Skip to content

fix: look for MLX models in $HF_HOME/hub - #61

Open
spicysharkco wants to merge 1 commit into
AlexsJones:mainfrom
spicysharkco:fix/hf-home-hub-dir
Open

spicysharkco wants to merge 1 commit into
AlexsJones:mainfrom
spicysharkco:fix/hf-home-hub-dir

Conversation

@spicysharkco

Copy link
Copy Markdown

Problem

discover_models uses HF_HOME as the hub directory. Hugging Face treats HF_HOME as the cache root and keeps the hub cache in $HF_HOME/hub, the same layout as the unset fallback. With HF_HOME=/data/hf, the models in /data/hf/hub are never scanned, so its MLX models are not listed.

Change

hf_hub_dir returns $HF_HOME/hub, or ~/.cache/huggingface/hub when unset. discover_models and the Sources tree in build_tree both use it.

Tests

cargo test --lib hf_home builds a cache under a temp HF_HOME root and expects the MLX model to be found, plus the unset default. It passes; with the helper returning HF_HOME unchanged (the old behaviour) it fails with left: 0, right: 1.

HF_HOME is the root of the Hugging Face cache and the hub cache lives in
$HF_HOME/hub, but model discovery and the Sources tree used HF_HOME
itself as the hub directory. With HF_HOME set, no MLX models were found.
Both now resolve the directory through one helper, matching the default
used when HF_HOME is unset.

@AlexsJones AlexsJones left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @spicysharkco, treating HF_HOME as the hub itself rather than the cache root is an easy mistake and this matches how Hugging Face documents it.

Checked at 56a4580: hf_hub_dir returns $HF_HOME/hub or the unchanged ~/.cache/huggingface/hub default, and both callers (discover_models and the tree label in app.rs) use it, so the sidebar path and the scan agree. The test builds a snapshot under a temp HF_HOME and proves scan_mlx_models finds it there. The cfg!(windows) branch that picked the same path either way is gone, which is a small cleanup on its own.

No checks have run on this PR (fork workflow approval), so CI hasn't been exercised on this head yet. Looks good to me otherwise.

This branch has not been deployed

No deployments
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.

2 participants