How do I run a generation worker with Hugging Face offline mode, and what does it do to a cache hit versus an API call?
Problem. Workers on a cluster with no or slow internet stall on version-check calls. Conditions. Cache already populated (ideally by a pinned prefetch). Method. Prefetch with a full commit hash (snapshot_download revision=<hash>), then set HF_HUB_OFFLINE=1 in the worker; no HTTP call is made and only cached files are used; a missing file raises an error. This also skips the online freshness check that a plain hf_hub_download makes even when the latest file is cached. Failure modes. Any HfApi call raises OfflineModeIsEnabled; the offline lookup of a branch name relies on refs/<branch> in the cache, so a worker should request the same pinned hash it prefetched. Limitations. Extends C3-B609-03 (offline run and audit): adds the pinned-prefetch pattern and the exception behaviour. Whether a given downstream loader (transformers, diffusers) honours the variable was not tested. Version/date: huggingface_hub docs main branch fetched 2026-10-24 (stamp per bibliography); behaviour may differ ...
Structured fields
{
"citations": [
{
"url": "https://huggingface.co/docs/huggingface_hub/main/en/package_reference/environment_variables.md",
"note": "HF_HUB_OFFLINE; HF_HUB_OFFLINE; HF_HUB_OFFLINE; researcher reasoning"
}
]
}Evidence claims
- [sourced_fact] Problem. Workers on a cluster with no or slow internet stall on version-check calls. Conditions. Cache already populated (ideally by a pinned prefetch). Method. Prefetch with a full commit hash (snapshot_download revision=<hash>), then set HF_HUB_OFFLINE=1 in the worker; no HTTP call is made and only cached files are used; a missing file raises an error. This also skips the online freshness check that a plain hf_hub_download makes even when the latest file is cached. Failure modes. Any HfApi call raises OfflineModeIsEnabled; the offline lookup of a branch name relies on refs/<branch> in the cache, so a worker should request the same pinned hash it prefetched. Limitations. Extends C3-B609-03 (offline run and audit): adds the pinned-prefetch pattern and the exception behaviour. Whether a given downstream loader (transformers, diffusers) honours the variable was not tested. Version/date: huggingface_hub docs main branch fetched 2026-10-24 (stamp per bibliography); behaviour may differ in older releases. · locator: HF_HUB_OFFLINE; HF_HUB_OFFLINE; HF_HUB_OFFLINE; researcher reasoning source
Rights
| component | license | hosting | redistribution | modification | training | Evidence and notes |
|---|---|---|---|---|---|---|
| documentation | unknown | permitted | permitted | unknown | unknown | Applies to this original summary only, not to the cited sources. |