Repository navigation
fix(writer): skip removed checkpoint modules - #4494
Merged
Merged
Conversation
Collaborator
|
@mikemikimike Please resolve merge conflict. |
The dtype-restore loop now iterates live model buffers (ModelCloud#4495), so a checkpoint-only module path is never looked up and the local try/except is obsolete. Keep the regression test that pins the contract.
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
… (#4509) * fix(loader): keep packed fp8 weights out of the accelerate cast (#4387) Accelerate casts every floating checkpoint tensor to the requested model dtype. For an FP8 checkpoint that materialized each packed `weight` as FP16/BF16 on the target device, and staged the whole shard there, until the loader re-read the FP8 bytes; the load peak was ~2.1x resident. Write a temporary safetensors checkpoint without the packed weights, let Accelerate load only the dense tensors, and restore the packed bytes from the source checkpoint on the `device_map` target. Key-converted checkpoints use a runtime-to-source name map for the restore. Pickle and non-safetensors checkpoints keep the previous path. Measured on a GPTQModel FP8 export of SmolLM2-135M (210 packed E4M3 weights): BF16 peak allocated 376 MB -> 164 MB (= resident), host VmHWM 2.44 GB -> 2.13 GB; the state-dict SHA-256 and a fixed forward pass are identical. A two-shard copy measured 296 MB -> 164 MB. * fixup(#4387): keep the tie-weights stub compatible and refresh doc line refs `_tie_weights_after_checkpoint_load` gained a keyword-only `extra_keys` argument so the packed FP8 names the loader restores itself are not reported as missing. The stub in the #4494 test only accepted positional arguments and failed on the new keyword; accept keywords like the stub in `test_checkpoint_scale_dtype.py` already does. No assertion changes. Also point the checkpoint-load row in the FP8 lifecycle doc at the current `accelerate.load_checkpoint_in_model` and `_restore_checkpoint_buffers` call sites (`:3478`, `:3540`); the old `:3422`/`:3461` refs drifted during the branch work.
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.
Summary
Fixes the checkpoint re-save regression reported in Issue #4452.
Resolves #4452
Older quantized checkpoints can contain buffers for modules removed from the current Transformers model implementation, such as legacy Llama rotary embedding buffers. During dtype preservation, the loader now skips those absent module paths because those tensors are already ignored by model loading, while continuing to restore matching current buffers.
flowchart TD A["checkpoint dtype map"] --> B["resolve module path"] B --> C{"module exists in current model?"} C -- "no" --> D["skip legacy checkpoint tensor"] C -- "yes" --> E["compare and restore buffer dtype"] D --> F["continue load and re-save"] E --> F style C fill:#ffe0b2,stroke:#e65100 style F fill:#c8e6c9,stroke:#2e7d32Before,
get_submodule()raisedAttributeErrorfor a checkpoint-only module and prevented saving. After, missing legacy paths are ignored without changing restoration of existing buffers or other shape/type errors.Failure contract
Only an absent module path is skipped. Existing module slots still undergo the same floating-point dtype and shape checks, and checkpoint read or restoration failures remain errors.
Validation
pytest -q tests/test_resave_missing_modules_4452.py(1 passed)python -m py_compile gptqmodel/utils/model.py tests/test_resave_missing_modules_4452.pypassedgit diff --checkpassed