Core CLI
opod fetch
Download one GGUF file or a safetensors snapshot from Hugging Face into a models directory, exclusively, atomically and resumably, with no leader.
In short
opod fetch downloads model weights into a models directory, exclusively and atomically: a per-file lock, a temporary file, and a rename only once the file is complete and verified. It needs no leader, so a manager runs it as a prefetch job before a worker starts on the node.
opod fetch bartowski/Llama-3.2-3B-Instruct-GGUF Llama-3.2-3B-Instruct-Q4_K_M.gguf --dir /data/models
opod fetch --snapshot Qwen/Qwen2.5-7B-Instruct@a09a354 --dir /data/modelsUsage
opod fetch HF_REPO FILE [--dir DIR] [--revision REV] [--sha256 DIGEST]
opod fetch --snapshot HF_REPO[@REV] [--dir DIR] [--revision REV]opod fetch makes model weights present in a models directory. It needs no leader, no config file and no store. It is the same pull a worker runs before it starts an engine, so a manager can run it as a prefetch job on a node before any worker pod starts there, and the worker then finds the weights warm.
| Form | Fetches | For |
|---|---|---|
opod fetch HF_REPO FILE | One file, normally a .gguf. | llama.cpp |
opod fetch --snapshot HF_REPO[@REV] | The file set a safetensors engine loads from a repo. | vLLM, SGLang |
Flags
| Flag | Default | Effect |
|---|---|---|
--dir DIR | $OPOD_MODELS_DIR | The models directory. Required one way or the other. |
--revision REV | $OPOD_MODEL_REVISION | A commit sha, tag or branch. Empty means main, which moves when the repo owner pushes. A revision with a / or .. is refused. |
--sha256 DIGEST | $OPOD_MODEL_SHA256 | The SHA-256 the file must have, hex. A mismatch removes the file and fails. One file only. |
--snapshot HF_REPO[@REV] | — | Fetch a snapshot instead of one file. |
Flags may come before or after the positional arguments. FILE must be a bare file name: no / and no ...
opod fetch bartowski/Llama-3.2-3B-Instruct-GGUF Llama-3.2-3B-Instruct-Q4_K_M.gguf --dir /data/models
opod fetch bartowski/Llama-3.2-3B-Instruct-GGUF Llama-3.2-3B-Instruct-Q4_K_M.gguf \
--dir /data/models --revision 5ab33fa --sha256 6c1a2b…
opod fetch --snapshot Qwen/Qwen2.5-7B-Instruct@a09a354 --dir /data/modelsOn success it prints the path of the weights on stdout, one line, and exits 0. Logs go to stderr as text lines. From core v0.4.6 they are one human line per event (▶ fetching file (url=…, to=…), ▶ already cached (path=…)), a long download adds ▶ still fetching (done=12.3 of 40.1 GiB (30%)) every 30 seconds, and --log-format json gives structured lines for a log collector instead.
/data/models/Llama-3.2-3B-Instruct-Q4_K_M.gguf
/data/models/Qwen-Qwen2.5-7B-Instruct@a09a354Revisions with --snapshot
- A revision after
@is the explicit one. It wins over$OPOD_MODEL_REVISION. - A revision after
@that disagrees with a typed--revisionis refused:error: --snapshot names revision "a" and --revision names "b": say it once. --snapshot repo@(an empty revision) is refused:error: --snapshot wants <hf-repo>[@revision], got "repo@".- A snapshot takes no
--sha256: one digest cannot describe a set of files. Pin the revision to a commit sha instead; each weight file is checked against the SHA-256 the Hub records for it. A typed--sha256is refused; a$OPOD_MODEL_SHA256in the environment is ignored for a snapshot.
Where the weights go
| What | Path |
|---|---|
| An unpinned file | DIR/FILE |
| A pinned file | DIR/<repo-slug>@<rev>/FILE |
| A snapshot | DIR/<repo-slug>@<rev>/ (an unpinned snapshot is under …@main/) |
The slug is the repo name with every character other than a letter, a digit, -, . or _ replaced by -, and leading and trailing - removed: Qwen/Qwen2.5-7B-Instruct → Qwen-Qwen2.5-7B-Instruct. So two revisions of one model can be cached side by side.
Beside each file opod writes a few small files of its own:
| File | Purpose |
|---|---|
FILE.opod | The marker: JSON with the repo, file, size, digest, fetch time and last-use time. opod cache prune deletes only files that have one. |
FILE.lock | The per-file lock, present while a pull runs. |
FILE.partial-… | The download in progress. |
.opod-snapshot.json | In a snapshot directory: the manifest, written last. The directory counts as a complete snapshot only when it exists and every file it names is present at its size. |
What happens
For one file:
- Size. A
HEADto the Hub (30-second limit) gives the file's size. With no answer (offline, a mirror withoutHEAD), the size is unknown. - Already there? A file that is present, not empty, and of the right size — or of any size when the size is unknown — counts as complete. With
--sha256, its digest is checked (once; the marker remembers a match). opod records the use for least-recently-used pruning and prints the path. No download. - Lock. It creates
FILE.lockexclusively. When another process holds it, it waits until that process finishes the file (then returns its result) or the lock goes away. A lock whose holder died is taken over at once. An old-style lock with no live holder is replaced after 6 hours. - Download. It writes to a
FILE.partial-…sibling. When a partial is there from an earlier attempt, it resumes with an HTTPRangerequest; a server that ignoresRangestarts over. - Check and rename. Only when the byte count matches the server's, and the digest matches when one was given, is the partial renamed to
FILE. A reader never sees a half file under the final name. - Marker. It writes
FILE.opod. A marker that cannot be written only warns:cache marker not written: this file will never be pruned.
For a snapshot:
- It lists the repo at the revision through the Hub API and resolves the revision to a commit.
- It chooses the files an engine loads, from the top level of the repo only:
- one weight format:
.safetensorswhen there is any, else PyTorch (.bin,.pt,.pth), never both; consolidated*.safetensorsis dropped whenmodel*.safetensorsexists (the same tensors twice);- training files are dropped:
training_args.bin,optimizer.bin,optimizer.pt,scheduler.pt,scaler.pt,rng_state.pth; - side files by extension:
.json,.txt,.model,.tiktoken,.jinja,.py; - nothing else: no subdirectories (
original/,onnx/,gguf/hold the model in other formats), no READMEs, no images, no empty files, no.gguf.
- one weight format:
- It fetches each chosen file as above, with the same lock and the same atomic rename, and checks each weight file against the Hub's SHA-256.
- It writes
.opod-snapshot.jsonlast.
A vLLM or SGLang worker that finds a complete snapshot of its model at this path serves from it and does not pull at launch.
Guarantees
- Exclusive. One pull per file, whatever the number of callers. The others wait and share its result.
- Atomic. No partial file under the final name, ever.
- Idempotent. Run it twice and the second run downloads nothing.
- Resumable.
SIGINTorSIGTERM(what Kubernetes sends a deleted pod) cancels the pull cleanly: the lock is released and the partial is kept, so the next attempt resumes at once. - Owned. Only files opod fetched carry a marker, and only those can ever be pruned.
Hub errors
A refusal by the Hub fails by name, so a manager can say what to fix:
| Error | Meaning | Fix |
|---|---|---|
hub-token-missing | No HF_TOKEN, and the repo is gated or private. | Set HF_TOKEN. |
hub-token-refused | The token is not accepted. | Mint a new token. |
hub-access-denied | The token is valid, but its account may not read this repo. | Accept the model's licence on the Hub with that account. |
HF_TOKEN is the Hugging Face token, sent as Authorization: Bearer. HF_ENDPOINT points at a mirror (default https://huggingface.co). A digest mismatch reads fetch: … the cached FILE hashes to sha256:…, not the sha256:… this version records for a cached file, and removes a freshly downloaded one.
Result file
With OPOD_FETCH_RESULT=PATH, a successful fetch also writes one JSON line to PATH (mode 0644), only once the weights are in place:
{"path":"/data/models/Qwen-Qwen2.5-7B-Instruct@a09a354","signature":{…}}signature says whether the repository publishes a model-transparency signature (model.sig): unsigned, unverified or unknown. It is looked for, never verified, so it never reads as a pass. In Kubernetes, point OPOD_FETCH_RESULT at /dev/termination-log to read the result from the pod status. A failure to write the file only warns (fetch result not written); the fetch still succeeds. From core v0.4.6 the warning names the file, the error and where the weights are. The typed shape is FetchResult in core's pkg/adminapi.
Exit codes
| Code | Meaning |
|---|---|
0 | The weights are in place. |
1 | The fetch failed: error: fetch: … on stderr (opod: fetch: … from core v0.4.6). A Hub that does not answer says cannot reach the Hub at <url> (HF_ENDPOINT, or the default) … — check the address and the network, or unset HF_ENDPOINT. |
2 | Usage error (the usage text on stderr), a bad --snapshot argument, or no --dir and no OPOD_MODELS_DIR (error: --dir or OPOD_MODELS_DIR required). |
Last updated · Source: content/docs/core-cli/fetch.mdx · View as Markdown