Repository navigation
fix(serve): refuse to boot a pinned-weights package over an incomplete cache - #136
Conversation
…e cache Some container manifests pin the weights snapshot path straight into the serve env (MISTRAL4_WEIGHTS_DIR=/hf/hub/models--org--w/snapshots/...) and the loader opens it directly. For those packages the advisory "the model will download them inside the container" is false: with --local-only, or when the prefetch itself fails (gated repo, offline), serve warned and booted anyway, paid ~30s of device init, and died in the engine on the first missing shard. Pass the merged serve profile into ensure_weights (serve only; pull never refuses). When its env pins a path into the weights' HF cache dir and the cache is not whole after the point where serve could have fixed it, raise a diagnosis card instead of the note: it tells an interrupted download from an absent one, says how much is already on disk, and names the exact `hf download --revision` that resumes it plus the managed `tt-model pull --with-weights`. --no-weights stays the escape hatch. The advisory note itself now also distinguishes a partial download from an absent one, since the fix differs (resume, not restart). DEVSTACK-470 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
anirudTT
left a comment
There was a problem hiding this comment.
Question : on the implementation, do we also help the user re download the model weights ?, this can ofc be a follow up PR
ezietlowTT
left a comment
There was a problem hiding this comment.
Approve. Reviewed and tested (container_cli tests 182 passed; full offline suite 922 passed; verified 6 of the new tests fail against pre-fix main).
The core insight is right and the fix is well-scoped. Two kinds of package declare weights: one calls from_pretrained on the HF id inside the container (a missing cache is just a slow first boot), the other pins the snapshot path into the serve env and the loader opens it directly (a missing shard is fatal, in the engine, after ~30s of device init). The old advisory "the model will download them inside the container" is simply false for the second kind, and this moves that failure to a card before device init.
Verified against the code:
_pinned_weights_envkeys off the HF cache dir name (models--org--repo) appearing in any serve-env value — the one stable marker that the model reads from the cache rather than fills it. Reasonable and correct.- The refusal fires only for
serve(which passesprofile) with a pinned path over an incomplete cache that serve can't fix (--local-only, or the prefetch failed);pullpasses no profile and so never refuses — matches the stated contract, and there's a test for it. --no-weightsstays the escape hatch (a warn, not a refusal) —pinned and not no_weights. Correct.- A complete cache still serves offline (tested), so the gate doesn't over-fire.
- Interrupted vs absent is told apart with bytes-on-disk, so the remedy is resume (not delete-and-restart), and a failed prefetch's own classification (gated/offline/no-repo) is folded into the card's actions.
Not hardware-exercised (author notes the chips were busy and the capacity check runs first) — acceptable here: the whole path is offline-testable and the new tests cover the refuse/warn/escape-hatch/pull branches. community-labeling red is the known #80 gating.
# Conflicts: # tests/test_container_cli.py
|
Resolved the merge conflict for you. It was a purely additive collision in Non-destructive (fast-forward merge commit, no history rewrite). Verified: full offline suite 986 passed, and this branch's diff vs |
Follow-up to DEVSTACK-470.
Nothing about how a package serves changes here. This is about guiding the user when the weights on the host are incomplete and
servecannot fix that itself (--local-only, or the prefetch failed on a gated repo / offline Hub).Some manifests pin the weights snapshot path straight into the serve env (the reporter's
ndaly/Mistral-Small-4-119B-2603-tt-p300x2setsMISTRAL4_WEIGHTS_DIR=/hf/hub/models--…/snapshots/…) and the loader opens that path directly. For those, our note "the model will download them inside the container" was wrong: the boot went through ~30s of device init and died in the engine on the first missing shard. The same failure now happens before device init, as a card that says what is going on and what to do:hf download <repo> --revision <rev>that resumes it, andtt-model pull <id> --with-weightsas the managed equivalent--no-weightsas the escape hatch, which warns and boots exactly as beforePackages that do not pin a path keep the advisory note, and
pullnever refuses. The note itself now also tells an interrupted download from an absent one, since the fix differs (resume, not start over).Tests
tests/test_container_cli.py, 6 of which fail onmain.test_container_run.pyfail identically on untouchedmainon my box.To try it (a box with free TT chips + docker)
Expected: a red card "weights download is incomplete" naming
MISTRAL4_WEIGHTS_DIRand "1.0 GB is on disk", exit 1, nothing new indocker ps. Add--no-weightsand it prints a ⚠ "a download was interrupted" note and boots instead (Ctrl-C, thentt-model stop …). Clean up withrm "$B/0000deadbeef.incomplete".🤖 Generated with Claude Code