Skip to content

fix: read the model card from the pinned snapshot, not main - #43

Merged
darylalim merged 1 commit into
mainfrom
fix/pinned-model-card
Nov 11, 2026
Merged

darylalim merged 1 commit into
mainfrom
fix/pinned-model-card

Conversation

@darylalim

Copy link
Copy Markdown
Owner

Closes the one unpinned Hub read in gdi convert-model, which S2 and S10 recorded as metadata only.

The leak

mlx_vlm.convert.convert(hf_path=<repo id>, revision=<sha>) ends with create_model_card, which calls ModelCard.load(<repo id>). That reads README.md with no revision, so at main, and leaves a README-only 37d591f snapshot and refs/main in the HF cache. Only the card's YAML header was used, and nothing reads the card. Still, it was the build's one unpinned read, and a rebuild's README changed whenever IBM edited theirs.

The fix

mlx-vlm skips the card fetch when hf_path is a local directory (hf_repo = None if Path(hf_path).exists() else hf_path). models._source_snapshot() therefore downloads the pinned source through mlx-vlm's own get_model_path, the same call convert() makes for a repo id, so the same files are fetched. _convert_granite_vision then passes that path to convert(). models.py writes README.md itself, naming the source and its SHA and noting that it is a modified copy of Apache-2.0 weights.

Verification

  • The fetch is gone. Against a scratch HF cache holding only the pinned dd48e97 snapshot, the new code converted and left no refs/main and no new snapshot. The old call, run as a control, created refs/main, the README-only 37d591f snapshot and a 19th blob. (HF_DEBUG=1 does not log the download client's requests, so the cache is the evidence.)
  • Byte-identical artifacts. Rebuilt with gdi convert-model, all 12 weight, config and tokenizer files match the previous conversion, and so does manifest.json. Only README.md differs. S10's own rebuild matches this one.
  • S10 --convert-model: PASS. The control was caught, no repo code ran, and nothing was left unstripped.
  • No eval. Every file a loader reads is byte-identical, so its output would be too. No model, revision or quantization moved.
  • Tests. Three new tests in test_models.py: convert gets the snapshot path, not the repo id; the snapshot is fetched at the pin through get_model_path; and the card is ours. Each was mutation-checked: passing the repo id again, or not writing the card, fails one. GATE_FORCE=1 ./scripts/gate.sh passes.

Docs

A closing note beside S10's record of the leak in pdf-pipeline-spikes.md, and a line in CLAUDE.md's pinning rule (Security, rule 1).

🤖 Generated with Claude Code

Given a repo id, mlx-vlm's convert() writes the model card from
README.md at main, ignoring revision: the one unpinned Hub read in
gdi convert-model (S10). Download the pinned snapshot through mlx-vlm's
own get_model_path, the call convert() makes for a repo id, and pass
convert() its local path: then the card step fetches nothing. models.py
writes the card itself, naming the source and its SHA.

The rebuilt conversion is byte-identical to the previous one apart from
README.md, and so is the manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@darylalim
darylalim merged commit 043d917 into main Nov 11, 2026
2 checks passed
@darylalim
darylalim deleted the fix/pinned-model-card branch November 11, 2026 00:00
@darylalim darylalim mentioned this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant