Skip to content

fix: Treat the declared OptiQ vision sidecar as a shard outside the loader #2451

Closed

Description

@inureyes

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.rs tests (write_index helper): sidecar present gives Complete, absent gives Incomplete.

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 gets ok: 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.rs tests: 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 -- --check

Each new test must fail with its fix reverted.

Activity

  1. added
    type:bugBug fixes, error corrections, or issue resolutions
    area:modelsModel architectures, weights, loading, metadata
    on Oct 19, 2026
  2. added 2 commits that reference this issue on Oct 19, 2026
    1440ad5
    205cb11
  3. added a commit that references this issue on Oct 21, 2026
    c40e2d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:modelsModel architectures, weights, loading, metadatapriority:mediumMedium prioritystatus:doneCompletedtype:bugBug fixes, error corrections, or issue resolutions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions