Skip to content

[BUG] Features: GPTQ dynamic -: exclusions load as garbage in HF (PPL 690), requantize embeddings + post-quant EoRA crash under default auto_nf12 (repo e2e test fails), EoRA KeyError with dynamic, rotation half-applies then asserts on Qwen2.5, GSQ fp16 loss overflow #4077

Closed

Description

@Qubitium

Audit of main @ ad0525c, RTX 4090. Covers quantization features beyond the defaults: dynamic, embedding/lm_head requantize, post-quant EoRA, rotation and GSQ. Items 2, 3, 5 and 6 were re-verified independently; item 2 is a failing repo test.

1. GPTQ dynamic -: exclusions load as silent garbage in plain HF transformers (medium; follow-up on #4013 item 3 / PR #4034)

For GPTQ, config.json carries no exclusion list (modules_in_block_to_quantize / modules_to_not_convert); the modules_to_not_convert emission (quantization/config.py:~5530) exists only for AWQ. So optimum builds a MarlinLinear with an uninitialised qweight for every excluded module. hf_compat_warnings (models/writer.py:215-244) doesn't warn about this, although its docstring names the same gap for AWQ.

Qwen2.5-0.5B GPTQ 4-bit, dynamic={"-:model\.layers\.0\.self_attn\..*": {}, "-:.*\.layers\.22\.mlp\..*": {}}
GPTQModel.load: PPL ~20.5
AutoModelForCausalLM: layers.0.self_attn.q_proj and layers.22.mlp.down_proj built as MarlinLinear -> PPL 689.8, output " not Is      "

Fix: optimum matches modules_in_block_to_quantize by name.endswith, so write the explicit full names of the quantized modules there. Failing that, add a GPTQ -: warning to hf_compat_warnings. (Mixed-bit dynamic checkpoints fail loudly in HF instead; that's the unwired bridge in #4073.)

2. requantize(embed_quant_mode=INPUT|BOTH) crashes on BF16 checkpoints under the default auto_nf12; the repo's e2e test fails at HEAD (high for this feature)

pytest tests/test_requant_embed_lm_head_e2e.py
FAILED test_requantize_both_save_reload_and_generate
RuntimeError: Lazy forward direct-state materialization left META tensors under ``.

For the input-embedding pseudo-layer, the layer module is the projection. AUTO_NF12 swaps NamedModule.module for an AutoNF12Embedding, but the layer reference passed to _prepare_layer_direct_state_for_forward (looper/stage_subset.py:921 → module_looper.py:1396) still holds the original Embedding, whose weight is META by then. The identity-based exclusion therefore misses it. With auto_dtype_cast off, the run works: INPUT reloads at PPL 20.03, BOTH at 20.74 (19.89 before requantize). OUTPUT mode works either way. Fix: re-resolve the layer module after named-module materialisation, or exclude the NamedModule's original module id.

3. Post-quant EoRA (GPTQModel.adapter.generate) crashes for any BF16 source model under the default auto_nf12 (high for this feature)

looper/dequantize_processor.py:65 uses module.weight.device, but the native source linear has become AutoNF12HookedLinear, which has no .weight:

Llama-3.2-1B-Instruct-gptqmodel-4bit-vortex-v1 + Llama-3.2-1B-Instruct (the pair used in tests/test_post_quant_eora.py)
AttributeError: 'AutoNF12HookedLinear' object has no attribute 'weight'

Qwen2.5 fails the same way. With auto_dtype_cast: "off", EoRA r64 takes PPL from 19.89 to 19.13 (Torch and Marlin). Fix: take the device and shape from the NF12 module or the dequantized source, or disable AUTO_NF12 for the EoRA generation pass.

4. Post-quant EoRA crashes on checkpoints with dynamic -: exclusions (medium)

DequantizeProcessor is created with qcfg=None, so the checkpoint's -: rules aren't applied to it. looper/dequantize_processor.py:69 self.quantized_modules.pop(module.full_name) then raises KeyError: 'model.layers.0.self_attn.q_proj' for an excluded module. This was run with auto_nf12 off, so it's independent of item 3. Fix: skip modules missing from quantized_modules, or pass the quantize config so dynamic exclusions apply.

5. Rotation crashes with a bare AssertionError on Qwen2.5 (MLP width 4864 = 2⁸·19) after the model is already half-rotated (medium)

base.py:2033 validates only the model class. rotate_mlp_output → apply_exact_had_to_linear → hadamard_utils.py:67 assert is_pow2(n) fires only after embeddings, head, norms and attention have been rotated and fused in place:

Qwen2.5-0.5B-Instruct, {"bits":4,"group_size":128,"rotation":"hadamard"} -> AssertionError   (rotation="random" identical)

Qwen2.5-1.5B (8960) and 7B (18944) hit the same assert, by arithmetic. Llama-3.2-1B hadamard works (PPL 19.51 on AUTO/Torch/Triton). Fix: check get_hadK compatibility of intermediate_size (and hidden_size) before fuse_layer_norms, and raise a clear ValueError.

6. Staged GSQ training aborts on fp16 Llama with an unrecoverable device-side assert (medium)

The stage losses (quantization/gsq_training.py:345, 385, reconstruction_cached_llama_mlp_loss) use F.mse_loss in the model dtype. Llama's large BOS residual overflows the squared error in fp16, and torch._assert_async(..., 'GSQ stage objective or gradient is nonfinite') (:541) poisons the CUDA context:

fp16 Llama-3.2-1B, epochs=1, qk_steps=20, 32 docs -> block 1 MLP stage: CUDA error: device-side assert triggered
bf16 same run -> all 16 blocks complete (58 s), PPL 89.74 vs matching GPTQ_V2 control 89.09
mse_loss of fp16 tensors differing by 300 in one element -> inf  (bf16 11.0, fp32 10.99)

test_gsq_staged_public parametrizes float16. Fix: compute stage losses in fp32 (mse_loss(student.float(), teacher.float())).

Checked, correct

Plausible, not verified

  • RCO budget_constrained_argmax at resolution 500 can overspend the target bpp by up to +0.017 (2.375 target, 112 groups), and nothing fails.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions