Skip to content
Opod

Core CLI

opod cache

List a node's weight cache, prune what no plan references without touching files opod did not fetch, and keep a disk KV-cache tier under a size bound.

In short

opod cache lists and reclaims the space model weights take on a node. It only ever deletes files opod itself fetched (they carry a marker), and it is a dry run unless you pass --apply. kv-prune keeps a disk KV-cache tier under a size cap. It runs on the node with no leader.

opod cache prune --dir /data/models            # what would go
opod cache prune --dir /data/models --apply    # remove it
would remove Llama-3.2-3B-Instruct-Q4_K_M.gguf           1.9 GB (last used 31h0m0s ago)
would remove 1 item(s), 1.9 GB; kept 2 referenced or recent; left 1 file(s) this cache did not write (my-own-model.gguf)

Usage

opod cache ls [--dir DIR] [--json]
opod cache prune [--dir DIR] [--keep a,b] [--min-age 24h] [--target-free GB] [--sweep 24h] [--apply] [--json]
opod cache kv-prune --dir DIR --max-gb N [--keep a,b] [--every 10s] [--apply] [--json]

Models are pulled once per node into the models directory and shared by every worker on it. Nothing deletes from that directory on its own, so a node fills up. opod cache reclaims the space safely. It runs on the node, without a leader, a config file or a store. A manager runs prune as a job and passes the files its plans still reference.

Two facts make a delete safe:

  • A marker. opod fetch and every worker pull write FILE.opod beside each file they fetch. A prune only ever considers files with a marker. Everything else on the volume is the owner's and is never touched, whatever it looks like.
  • The download lock. A prune takes the same per-file lock a download takes, so a prune and a pull never race. Whoever gets the lock goes first.

opod cache ls

What is cached, which entries opod fetched, their size and when each was last used.

FlagDefaultEffect
--dir DIR$OPOD_MODELS_DIRThe models directory.
--jsonoffA JSON array of entries.
opod cache ls --dir /data/models
Llama-3.2-3B-Instruct-Q4_K_M.gguf           1.9 GB  opod      last used 3h12m0s ago
Qwen-Qwen2.5-7B-Instruct@a09a354/ (snapshot, 14 files)    14.2 GB  opod      last used 26h4m0s ago
my-own-model.gguf                           4.1 GB  not ours  last used never recorded

One line per entry: the name, the size in GiB, opod or not ours, and the last use. A file pinned to a revision is named <repo-slug>@<rev>/FILE and listed by itself. A safetensors snapshot is one entry with the directory's total size, because an engine loads the whole directory. opod's own bookkeeping files (*.opod, *.lock, *.partial-*, *.trash-*) are not listed. A directory that is not a <repo-slug>@<rev> revision directory is not looked into.

JSON fields

FieldMeaning
pathAbsolute path.
fileName relative to --dir: a.gguf, <repo-slug>@<rev>/a.gguf, or <repo-slug>@<rev> for a snapshot.
repoThe Hugging Face repo, from the marker.
sizeBytes; for a snapshot, the sum of its files.
ourstrue when opod fetched it. Only these can be pruned. A snapshot is ours only when its manifest reads and every file in it has a marker.
fetchedAt, lastUsedAtFrom the marker. A worker or a fetch that finds the file records a use.
revisionSet for anything under a revision directory.
snapshot, filesA snapshot directory, and how many files it holds.

opod cache prune

Remove cached entries that are opod's, that no one references, and that have not been used for a while. A dry run unless you pass --apply.

FlagDefaultEffect
--dir DIR$OPOD_MODELS_DIRThe models directory.
--keep a,b—Entries that must survive, comma-separated (below).
--min-age D24hLeave entries used more recently than this, so a rollback finds its weights warm.
--target-free GB0Stop once the volume has this many GB free. 0 removes every prunable entry.
--sweep D24hWith --apply, also clear the leftovers of crashed pulls (temp files and locks nothing writes any more) older than this. 0 turns it off. Without --apply there is no sweep.
--applyoffActually delete.
--jsonoffOne JSON result object.

What --keep matches

  • A bare file name (a.gguf) keeps that file wherever it is cached: at the top and under every revision.
  • A path under --dir (org-model@rev/a.gguf) keeps exactly that entry.
  • A snapshot is kept by its directory name (Qwen-Qwen2.5-7B-Instruct@a09a354, bare or as a path) or by the path of any file inside it. Never by a bare file name, since every snapshot holds a config.json.

The manager computes this list: every file a plan, a job, an in-flight prefetch or a staged model version on this node references. prune trusts it.

Rules

  1. Only entries with opod's marker are considered. A file opod did not fetch is never deleted, whatever the disk pressure; the summary names it.
  2. Entries used within --min-age and entries on the keep list are kept.
  3. The least recently used entries go first.
  4. With --target-free, the prune stops as soon as the volume has that much free.
  5. Each removal takes the file's download lock. A file a pull holds is left for the next run. A lock whose holder died is taken over.
  6. A safetensors snapshot goes whole, under every one of its files' locks, or stays whole. The manifest is removed first, so an engine that starts mid-prune pulls for itself instead of loading a directory that is losing files. One file in it that opod did not write leaves the whole directory alone.
  7. A removal renames the file to .trash-… and then unlinks it, so a reader that opened it a moment earlier keeps reading.
opod cache prune --dir /data/models                                     # what would go
opod cache prune --dir /data/models --keep Qwen-Qwen2.5-7B-Instruct@a09a354 --apply
opod cache prune --dir /data/models --target-free 100 --min-age 72h --apply
would remove Llama-3.2-3B-Instruct-Q4_K_M.gguf           1.9 GB (last used 31h0m0s ago)
would remove 1 item(s), 1.9 GB; kept 2 referenced or recent; left 1 file(s) this cache did not write (my-own-model.gguf)
dry run: pass --apply to delete

With --apply, would remove reads removed, the last line is gone, and a sweep that cleared anything says swept N leftover(s) of crashed pulls on stderr.

JSON result

FieldMeaning
removedThe entries removed, or that would be (same shape as ls).
freedBytesBytes freed, or that would be.
keptEntries kept because referenced or recent.
skippedFiles that are not opod's, by name.
dryRuntrue without --apply.
totalBytes, freeBytesThe volume holding the cache, measured where the prune ran.
volumeErrWhy the volume could not be measured, when it could not.
sweptLeftovers cleared by --sweep.

A full node

On a node whose disk is full, the kubelet admits only pods of priority system-cluster-critical and above, so a prune job of normal priority cannot start on the node that needs it most. Give the prune job a priority class that is admitted under disk pressure.

opod cache kv-prune

Bound a disk KV-cache tier: the directory an engine writes KV blocks to (the kv_tier_fs engine flag). The engine never deletes from it, so something must. A manager runs this beside the engine, for as long as the engine writes the directory.

FlagDefaultEffect
--dir DIR—The tier directory. Required.
--max-gb N—Cap on the tier's files, in GiB; decimals are allowed. Required. 0 removes everything but the --keep entries.
--keep a,b—Top-level entries of --dir that are never touched.
--every D0 (once)Repeat at this idle interval until stopped (SIGINT or SIGTERM). While the tier grows or is being trimmed, the next pass follows within 1 second.
--applyoffActually delete.
--jsonoffOne JSON object per pass.
opod cache kv-prune --dir /data/kvtier/ep --max-gb 100                          # one dry pass
opod cache kv-prune --dir /data/kvtier/ep --max-gb 100 --every 10s --apply      # keep it bounded
/data/kvtier/ep: 103.40 GiB in the tier; removed 812 file(s), 13.42 GiB (walk 41 ms, remove 220 ms)

How a pass works:

  1. It walks --dir and counts only the tier's own files: *.bin (blocks), *.tmp (blocks being written) and config.json.
  2. When the total is above --max-gb, it removes the oldest files first until the total is at 90 % of --max-gb, so the next burst does not trip the cap at once.
    • From core v0.4.7, with --every, a pass also counts the growth since the previous pass as already written (at most half of --max-gb). It trims when the total plus that growth is above --max-gb, down to 90 % less the growth, so a tier that a burst keeps filling is trimmed ahead of it. The growth is measured from one pass to the next, so in core v0.4.7 a burst that starts while the pruner is idle (one pass every --every) is not trimmed ahead: on NFS, two writers took a tier capped at 0.85 GiB to 1.07 GiB before the first trim, 10 s after the burst began.
    • From core v0.4.8, while idle the loop also reads the volume's free space every second (one statfs call, not a walk) and runs a pass at once when it has dropped by a twentieth of --max-gb. The same two-writer burst then peaked at 0.95–1.08 × the cap in four runs. Another writer on the same volume only brings a pass forward.
    • From core v0.4.7, a pass lists up to 32 directories at once. On a network filesystem (NFS) each listing is a round trip, and vLLM puts almost every block in its own directory: a one-at-a-time pass took 3.7 s for 3,362 blocks on NFS, long enough for two writers to take a 1 GiB tier to 2.28 GiB.
  3. Entries named in --keep are never touched.

With --every, a pass that removes nothing prints nothing (except with --json), and a failed pass prints error: … and the next pass tries again. A single pass that fails exits 1.

JSON per pass: dir, dryRun, usedBytes (before the pass), removed (files), freedBytes, totalBytes and freeBytes (the volume), volumeErr, walkMs, removeMs. A pass much longer than --every is how a burst outruns the cap.

Exit codes

CodeMeaning
0Done (or a dry run).
1An error: error: … on stderr.
2No --dir and no $OPOD_MODELS_DIR (error: --dir or OPOD_MODELS_DIR required), or, for kv-prune, no --dir or no --max-gb (error: --dir and --max-gb are required).

From core v0.4.6:

  • Every message starts with opod:, and kv-prune names the flag it lacks (needs --dir, the tier directory or needs --max-gb, the tier's cap in GiB). An extra argument is a usage error.
  • Sizes are labelled GiB, which is what they always were (bytes ÷ 2³⁰).
  • ls on an empty cache says (no weights cached in <dir>).
  • prune's dry run says it does not sweep crashed pulls; with --apply the sweep's count is on stdout with the summary, and a failed sweep is a warning.
  • kv-prune on a directory that does not exist warns (… does not exist — nothing to prune) and still exits 0 with its result — a sweep may find a tier already gone. With --every it prints a start line, waits for the directory the engine creates (warning every 10 minutes while it is missing, so a mistyped --dir shows), and prints an idle pass at most once a minute.
  • --json stays one object per line: a control plane reads the last line that starts with {.

Last updated · Source: content/docs/core-cli/cache.mdx · View as Markdown