Skip to content

Fix loading sharded GGUF checkpoints - #50653

Open
not-heavychevy wants to merge 1 commit into
huggingface:mainfrom
not-heavychevy:reference/gguf-shards-32266
Open

not-heavychevy wants to merge 1 commit into
huggingface:mainfrom
not-heavychevy:reference/gguf-shards-32266

Conversation

@not-heavychevy

@not-heavychevy not-heavychevy commented Nov 12, 2026 •

Copy link
Copy Markdown

🤗 Transformers CI

What does this PR do?

Fixes #32266.

Passing the first shard as gguf_file currently loads only that file. Weights stored in later shards can be reported missing and reinitialized. Configuration inference can also miss output.weight and incorrectly tie the embeddings.

This change resolves and validates the full shard set from the first filename. Configuration inference uses metadata from the first shard and tensor names from all shards. Both the legacy loader and the GGUF quantizer load weights from the complete set, using each file's own tensor offsets. Tokenizer loading can still read metadata from the first shard alone.

Validation

  • Added offline regressions for Llama F32 and LFM2 with a Q8_0 weight in the second shard. Both fail on a6f5c8676b and pass with the fix. They check configuration, missing and unexpected keys, and exact parameter and logit equality against single-file controls.
  • CPU checks passed with gguf==0.10.0 and gguf==0.19.0. Each run passed the two regressions and GgufDequantizeTest (3 tests and 17 subtests).
  • All 16 CUDA cases passed on an RTX 3080 Ti with dequantization enabled.
  • Two published Hub checkpoints, with two and three shards, loaded from an empty cache and matched their single-file controls. Offline reloads made zero HTTP requests. Split and single-file loads used the same pad_token_id=None override for these fixtures.
  • fix-repo passed 18/18 checks. The CI quality and repository consistency profiles passed 7/7 and 20/20 checks, respectively, after targeted reruns. The combined check with Torch reports a ty warning for torch.distributed.get_rank that also reproduces on clean main.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — waiting for maintainer approval

CI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: ggml

This branch has not been deployed

No deployments
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.

Support loading shard GGUF models

1 participant