Repository navigation
fix(config): reject model-wide rotation on non-GPTQ formats (#4666) - #4701
Merged
Merged
Conversation
`rotation` is a base-class field, so AWQ/FP8/QQQ/VPTQ/Paro/EXL3/BnB/GGUF/ NF12 and RTN(format="gemm") all accepted it. Only the GPTQ kernels apply the online Hadamard a rotated checkpoint needs, and the loader already refused a rotated checkpoint whose format is not GPTQ/GPTQ_V2. A non-GPTQ run therefore quantized a rotated model with kernels that ignored the transform (FP8 nll 21.05 -> 30.20, AWQ 21.59 -> 30.68) and saved a checkpoint that could not be reloaded. - New `validate_rotation_format()` rejects the option in `BaseQuantizeConfig.__post_init__` (and in `EXL3Config.__post_init__`, which does not call the base hook), naming the config, the resolved format and the two supported layouts. MACaQ is unaffected: its `model_rotation` is None because `rotation` is its own per-layer transform. - `quantize()` runs the same check first and moves the rotation backend check up with it, before `fuse_layer_norms`/`rotate_model`, so a refused run leaves the model exactly as loaded. Issue #4666.
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.
Root cause
rotationis a base-class field, so every config accepted it: AWQ, FP8, QQQ, VPTQ, Paro, EXL3, BitsAndBytes, GGUF, NF12 andRTNConfig(format="gemm"). But:from_quantizedonly accepts a rotated checkpoint whose format is GPTQ/GPTQ_V2, and only the GPTQ kernels apply the online Hadamard;quantize()fused the norms and rotated the weights before its backend check, and that check mappedBACKEND.AUTOtoGPTQ_TORCHregardless of method, so a non-GPTQ config passed it.A non-GPTQ run therefore quantized a rotated model with kernels that ignore the transform (FP8 nll 21.05 -> 30.20, AWQ 21.59 -> 30.68) and saved a checkpoint that could not be reloaded. With an explicit backend the run raised only after the weights had already been rotated and the norms fused in place.
Changes
gptqmodel/quantization/config.py: newROTATION_SUPPORTED_FORMATS(FORMAT.GPTQ,FORMAT.GPTQ_V2) andvalidate_rotation_format(), which rejects the option with the config name, the resolved format and both supported layouts. It runs inBaseQuantizeConfig.__post_init__and inEXL3Config.__post_init__(which does not call the base hook).MacaqConfig.model_rotationisNonebecauserotationis its own per-layer transform.gptqmodel/models/base.py:quantize()runs the format check first and the rotation backend check moved up with it, sofuse_layer_norms/rotate_modelnever run for a refused config.AUTOstill resolves toGPTQ_TORCHfor the accepted GPTQ layouts.docs/rotation-model-support.md: the flow chart now starts with the format gate, plus a "Checkpoint-format gate" section.unitsuite (that workflow triggers ongptqmodel/quantization/**andgptqmodel/models/**).Tests
New
tests/test_rotation_format_gate_4666.py(36 tests):rotation="hadamard"and"random"at construction, with the supported layouts in the message;rotation=Noneis accepted everywhere, and GPTQ / GPTQ_V2 / RTN (GPTQ layout) /QuantizeConfigstill accept it;quantize()with a rotation-injected AWQ config (simulating a deserialized payload) raises beforefuse_layer_norms/rotate_model(monkeypatched to fail if called) and every model parameter is bitwise unchanged.On unmodified
main21 of the 36 fail (the configs accept the option, and the quantize test reachesrotate_model); with the fix all 36 pass.Closes #4666.