Repository navigation
feat(downloader): detect incomplete snapshot and re-fetch on load - #604
Merged
Merged
Conversation
An interrupted model download leaves a partial snapshot (config.json plus only some safetensors shards). The resolver previously reused it after only checking that config.json was present, so `mlxcel run <repo-id>` (and `mlxcel serve` / `mlxcel-server` auto-download, which funnel through the same resolver) loaded the partial snapshot and died with a bare `Weight not found`. The loader's stale-index glob fallback (kept for repackaged mlx-community quants) silently loads whatever shards are present, which is why the failure surfaced as a missing tensor rather than a missing shard. The load/resolve path now classifies a candidate snapshot against its own `model.safetensors.index.json` in a new `src/downloader/completeness.rs`: every shard the index names must be present and non-zero. An interrupted download (the on-disk shards are a subset of the index) is treated as a miss and resumed through the shared `download_repo`, which skips files already present and re-fetches only the missing ones, with a forced clean re-download as a fallback and a clear "incomplete download detected, re-fetching N missing files" message. A repackaged mlx-community quant whose stale full-precision index no longer matches the on-disk quant files is still reused without a re-fetch, mirroring the loader's glob tolerance, so common quant snapshots do not pay a spurious network round-trip. Because every subcommand (run, generate, chat, inspect, serve) and the mlxcel-server binary resolve `-m` through `resolve_model_source_with_override`, the same protection covers the server auto-download path (relates to #463) with a single gate. Changes: - Add `src/downloader/completeness.rs`: offline `classify_snapshot` gate (Complete / Incomplete / Absent) reusing `mlxcel_core::weights::parse_shard_index`, with a shard-name traversal guard. - Strengthen the resolver's legacy and mlxcel-store reuse gates to the full-weight check; route an incomplete destination through resume then forced re-download. - Replace the two weak-gate unit tests with classifier coverage and add a resolver regression test that an interrupted store snapshot is not a cache hit. - CHANGELOG: record the fix.
inureyes
added a commit
that referenced
this pull request
Jul 2, 2026
* chore(mlx): bump pin to e9463bb and rebase CUDA overlays (#625) Bump the pinned MLX commit from a6ec7123dac814417147e21d4aeed694924ddd4d (2026-06-10) to e9463bbfc1a7cd9e0e6b96aaa3068a316e234a63 (upstream main, 2026-07-01) in both enforcement points (mlx-cpp/CMakeLists.txt GIT_TAG and mlxcel-core/build.rs MLX_EXPECTED_COMMIT), and reconcile every source overlay three-way against the 63 upstream commits between the pins (qmv global scale #3723, JIT qmm/gather_gemm #3706 and qmm_naive #3576, rope without copy #3704, Tegra managed-memory gate #3701, fused SDPA asymmetric head dims #3637, NAX qmm fixes #3631/#3632, large-uncontiguous-grid fix 4885acd). git diff --stat (src/lib/mlx-cpp/ overlay rebase plus supporting changes): .github/workflows/release.yml | 40 +- .../mlx-pin-upgrade-2026-07-03.md | 139 ++++++ docs/installation.md | 30 +- src/bin/mlx_server.rs | 5 + src/lib/mlx-cpp/CMakeLists.txt | 25 +- src/lib/mlx-cpp/patches-cuda/ops.cpp | 362 +++++++++++---- .../patches/mlx/backend/cuda/binary/binary.cuh | 136 +++--- .../patches/mlx/backend/cuda/jit_module.cpp | 66 ++- .../patches/mlx/backend/cuda/primitives.cpp | 41 -- .../patches/mlx/backend/cuda/quantized/qmm/qmm.h | 149 ------ .../patches/mlx/backend/cuda/quantized/qmm/qmv.cu | 504 --------------------- .../mlx/backend/cuda/quantized/quantized.cpp | 25 +- src/lib/mlxcel-core/build.rs | 3 +- src/main.rs | 3 + src/models/gemma4_mtp_target_tests.rs | 44 +- src/models/sanitize.rs | 28 +- 16 files changed, 707 insertions(+), 893 deletions(-) Per-file decisions: - patches/mlx/backend/cuda/quantized/qmm/qmm.h: dropped (superseded), the overlay delta vs the old pin was a documentation comment only and pristine e9463bb adds the global_scale parameter from upstream #3723 which we want unmodified. - patches/mlx/backend/cuda/quantized/qmm/qmv.cu: dropped (superseded), comment-only delta vs the old pin (the broadcast_w fix it documented had already landed upstream), and pristine e9463bb carries qmv global-scale support (#3723) plus the relocated device/cute_dequant.cuh include (#3576). - patches/mlx/backend/cuda/primitives.cpp: dropped (no-op), the overlay was byte-identical to upstream apart from an annotation comment. - patches/mlx/backend/cuda/quantized/quantized.cpp: rebased, re-applied the ensure_row_contiguous fix for w/scales/biases in QuantizedMatmul::eval_gpu (non-contiguous 3D batched MLA weights, upstream-rejected) onto the new base that now passes std::nullopt global_scale to qmv; the GatherQMM path returns to pristine upstream. - patches/mlx/backend/cuda/jit_module.cpp: rebased, re-applied the /proc/self/exe executable-dir resolution, the MLXCEL_CCCL_DIR override, and the cold-JIT stderr notice onto the new base, adopting upstream's cccl_dir() fallback, the extra bundled include path, the JIT'd qmm/cute_dequant header registration (#3706/#3576), the CUTLASS nvrtc flags, and the get_jit_module(Device&) signature; MLX_PTX_CACHE_DIR handling is unchanged upstream so the persistent PTX cache redirect still takes effect (upstream #3587 turned out to be CI-cache-only, no code conflict). - patches/mlx/backend/cuda/binary/binary.cuh: rebased (adapted), re-applied the mixed-precision bf16/fp32 kernels, trait, and dispatch onto the new base; this also drops stale v0.31.1-era reversions the old overlay was silently carrying (missing __launch_bounds__/BINARY_MAX_BLOCK_DIM) and adopts upstream's large-grid index_rest fix (grid.z) and get_launch_args_general in both the same-type and the mixed general paths. - patches-cuda/ops.cpp: rebased (adapted), re-applied bf16_mixed_astype() and its use in add/subtract/multiply/divide/maximum/minimum onto the new base; this drops stale v0.31.1-era reversions the old overlay was silently carrying (safe_cast overflow checks, the arange zero-step check, use-after-move-prone auto& shape bindings) and picks up upstream's new array-API ops unmodified. - src/lib/mlx-cpp/CMakeLists.txt: pin bump, retargeting the MLX_CCCL_DIR compile definition to the new mlx_dirs OBJECT target (upstream moved the macro consumer into dirs.cpp) with a fallback to the mlx target, and a new MLX_CUTLASS_DIR build-tree fallback because the JIT'd quantized kernels now need CUTLASS/CuTe headers at runtime. - Runtime JIT deployment: upstream #3706/#3576 moved the CUTLASS qmm/gather_gemm instantiations from build-time nvcc to runtime NVRTC (cold build dropped from 30+ min to ~7.5 min on GB10), so quantized models now need cute/ and cutlass/ headers on the deployment host at first run; the jit_module overlay resolves them via MLXCEL_CUTLASS_DIR, the bundled include/ layout, or the compiled-in build-tree path, release archives bundle include/cute + include/cutlass next to include/cccl, and docs/installation.md documents the requirement. - src/lib/mlxcel-core/build.rs: also watch ../mlx-cpp/patches-cuda with rerun-if-changed (it was unwatched, so edits to the CUDA-only dtype/fast/ops overlays did not retrigger the MLX build). - Unchanged overlays (base file identical between the two pins, kept as-is): device/binary_ops.cuh, gemms/grouped_gemm.h, gemms/grouped_gemm_unaligned.cu, matmul.cpp (CUTLASS GatherMM rework intentionally still bypasses upstream's JIT gather_gemm; re-baseline sweep will confirm), reduce/{all,col,init,row}_reduce.cu, reduce/reduce_ops.cuh, metal/compiled.cpp, metal/kernels/utils.h, patches-cuda/{dtype,fast}.cpp. Test-suite reconciliation (cargo test --release --features cuda on GB10): - src/models/sanitize.rs: fix NVFP4 block-scale parsing to be load-dtype-agnostic (astype to F32 before the raw-byte parse). The CUDA loader widens F16 safetensors to F32 at load (from_bytes_f16, CUDA branch since 2026-03), so the previous F16 byte parse read zeros on CUDA; this is a pre-existing CUDA bug exposed by running the suite here, not a pin regression, and it also corrects real gemma4-nvfp4 scale handling on CUDA. f16_to_f32 is now cfg(test) (kept for its format unit tests). - src/models/gemma4_mtp_target_tests.rs: the batched-vs-B=1 bitwise-equality assertion now uses a 2e-3 fp32 tolerance on CUDA (bitwise retained elsewhere). Since MLX #3704 (rope without copy) RoPE preserves input layouts instead of canonicalizing with a copy, so downstream GEMM/SDPA kernels can see different strides for the batched row than for the B=1 replay and pick different reduction orders (observed max_abs 1.6e-4 on fp32 hidden of magnitude ~8). The argmax-equality assertion is unchanged, preserving the functional MTP verify guarantee. - docs/installation.md: document running the CUDA test suite with --test-threads=1. The JIT'd kernels are now compiled and module-loaded on first use, and those first-use paths are not safe against concurrent test threads: the default parallel run aborts with cudaStreamEndCapture capture errors (module load racing another thread's capture) or, with MLX_USE_CUDA_GRAPHS=0, with cuLaunchKernelEx invalid-argument (kernel-configure race). Inference binaries are unaffected. - src/main.rs: add the GLM VLM, Kimi VLM, and PaddleOCR VLM families to FAMILY_ORDER (pre-existing gap on main from the recent VLM ports; family_order_is_exhaustive fails without it and blocks the suite). - src/bin/mlx_server.rs: the legacy-server-mode resolver test fixture now writes a stub model.safetensors next to config.json; the offline completeness gate from PR #604 classifies a config-only directory as an interrupted download and re-fetches from the network, which 404s on the synthetic repo id (pre-existing on main since #604). Tegra note: upstream #3701 gates managed memory on concurrentManagedAccess only; GB10 reports concurrentManagedAccess=1, so managed memory stays enabled on GB10 under both pins and #3701 is a no-op on this platform (details in docs/benchmark_results/mlx-pin-upgrade-2026-07-03.md). * docs(bench): GB10 re-baseline and Phase 3 triage for the MLX pin bump Adds the focused GB10 re-baseline CSV (benchmarks/cuda_gb10_2026-07-03.csv, 19 models covering all Phase-3 outlier families plus dense/MoE/SSM/VLM representatives and a pure-mamba control) and fills the outlier-verdict table in docs/benchmark_results/mlx-pin-upgrade-2026-07-03.md. Verdicts: MoE prefill collapse (#629) is unchanged (our matmul.cpp CUTLASS GatherMM overlay bypasses upstream's now-JIT'd gather_gemm, so #3706 does not reach the path); the hybrid-SSM decode gap (#631) is unchanged (pure-mamba control healthy, isolating the gap to the hybrid path); the gemma-4-31b nvfp4 outlier (#630) is root-caused (the checkpoint is NVIDIA ModelOpt-packed and now correctly rejected; the genuine MLX-native nvfp4 dequant bug was fixed here in sanitize.rs; mxfp4 sibling healthy) and re-scoped to end-to-end validation plus a guard test. No Phase-3 issue is fully fixed by the pin bump, so Phase 3 stands at three issues. Dense decode is uniformly +1 to +3% with several prefill gains and no cross-family regression.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…blup#604) An interrupted model download leaves a partial snapshot (config.json plus only some safetensors shards). The resolver previously reused it after only checking that config.json was present, so `mlxcel run <repo-id>` (and `mlxcel serve` / `mlxcel-server` auto-download, which funnel through the same resolver) loaded the partial snapshot and died with a bare `Weight not found`. The loader's stale-index glob fallback (kept for repackaged mlx-community quants) silently loads whatever shards are present, which is why the failure surfaced as a missing tensor rather than a missing shard. The load/resolve path now classifies a candidate snapshot against its own `model.safetensors.index.json` in a new `src/downloader/completeness.rs`: every shard the index names must be present and non-zero. An interrupted download (the on-disk shards are a subset of the index) is treated as a miss and resumed through the shared `download_repo`, which skips files already present and re-fetches only the missing ones, with a forced clean re-download as a fallback and a clear "incomplete download detected, re-fetching N missing files" message. A repackaged mlx-community quant whose stale full-precision index no longer matches the on-disk quant files is still reused without a re-fetch, mirroring the loader's glob tolerance, so common quant snapshots do not pay a spurious network round-trip. Because every subcommand (run, generate, chat, inspect, serve) and the mlxcel-server binary resolve `-m` through `resolve_model_source_with_override`, the same protection covers the server auto-download path (relates to lablup#463) with a single gate. Changes: - Add `src/downloader/completeness.rs`: offline `classify_snapshot` gate (Complete / Incomplete / Absent) reusing `mlxcel_core::weights::parse_shard_index`, with a shard-name traversal guard. - Strengthen the resolver's legacy and mlxcel-store reuse gates to the full-weight check; route an incomplete destination through resume then forced re-download. - Replace the two weak-gate unit tests with classifier coverage and add a resolver regression test that an interrupted store snapshot is not a cache hit. - CHANGELOG: record the fix.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…lablup#642) * chore(mlx): bump pin to e9463bb and rebase CUDA overlays (lablup#625) Bump the pinned MLX commit from a6ec7123dac814417147e21d4aeed694924ddd4d (2026-06-10) to e9463bbfc1a7cd9e0e6b96aaa3068a316e234a63 (upstream main, 2026-07-01) in both enforcement points (mlx-cpp/CMakeLists.txt GIT_TAG and mlxcel-core/build.rs MLX_EXPECTED_COMMIT), and reconcile every source overlay three-way against the 63 upstream commits between the pins (qmv global scale lablup#3723, JIT qmm/gather_gemm lablup#3706 and qmm_naive lablup#3576, rope without copy lablup#3704, Tegra managed-memory gate lablup#3701, fused SDPA asymmetric head dims lablup#3637, NAX qmm fixes lablup#3631/lablup#3632, large-uncontiguous-grid fix 4885acd). git diff --stat (src/lib/mlx-cpp/ overlay rebase plus supporting changes): .github/workflows/release.yml | 40 +- .../mlx-pin-upgrade-2026-07-03.md | 139 ++++++ docs/installation.md | 30 +- src/bin/mlx_server.rs | 5 + src/lib/mlx-cpp/CMakeLists.txt | 25 +- src/lib/mlx-cpp/patches-cuda/ops.cpp | 362 +++++++++++---- .../patches/mlx/backend/cuda/binary/binary.cuh | 136 +++--- .../patches/mlx/backend/cuda/jit_module.cpp | 66 ++- .../patches/mlx/backend/cuda/primitives.cpp | 41 -- .../patches/mlx/backend/cuda/quantized/qmm/qmm.h | 149 ------ .../patches/mlx/backend/cuda/quantized/qmm/qmv.cu | 504 --------------------- .../mlx/backend/cuda/quantized/quantized.cpp | 25 +- src/lib/mlxcel-core/build.rs | 3 +- src/main.rs | 3 + src/models/gemma4_mtp_target_tests.rs | 44 +- src/models/sanitize.rs | 28 +- 16 files changed, 707 insertions(+), 893 deletions(-) Per-file decisions: - patches/mlx/backend/cuda/quantized/qmm/qmm.h: dropped (superseded), the overlay delta vs the old pin was a documentation comment only and pristine e9463bb adds the global_scale parameter from upstream lablup#3723 which we want unmodified. - patches/mlx/backend/cuda/quantized/qmm/qmv.cu: dropped (superseded), comment-only delta vs the old pin (the broadcast_w fix it documented had already landed upstream), and pristine e9463bb carries qmv global-scale support (lablup#3723) plus the relocated device/cute_dequant.cuh include (lablup#3576). - patches/mlx/backend/cuda/primitives.cpp: dropped (no-op), the overlay was byte-identical to upstream apart from an annotation comment. - patches/mlx/backend/cuda/quantized/quantized.cpp: rebased, re-applied the ensure_row_contiguous fix for w/scales/biases in QuantizedMatmul::eval_gpu (non-contiguous 3D batched MLA weights, upstream-rejected) onto the new base that now passes std::nullopt global_scale to qmv; the GatherQMM path returns to pristine upstream. - patches/mlx/backend/cuda/jit_module.cpp: rebased, re-applied the /proc/self/exe executable-dir resolution, the MLXCEL_CCCL_DIR override, and the cold-JIT stderr notice onto the new base, adopting upstream's cccl_dir() fallback, the extra bundled include path, the JIT'd qmm/cute_dequant header registration (lablup#3706/lablup#3576), the CUTLASS nvrtc flags, and the get_jit_module(Device&) signature; MLX_PTX_CACHE_DIR handling is unchanged upstream so the persistent PTX cache redirect still takes effect (upstream lablup#3587 turned out to be CI-cache-only, no code conflict). - patches/mlx/backend/cuda/binary/binary.cuh: rebased (adapted), re-applied the mixed-precision bf16/fp32 kernels, trait, and dispatch onto the new base; this also drops stale v0.31.1-era reversions the old overlay was silently carrying (missing __launch_bounds__/BINARY_MAX_BLOCK_DIM) and adopts upstream's large-grid index_rest fix (grid.z) and get_launch_args_general in both the same-type and the mixed general paths. - patches-cuda/ops.cpp: rebased (adapted), re-applied bf16_mixed_astype() and its use in add/subtract/multiply/divide/maximum/minimum onto the new base; this drops stale v0.31.1-era reversions the old overlay was silently carrying (safe_cast overflow checks, the arange zero-step check, use-after-move-prone auto& shape bindings) and picks up upstream's new array-API ops unmodified. - src/lib/mlx-cpp/CMakeLists.txt: pin bump, retargeting the MLX_CCCL_DIR compile definition to the new mlx_dirs OBJECT target (upstream moved the macro consumer into dirs.cpp) with a fallback to the mlx target, and a new MLX_CUTLASS_DIR build-tree fallback because the JIT'd quantized kernels now need CUTLASS/CuTe headers at runtime. - Runtime JIT deployment: upstream lablup#3706/lablup#3576 moved the CUTLASS qmm/gather_gemm instantiations from build-time nvcc to runtime NVRTC (cold build dropped from 30+ min to ~7.5 min on GB10), so quantized models now need cute/ and cutlass/ headers on the deployment host at first run; the jit_module overlay resolves them via MLXCEL_CUTLASS_DIR, the bundled include/ layout, or the compiled-in build-tree path, release archives bundle include/cute + include/cutlass next to include/cccl, and docs/installation.md documents the requirement. - src/lib/mlxcel-core/build.rs: also watch ../mlx-cpp/patches-cuda with rerun-if-changed (it was unwatched, so edits to the CUDA-only dtype/fast/ops overlays did not retrigger the MLX build). - Unchanged overlays (base file identical between the two pins, kept as-is): device/binary_ops.cuh, gemms/grouped_gemm.h, gemms/grouped_gemm_unaligned.cu, matmul.cpp (CUTLASS GatherMM rework intentionally still bypasses upstream's JIT gather_gemm; re-baseline sweep will confirm), reduce/{all,col,init,row}_reduce.cu, reduce/reduce_ops.cuh, metal/compiled.cpp, metal/kernels/utils.h, patches-cuda/{dtype,fast}.cpp. Test-suite reconciliation (cargo test --release --features cuda on GB10): - src/models/sanitize.rs: fix NVFP4 block-scale parsing to be load-dtype-agnostic (astype to F32 before the raw-byte parse). The CUDA loader widens F16 safetensors to F32 at load (from_bytes_f16, CUDA branch since 2026-03), so the previous F16 byte parse read zeros on CUDA; this is a pre-existing CUDA bug exposed by running the suite here, not a pin regression, and it also corrects real gemma4-nvfp4 scale handling on CUDA. f16_to_f32 is now cfg(test) (kept for its format unit tests). - src/models/gemma4_mtp_target_tests.rs: the batched-vs-B=1 bitwise-equality assertion now uses a 2e-3 fp32 tolerance on CUDA (bitwise retained elsewhere). Since MLX lablup#3704 (rope without copy) RoPE preserves input layouts instead of canonicalizing with a copy, so downstream GEMM/SDPA kernels can see different strides for the batched row than for the B=1 replay and pick different reduction orders (observed max_abs 1.6e-4 on fp32 hidden of magnitude ~8). The argmax-equality assertion is unchanged, preserving the functional MTP verify guarantee. - docs/installation.md: document running the CUDA test suite with --test-threads=1. The JIT'd kernels are now compiled and module-loaded on first use, and those first-use paths are not safe against concurrent test threads: the default parallel run aborts with cudaStreamEndCapture capture errors (module load racing another thread's capture) or, with MLX_USE_CUDA_GRAPHS=0, with cuLaunchKernelEx invalid-argument (kernel-configure race). Inference binaries are unaffected. - src/main.rs: add the GLM VLM, Kimi VLM, and PaddleOCR VLM families to FAMILY_ORDER (pre-existing gap on main from the recent VLM ports; family_order_is_exhaustive fails without it and blocks the suite). - src/bin/mlx_server.rs: the legacy-server-mode resolver test fixture now writes a stub model.safetensors next to config.json; the offline completeness gate from PR lablup#604 classifies a config-only directory as an interrupted download and re-fetches from the network, which 404s on the synthetic repo id (pre-existing on main since lablup#604). Tegra note: upstream lablup#3701 gates managed memory on concurrentManagedAccess only; GB10 reports concurrentManagedAccess=1, so managed memory stays enabled on GB10 under both pins and lablup#3701 is a no-op on this platform (details in docs/benchmark_results/mlx-pin-upgrade-2026-07-03.md). * docs(bench): GB10 re-baseline and Phase 3 triage for the MLX pin bump Adds the focused GB10 re-baseline CSV (benchmarks/cuda_gb10_2026-07-03.csv, 19 models covering all Phase-3 outlier families plus dense/MoE/SSM/VLM representatives and a pure-mamba control) and fills the outlier-verdict table in docs/benchmark_results/mlx-pin-upgrade-2026-07-03.md. Verdicts: MoE prefill collapse (lablup#629) is unchanged (our matmul.cpp CUTLASS GatherMM overlay bypasses upstream's now-JIT'd gather_gemm, so lablup#3706 does not reach the path); the hybrid-SSM decode gap (lablup#631) is unchanged (pure-mamba control healthy, isolating the gap to the hybrid path); the gemma-4-31b nvfp4 outlier (lablup#630) is root-caused (the checkpoint is NVIDIA ModelOpt-packed and now correctly rejected; the genuine MLX-native nvfp4 dequant bug was fixed here in sanitize.rs; mxfp4 sibling healthy) and re-scoped to end-to-end validation plus a guard test. No Phase-3 issue is fully fixed by the pin bump, so Phase 3 stands at three issues. Dense decode is uniformly +1 to +3% with several prefill gains and no cross-family regression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An interrupted model download leaves a partial snapshot (config.json plus only some safetensors shards). The resolver reused it after only checking config.json presence, so
mlxcel run <repo-id>(andmlxcel serve/mlxcel-serverauto-download) loaded the partial snapshot and died with a bareWeight not foundinstead of noticing the snapshot was incomplete and re-fetching it. This strengthens the load/resolve gate to verify the full weight set and to resume the download on incompleteness.Root cause
The loader's
collect_shard_pathshas a stale-index tolerance (for repackaged mlx-community quants): when themodel.safetensors.index.jsonreferences shards not on disk but any*.safetensorsexists, it globs the present shards and loads them. For an interrupted download that has only some shards, this loads the partial set and then fails later at the first missing tensor withWeight not found, masking the real cause. The resolver must therefore detect incompleteness itself, and must distinguish an interrupted download from a legitimately repackaged quant.What changed
src/downloader/completeness.rs: an offlineclassify_snapshotgate (Complete/Incomplete { missing }/Absent) that reusesmlxcel_core::weights::parse_shard_indexto derive the expected weight set from the snapshot's own index. A sharded snapshot isIncompleteonly when the on-disk shards are a subset of the index (an interrupted download); a repackaged quant whose stale full-precision index no longer names the on-disk files (there is an unindexed*.safetensors) isCompleteand never re-fetched. A malformed/truncated index defers to the loader glob when weights exist, else re-fetches. A traversal shard name is treated as missing.src/downloader/resolver.rs: the legacy (2a) and mlxcel-store (2c) reuse gates now requireclassify_snapshot(...) == Completeinstead of onlyconfig.jsonpresence, so an interrupted store snapshot is treated as a miss.resolve_repo_idnames the condition ("incomplete download detected at : re-fetching N missing file(s): ...") and resumes through the shareddownload_repo(which skips complete files and re-fetches only what is missing), falling back to a forced clean re-download, then loads. The read-only HuggingFace cache reuse keeps its own config.json gate since mlxcel never writes into that externally-managed layout.src/downloader/mod.rs: register thecompletenessmodule.src/downloader/resolver_tests.rs: make the fixture realistic (a complete snapshot now has a weight file), drop the two weak-gate tests (their intent moved to the classifier), and addlocate_ignores_incomplete_store_dirasserting an interrupted store snapshot is no longer a cache hit.CHANGELOG.md: record the fix under Unreleased.Coverage of
serve/mlxcel-server(relates to #463)Every subcommand (
run,generate,chat,inspect,serve) and themlxcel-serverbinary resolve-mthroughresolve_model_source_with_override, so the single resolver-level gate covers the server auto-download path as well.Test plan
cargo test --lib downloader::completeness(10 new classifier tests: complete/incomplete single-file and sharded, zero-byte shard, stale-index repackaged quant reused, malformed index with/without weights, traversal shard name)cargo test --lib downloader::(122 passed, 0 failed, including the newlocate_ignores_incomplete_store_dirregression)cargo clippy --lib --tests -- -D warnings(clean)cargo fmtandcargo check --bins(clean)Closes #465