Repository navigation
Description
Depends on #2446 (for #2445), which moves optiq_vision_sidecar_path into mlxcel_core::weights (src/lib/mlxcel-core/src/weights.rs:664 on that branch). Do all three items in one PR, run the verification once at the end, and push as few times as possible.
OptiQ checkpoints list optiq/optiq_vision.safetensors in weight_map and declare it in config.json optiq_vision.sidecar. #2446 stops the loader treating it as a bad shard. Three other places still do.
Shared helper. Split the config read out of without_declared_optiq_sidecar (branch weights.rs:700-717) into pub fn declared_optiq_vision_sidecar(dir: &Path) -> Option<PathBuf>: Infinity/NaN sanitized, optiq_vision_sidecar_path (relative .safetensors, no traversal), subdirectory paths only. All three sites call it. Do not copy the validation.
1. Snapshot classified incomplete
missing_indexed_shards (src/downloader/completeness.rs:130-144) sends the entry to shard_present (:151), which rejects any /. model.safetensors is indexed, so has_unindexed is false and the snapshot is Incomplete. resolver.rs:392-405 then calls report_incomplete_snapshot and download_repo.
- A declared sidecar counts as present when
dir.join(sidecar)is non-empty. If it is absent, it is reported missing under its relative name. Undeclared subdirectory entries still count as missing. - Test in
completeness.rstests (write_indexhelper): sidecar present givesComplete, absent givesIncomplete.
2. WebUI catalog: "unsafe shard path"
indexed_completeness (src/server/webui/catalog_fs.rs:85-91) and push_index_shard_facts (:333-337) reject any multi-component name.
- Skip that check for the declared sidecar only, and let item 1 decide whether it is present. Traversal and undeclared paths are still rejected.
- Test in
catalog_fs_tests.rs: an OptiQ layout getsok: true.
3. Preflight leaves out the sidecar
weight_footprint_bytes (weights.rs:246-273) fails validate_index_shards on this entry and falls back to the model.safetensors header. metadata.total_size also leaves the sidecar out.
- Drop the sidecar before validation. When the sidecar file exists, add its
read_safetensors_header_bytes. - Test in
weights.rstests: the result equals main header plus sidecar header.
Real checkpoint
~/models_archive/mlx/lfm2.5-vl-3b-optiq-4bit: classify_snapshot is Complete, and the WebUI catalog lists it with no unsafe-path reason. mlxcel inspect -m currently prints Weights: 1.82 GiB (1958475776 bytes). After the fix it must print 2811046368 bytes (sidecar 852570592).
Verification
cargo test --profile test-fast --features cuda --lib -- downloader::completeness webui::catalog --test-threads=1
cargo test --profile test-fast -p mlxcel-core --features cuda --lib -- weights:: --test-threads=1
cargo clippy --profile test-fast --features cuda --lib --tests -- -D warnings
cargo fmt --all -- --checkEach new test must fail with its fix reverted.
Activity
fix: close loader and LoRA follow-ups from #2438 and #2439 (#2446)
fix: bound the sidecar config read and stop trusting total_size
fix: accept the declared OptiQ vision sidecar outside the loader
fix: bound the sidecar config read and stop trusting total_size
fix: treat the declared OptiQ vision sidecar as a shard outside the l…