Repository navigation
Description
Summary
If a model download is interrupted (for example with ctrl+c), the next mlxcel run <repo-id> loads the partial local snapshot and fails with Error: Weight not found: <tensor> instead of noticing the snapshot is incomplete and re-fetching it. The user has to know to delete the directory by hand.
Background
The downloader already stages each file to a tempfile and atomically renames it, and it has a full completeness gate snapshot_complete() that requires config.json plus every wanted file present and non-zero. But the load/resolve path uses a weaker "snapshot exists" check (essentially: is config.json present). An interrupted download that got config.json and only some of the safetensors shards therefore passes the resolver, the re-download is skipped, and loading dies at the first missing weight.
Proposed Solution
Before loading a pre-existing local snapshot, verify it against the same completeness gate the downloader uses (all files in the safetensors index / the repo wanted-set present and non-zero), not just config.json presence. On incompleteness, resume the download (re-fetch only the missing / zero-byte files, which download_repo already supports by skipping complete files) or, failing that, clean the partial snapshot and re-download, then load. Surface a clear message ("incomplete download detected, re-fetching N missing files") rather than a bare Weight not found.
Implementation Notes
- Reuse the strong gate on the load path:
snapshot_complete()atsrc/downloader/mod.rs:911(config.json + non-zero files; tests atsrc/downloader/tests.rs:443-459). - Strengthen the weaker load-side gate:
src/downloader/resolver.rs:55,75(currently mirrors onlyconfig.jsonpresence). - Download reuse / resume:
src/downloader/mod.rs:693(else if snapshot_complete(...)), staging+rename at:448,524,576, stale-partial cleanupcleanup_stale_partialsat:362-374. Routing an incomplete local dir back throughdownload_reposhould resume cheaply because complete files are skipped. - Current failure surface:
Weight not foundatsrc/lib/mlxcel-core/src/layers.rs:125(and peer call sites), which is where the incomplete snapshot currently blows up.
Acceptance Criteria
- Interrupting a download and then re-running
mlxcel run <repo-id>completes the download (resume) or cleans and re-downloads, then loads successfully, instead ofWeight not found. - The load/resolve path uses the full completeness gate (index / wanted-set + non-zero), not just
config.jsonpresence. - A clear message names the incomplete-snapshot condition and the re-fetch action.
- The same protection covers
mlxcel serve/mlxcel-serverauto-download (relates to fix(serve): mlxcel serve aborts with a nested-runtime panic when auto-downloading a missing model #463). - Regression coverage for the incomplete-snapshot to resume/redownload path.
Original Suggestion
Title: feat: autodetact and cleanup premature downloaded model
Problem / motivation
When a model downloading is interrupted, for example, with ctrl+c, mlxcel just throws an error it cannot find a required file:
% mlxcel run mlx-community/gemma-4-31B-it-qat-OptiQ-4bit
Runtime device: Apple GPU (Metal)
Loading model from "/Users/parkj/.cache/mlxcel/models/mlx-community/gemma-4-31B-it-qat-OptiQ-4bit"...
Error: Weight not found: language_model.model.layers.10.self_attn.k_proj.weight
Instead, it would be better to clean up such a model and download it again.
Proposed solution
As described, it would be better to clean up such a model and download it again.
Alternatives considered
No response
Scope
CLI behavior (mlxcel)
Acceptance criteria
No response
Additional context
No response
Pre-submission checks
- I searched existing issues and discussions and did not find a duplicate
Activity
[-]feat: autodetact and cleanup premature downloaded model[/-][+]fix: resume or repair incomplete model-store downloads[/+][-]fix: resume or repair incomplete model-store downloads[/-][+]feat(cli): detect an incomplete or interrupted model download and re-fetch instead of failing at load[/+]