fix: derive HF_HUB_CACHE from HF_HOME when set

Previously HF_HUB_CACHE always defaulted to ~/.cache/huggingface/hub
even when HF_HOME was explicitly set (e.g. in Docker). This caused
models to download to the wrong location instead of the configured
HF_HOME path.
This commit is contained in:
Roland Tannous 2026-04-05 05:22:43 +00:00
parent c26d909265
commit b362c60719

View file

@ -148,10 +148,11 @@ def _setup_cache_env() -> None:
os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")
).expanduser()
hf_default = xdg_cache / "huggingface"
hf_home = Path(os.environ.get("HF_HOME", str(hf_default)))
defaults: dict[str, str] = {
"HF_HOME": str(hf_default),
"HF_HUB_CACHE": str(hf_default / "hub"),
"HF_XET_CACHE": str(hf_default / "xet"),
"HF_HUB_CACHE": str(hf_home / "hub"),
"HF_XET_CACHE": str(hf_home / "xet"),
"UV_CACHE_DIR": str(root / "uv"),
"VLLM_CACHE_ROOT": str(root / "vllm"),
}