Repository navigation
fix(load): require every kernel's checkpoint payload (#5218) - #5239
Merged
Merged
Conversation
Qubitium
marked this pull request as ready for review
November 18, 2026 13:09
This was referenced Nov 18, 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.
Fixes #5218.
fix(load): require every kernel's complete checkpoint payload (#5218)
Root cause (one line)
validate_checkpoint_qweightsonly enforced the suffixes a kernel declared, andonly
qweight(GPTQ/AWQ family) and QQQ'sB/s_group/s_channelweredeclared, so a checkpoint truncated at
scales/qzeros/g_idxor at anyFP8/NF12/GGUF/Paro/VPTQ/BnB/MACaQ/EXL3 tensor loaded into the module's
torch.empty/zero placeholder and produced NaN, wrong logits, a CUDA illegalmemory access, or a device-mismatch error.
Fixes #5218. Follow-up to #5032 / #5010.
Before / after
flowchart TD A[GPTQModel.load] --> B[validate_checkpoint_qweights] B --> C{module declares<br/>CHECKPOINT_REQUIRED_BUFFERS?} C -- "GPTQ/AWQ: qweight only<br/>QQQ: B/s_group/s_channel" --> D{checkpoint has suffix?} D -- yes --> E[load] D -- no --> F[ValueError] C -- "FP8/NF12/GGUF/Paro/VPTQ/<br/>BnB/MACaQ/EXL3: nothing declared" --> G[no check] G --> H[torch.empty / zero placeholder] H --> I[NaN · wrong logits ·<br/>illegal memory access ·<br/>device mismatch]flowchart TD A[GPTQModel.load] --> B[validate_checkpoint_qweights] B --> C["instance hook checkpoint_required_buffers()<br/>else CHECKPOINT_REQUIRED_BUFFERS"] C --> D["resolve dotted suffix on the live module<br/>_checkpoint_suffix_tensor"] D -- "live tensor absent (conditional payload)" --> E[skip: nothing to restore] D -- "live tensor present" --> F{optional-empty and numel==0?} F -- yes --> E F -- no --> G{checkpoint has<br/>module.suffix or alias?} G -- yes --> H[load] G -- no --> I["ValueError: Missing required quantized weights ...: module.suffix"]What changed
gptqmodel/utils/model.py_checkpoint_suffix_tensor(module, suffix)resolves a dotted suffix(e.g. VPTQ
centroids.weight) through_modules/attributes and returnsNonewhen this instance does not own the tensor.validate_checkpoint_qweightsasks the instance hookcheckpoint_required_buffers()first (falling back to the class tuple) andis now presence-aware: a suffix the live module does not own is skipped.
This is what lets one union declaration cover conditionally allocated
payloads (AllSpark has no
qzeros; plain MXFP4 MACaQ has noBH/pre_scale;VPTQ without residuals has no
res_centroids; BnB 4/8-bit differ; EXL3packed vs unpacked signs and
mcgvsmul1).CHECKPOINT_OPTIONAL_EMPTY_BUFFERSkeeps its meaning: an empty live bufferis not required (QQQ per-channel
s_group, symmetric BitBLASqzeros).Missing required quantized weights in checkpoint '<path>': <keys>.gptqmodel/nn_modules/qlinear/__init__.pyPackedGroupedQuantLinear:("qweight", "scales", "qzeros").BaseQuantLinear.checkpoint_required_buffers()is the class-tuple default;GPTQQuantLinearappendsg_idxwhendesc_actis set.qweight,scales,qzeros+ emptyqzeros), TT blockfloat linear/embedding (codes,exponents), FP8(
weight,weight_scale_inv), NF12 (nf12_packed,nf12_escapes,nf12_exp_base), GGUF (qweight), BnB (weight+ quant-state/absmax/map/scb),Paro (
qweight,qzeros,scales,theta,pairs,channel_scales), VPTQ(
indices+ codebooks/scales/perm), MACaQ (W_packed,W_scales,BH,pre_scale), EXL3 (trellis+ sign vectors + codebook).qzeros(no such buffer),qzeros_format(not serialized),g_idxwhendesc_act=False(derived),code_shape(derived),AutoNF12Embeddingbuffers (calibration scratch; thewriter saves the dense
weight).Evidence
Issue-reported symptom (2-layer Qwen2.5-0.5B, delete one tensor of
model.layers.0.self_attn.q_proj) and the new behavior. "refused" means thefail-closed
ValueErrornaming the missing tensor; the new matrix reproduceseach deletion at the loader boundary.
qweightscalesqzerosdesc_act=Trueg_idxscalesqzerosqzeros/scalesweight_scale_invweightnf12_packed/nf12_exp_basenf12_escapesescape index 0 out of rangeqweight(only tensor)scales/theta/pairs/channel_scalescentroids.weight/res_centroids.weightweightCUDA illegal memory accessweight_absmax/weight_quant_map/weight_quant_stateBH/W_packed/W_scales/pre_scaletrellis/suh/svh/mcgValueError(not fail-closed)qzeros/scalesAWQ GEMMV2 expects all tensors on CUDAB/s_group/s_channelRegression matrix
New
tests/test_fail_closed_checkpoint_5218.pybuilds each real kernel,publishes
state_dict()as safetensors, and deletes one tensor at a time:21 cases (GPTQ, GPTQ
desc_act, AWQ, FP8, NF12, GGUF, BnB 4/8-bit, Paro, VPTQplain/full, MACaQ default/plain, QQQ grouped/per-channel, TT blockfloat, EXL3
mcg/mul1/packed, AllSpark, BitBLAS). It asserts the intact checkpointpasses, the declared set covers every published tensor, every required tensor
fails closed and is named, and optional/derived tensors do not. Two
end-to-end cases (FP8, NF12) quantize → save → reload → forward, then truncate
and assert the fail-closed error.
Verification
Not verified: bitblas (not installed); native GGUF/VPTQ/EXL3 CUDA kernels and
the BnB CUDA forward path (loader-level matrix uses the Torch implementations);
Marlin/AWQ-Marlin/Machete/Swordfish/ExLlamaV2/MLX inherit the family
declaration but were not separately constructed in the new matrix.