Repository navigation
fix: read the model card from the pinned snapshot, not main - #43
Merged
Merged
Conversation
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>
Merged
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.
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 withcreate_model_card, which callsModelCard.load(<repo id>). That readsREADME.mdwith no revision, so atmain, and leaves a README-only37d591fsnapshot andrefs/mainin 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_pathis 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 ownget_model_path, the same callconvert()makes for a repo id, so the same files are fetched._convert_granite_visionthen passes that path toconvert().models.pywritesREADME.mditself, naming the source and its SHA and noting that it is a modified copy of Apache-2.0 weights.Verification
dd48e97snapshot, the new code converted and left norefs/mainand no new snapshot. The old call, run as a control, createdrefs/main, the README-only37d591fsnapshot and a 19th blob. (HF_DEBUG=1does not log the download client's requests, so the cache is the evidence.)gdi convert-model, all 12 weight, config and tokenizer files match the previous conversion, and so doesmanifest.json. OnlyREADME.mddiffers. S10's own rebuild matches this one.--convert-model: PASS. The control was caught, no repo code ran, and nothing was left unstripped.test_models.py: convert gets the snapshot path, not the repo id; the snapshot is fetched at the pin throughget_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.shpasses.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