Repository navigation
fix(load): load quantized-module buffers at their checkpoint dtype (#4458, #4452) - #4495
Merged
Merged
Conversation
…4458, #4452) Accelerate casts every floating buffer to the model dtype. The loader only restored `scales`, the Torch AWQ bias (by QUANT_TYPE name) and the bnb 4-bit state, and enabled the generic restore for EXL3 alone, so a BF16 load rounded QQQ's FP16 `s_group` and FP32 `s_channel` (Llama-3.2-1B QQQ PPL 35.005 in-session vs 35.523 reloaded), ParoQuant `theta`/`channel_scales`, VPTQ `weight_scale`/`weight_bias` and bnb 8-bit `weight_scb`. Kernels now declare their activation-side buffers in `MODEL_DTYPE_BUFFERS` (`("bias",)` on BaseQuantLinear); every other persistent floating buffer of a declaring module is restored from the checkpoint when the load narrowed it. Torch AWQ, MACaQ and EXL3 declare their exceptions, which replaces the `awq_torch` name check and the EXL3-only loader flag. The restore loop walks the model's buffers instead of the checkpoint keys, so a checkpoint tensor without a module (legacy per-layer `rotary_emb.inv_freq`) no longer crashes `save()` with `get_submodule` (#4452). Fixes #4458 Fixes #4452 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium
added a commit
to mikemikimike/GPTQModel
that referenced
this pull request
Nov 16, 2026
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.
This was referenced Nov 17, 2026
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.
TL;DR
s_group/s_channeltheta/channel_scalesweight_scale/weight_biasweight_scbMODEL_DTYPE_BUFFERS, default("bias",)). Every other persistent floating buffer of a quantized module is restored from the checkpoint when the load narrowed it.self_attn.rotary_emb.inv_freq) #4452: the restore loop now walks the model's own buffers instead of the checkpoint keys, so a legacy key with no module no longer crashessave().1. The problem
utils/model.py:3269-3276restoresscalesof anyBaseQuantLinearutils/model.py:3277-3280checksQUANT_TYPE == "awq_torch"to keep the biasmodels/loader.py:3365enables the generic restore only forFORMAT.EXL3utils/model.py:3305-3326loops over checkpoint keys and callsget_submoduleself_attn.rotary_emb.inv_freq(#4452)2. The new flow
flowchart TD A["accelerate.load_checkpoint_in_model"] --> B["_checkpoint_tensor_dtypes (headers)"] B --> C["for each model.named_modules()"] C --> D{"declares MODEL_DTYPE_BUFFERS<br/>or re-save shell?"} D -- "no" --> S["skip"] D -- "yes" --> E["each persistent floating buffer in checkpoint"] E --> G{"re-save shell?"} G -- "yes" --> H{"dtype differs?"} G -- "no" --> I{"declared model-dtype buffer?"} I -- "no" --> J{"_load_narrowed?"} I -- "yes" --> S H -- "yes" --> R["_restore_checkpoint_buffers"] J -- "yes" --> R H -- "no" --> S J -- "no" --> S style R fill:#d1e7dd,stroke:#146c43,stroke-width:2pxCheckpoint keys that have no module are never visited (#4452).
3. Declarations
MODEL_DTYPE_BUFFERSBaseQuantLinear("bias",)AwqTorchLinear()ParoLinear("bias",)MacaqLinear("bias", "BH", "pre_scale")ExllamaV3Linear,ExllamaV3TorchLinear()4. Validation
Llama-3.2-1B-Instruct, 4-bit g128, BF16, 80-window wikitext-2 PPL, RTX 4090:
TheBloke/Llama-2-7B-GPTQload().save(): before,AttributeError: LlamaAttention has no attribute rotary_emb. After, it saves, and the re-saved logits are bitwise equal to the original.5. Tests
tests/test_checkpoint_quant_buffer_dtypes_4458.py, all of which fail on main:test_macaq.py,test_bitsandbytes.pyandtest_checkpoint_modules.py).6. Out of scope
Reference page:
docs/checkpoint-and-runtime-contracts.md§4.Fixes #4458
Fixes #4452
🤖 Generated with Claude Code