Skip to content

Scan HuggingFace Hub cache during model discovery using hf-hub crate#17

Open
DylanSchell wants to merge 1 commit into
pwilkin:masterfrom
DylanSchell:feature/hf-cache-support
Open

Scan HuggingFace Hub cache during model discovery using hf-hub crate#17
DylanSchell wants to merge 1 commit into
pwilkin:masterfrom
DylanSchell:feature/hf-cache-support

Conversation

@DylanSchell
Copy link
Copy Markdown
Contributor

@DylanSchell DylanSchell commented May 5, 2026

Use hf_hub::Cache::from_env() to discover GGUF files in the HuggingFace Hub cache (respects HF_HOME environment variable). Models are scanned alongside user-configured directories and shown with an 'HF' badge in the UI so users can distinguish them from their own directories.

Partial implementation of #14

@DylanSchell DylanSchell marked this pull request as draft May 6, 2026 16:47
@DylanSchell
Copy link
Copy Markdown
Contributor Author

working on the download code

@DylanSchell DylanSchell force-pushed the feature/hf-cache-support branch 2 times, most recently from 93e21c2 to bc7ad0a Compare May 6, 2026 18:45
@DylanSchell
Copy link
Copy Markdown
Contributor Author

Download to HF cache is working. delete is working, but it only deletes the symlink under the snapshots folder ( I assume this is expected behavior for hf cache management, since the blob might be used by multiple models. like mmproj files? )

@DylanSchell DylanSchell force-pushed the feature/hf-cache-support branch 2 times, most recently from 7740f37 to 20b047e Compare May 7, 2026 17:35
Add opt-in support for downloading models directly into the HuggingFace
Hub cache (HF_HOME or ~/.cache/huggingface/) via the hf-hub crate, and
scanning that cache during model discovery.

- Toggle HF cache on/off at runtime with a config flag
- Download models into HF cache structure (blobs/ + snapshots/) with
  proper progress tracking using cumulative atomic byte counters
- Scan existing HF cache alongside configured model directories
- Skip redundant downloads by checking if cached files already exist
- Clean up stale .lock files left by hf-hub after downloads
- Show mmproj picker dialog when downloading from the recommended tab,
  using actual HF API file sizes instead of estimates
- Delete all symlinks in a snapshot commit directory when pruning HF
  cache models (model weights + mmproj companions), then prune orphaned
  blobs and empty directories
- Accept any mmproj symlink in HF cache snapshot directories as a valid
  companion, since the shared commit directory proves they belong to the
  same repo
@DylanSchell DylanSchell force-pushed the feature/hf-cache-support branch from 48aa5c2 to 9e45aed Compare May 7, 2026 18:20
@DylanSchell DylanSchell marked this pull request as ready for review May 7, 2026 18:22
@DylanSchell
Copy link
Copy Markdown
Contributor Author

delete code now also in place.

I've tested this on a macOs machine, not quite sure if windows would need special handling, since I assume HF cache does not use symlinks on windows.

@DylanSchell
Copy link
Copy Markdown
Contributor Author

the mmproj picker did not appear when downloading from the recommended models page, so that was also added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant