Skip to content

fix(config): reject model-wide rotation on non-GPTQ formats (#4666) - #4701

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4666-rotation-gate
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4666-rotation-gate

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Root cause

rotation is a base-class field, so every config accepted it: AWQ, FP8, QQQ, VPTQ, Paro, EXL3, BitsAndBytes, GGUF, NF12 and RTNConfig(format="gemm"). But:

  • from_quantized only 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 mapped BACKEND.AUTO to GPTQ_TORCH regardless 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: new ROTATION_SUPPORTED_FORMATS (FORMAT.GPTQ, FORMAT.GPTQ_V2) and validate_rotation_format(), which rejects the option with the config name, the resolved format and both supported layouts. It runs in BaseQuantizeConfig.__post_init__ and in EXL3Config.__post_init__ (which does not call the base hook).
  • MACaQ is unaffected: MacaqConfig.model_rotation is None because rotation is its own per-layer transform.
  • gptqmodel/models/base.py: quantize() runs the format check first and the rotation backend check moved up with it, so fuse_layer_norms/rotate_model never run for a refused config. AUTO still resolves to GPTQ_TORCH for the accepted GPTQ layouts.
  • docs/rotation-model-support.md: the flow chart now starts with the format gate, plus a "Checkpoint-format gate" section.
  • CI: the regression file is added to the AWQ CPU unit suite (that workflow triggers on gptqmodel/quantization/** and gptqmodel/models/**).

Tests

New tests/test_rotation_format_gate_4666.py (36 tests):

  • every non-GPTQ config rejects rotation="hadamard" and "random" at construction, with the supported layouts in the message;
  • rotation=None is accepted everywhere, and GPTQ / GPTQ_V2 / RTN (GPTQ layout) / QuantizeConfig still accept it;
  • MACaQ keeps its per-layer rotation;
  • quantize() with a rotation-injected AWQ config (simulating a deserialized payload) raises before fuse_layer_norms/rotate_model (monkeypatched to fail if called) and every model parameter is bitwise unchanged.

On unmodified main 21 of the 36 fail (the configs accept the option, and the quantize test reaches rotate_model); with the fix all 36 pass.

tests/test_rotation_format_gate_4666.py tests/qcfg tests/test_rotation_persistence.py
tests/test_rotation_opt_in.py tests/test_config_serialization_roundtrip_4201.py
-> 227 passed, 4 skipped

AWQ CPU unit suite (all listed files) -> 907 passed, 71 skipped
  9 failures are pre-existing on unmodified main in this environment
  (afmoe/flint/granite/bailing_moe fixtures)
tests/test_macaq.py -> 4 pre-existing CUDA-kernel failures on this CPU host

Closes #4666.

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant