Repository navigation
Description
Regression and completeness review of the quantization-side fix PRs (#4069, #4071, #4080, #4081, #4084, #4086) on main @ a15e6bf, RTX 4090. A/B checks compare against ad0525c, the base before all of these PRs.
1. hf_repack_layer makes every GPTQ v1 zero point one step low (in-memory and loaded models) (high for integrators, silent)
utils/packing.py:797-824 (_copy_packed_state) does the following:
- Copies
source.state_dict(). Since fix(models): honor third-party checkpoint filters and layouts (#4053) #4061 that state_dict holds v1 checkpoint-layout qzeros (checkpoint_layout_qzeros). Since fix(looper,gptq): restore EXL3 AUTO_NF12 and the in-memory v2 qzero layout (#4063) #4069, freshly packed modules also carry_checkpoint_format_on_disk=GPTQ, so everyquantize()d module is affected too. - Calls
target.qzero_format(format=source.qzero_format()), i.e. 2, which relabels the v1 words as v2. - Then
_align_qzero_format(:877) sees 2 == 2 and converts nothing.
Qwen2.5-0.5B-Instruct-gptq-4bit loaded with GPTQ_TORCH, down_proj repacked:
-> TritonV2Linear rel_err 0.30 -> MarlinLinear rel_err 0.0 (Marlin ignores qzeros for sym)
Llama-3.2-1B RTN4 sym, offload_to_disk=False, in-memory TorchLinear -> TritonV2Linear: rel_err 0.44-0.61; target zeros == source - 1
On ad0525c, the loaded-checkpoint case was already broken (#4061). The in-memory case happened to work only because the source was itself wrong (#4063). At HEAD both are broken. tests/test_hf_packing_api.py::test_hf_repack_layer_between_compatible_kernels only uses GPTQ_V2, so no conversion happens.
Fix: copy the raw named_buffers() instead of state_dict(), or set target._checkpoint_format_on_disk = source._checkpoint_format_on_disk before load_state_dict (so _load_from_state_dict converts) and drop the relabel.
2. hf_pack_layer(checkpoint_format="gptq", post_init=True) / hf_post_init restore v2 words without setting the checkpoint marker, so state_dict() / save_pretrained write v2 words labelled gptq (medium; a sibling path #4069 missed)
#4069 moved pack_module to "keep live v2 + mark _checkpoint_format_on_disk=GPTQ, convert a copy on serialize". hf_pack_layer (utils/packing.py:675-715) still converts the live buffer to v1. Then post_init / _restore_gptq_runtime_qzeros (:248) converts it back to v2 without setting the marker, so the serialization conversion never runs:
post_init=False: state_dict qzero fields [7,6,7,6] (correct v1)
post_init=True: qzero_format=2, ckpt_marker=None, state_dict fields [8,7,8,7] (v2 under a v1 label)
-> reload as v1 checkpoint: rel_err 0.269
The documented HF lifecycle in docs/hf_packing_api.md (pack → post_init → save_pretrained) therefore produces checkpoints whose zero points are one step high on reload. The behaviour is the same on ad0525c. Fix: have hf_pack_layer mirror pack_module (keep v2 and set the marker), or set _checkpoint_format_on_disk = FORMAT.GPTQ wherever the v1 words are restored to v2.
3. #4084's AWQ group retune is incomplete: Phi-tiny-MoE (the model from #4073 item 3) still crashes under default AWQ (medium)
_ensure_group_size_divisibility / _largest_supported_group_divisor (looper/awq_processor.py:513-600) only check in_features % group_size. They do retune the 512 expert down_proj modules from 128 to 64. But AwqGEMMLinear._validate (qlinear/gemm_awq.py:209-229) also requires out_features % group_size == 0, and the expert gate_proj/up_proj have out_features = 448:
AWQConfig(bits=4, group_size=128), Phi-tiny-MoE-instruct bf16:
NotImplementedError: AWQ GEMM requires a group size divisible by 32 and out_features divisible by that group size: got out_features=448, group_size=128
(awq_processor.py:3469 pack_module -> utils/model.py:806 create_quant_module)
Fix: check each candidate group size against the kernel's full validate(in_features, out_features, group_size) (64 works here). Add an out_features=448 case to tests/test_awq_dynamic_group_size.py.
Plausible, not verified end to end
- fix(awq,qqq,paroquant): gauge offset-gain folds and fix QQQ/ParoQuant load paths (#4074) #4081, offset-gain renormalization
s/max(s)in fp16:(1+w)/s'can grow to ≈R·(1+w), where R is the scale range. In a unit test, an fp16 Gemma3RMSNorm with R=1e6 gives 226 inf gains and all-NaN output (bf16 and LlamaRMSNorm are fine). Real Gemma-3-1B in fp16 doesn't hit it: AWQ 43.17 vs RTN 51.08. - fix(awq): aggregate variable-length calibration for every module (#4063) #4071,
token_rowsfor attention: the q/k/v scale search replaysself_attnon[1, 638, H]rows drawn from 16 different documents, withattention_mask=None. The result is a causal mask across documents with synthetic positions, so the objective is semantically off. PPL shows no loss (AWQ beats RTN everywhere), but thebatch_size>1crash in [BUG] Follow-up on #4071/#4082/#4083/#4085: AWQ batch_size>1 crash (regression), CPU AUTO kernels corrupt state_dict (inf/NaN), v1<->v2 state_dict copy, PEFT on Marlin, HF random weights for exl3/gguf, MLX batched generate #4091 comes from the same path, and a mask-aware replay would fix both. - After
requantize(): the quantizedTorchQuantEmbeddingsstays on CPU while the model is oncuda:0, so an in-process forward raises a device mismatch. Save and reload are fine.
Checked, no defect found
-
fix(looper,gptq): restore EXL3 AUTO_NF12 and the in-memory v2 qzero layout (#4063) #4069: in-memory and reloaded models agree (PPL within 0.015, top-1 agreement 1.0) for RTN4 asym and GPTQ4 asym (gptq and gptq_v2 formats), and for Qwen GPTQ4 sym. Re-save does no double conversion.
requantizekeeps untouched qzeros byte-identical. No VRAM increase (1.413 vs 1.421 GB). -
fix(awq): aggregate variable-length calibration for every module (#4063) #4071: AWQ beats RTN in all six cells (wikitext PPL, AWQ / RTN):
Model sym asym Qwen2.5-0.5B 24.61 / 24.81 22.47 / 22.73 Llama-3.2-1B 22.08 / 24.49 21.29 / 23.58 gemma-3-1b 44.19 / 48.01 45.01 / 51.07 OLMoE AWQ gives 11.56.
-
fix(gptaq,foem,gguf): unblock MoE experts and warn on K-quant aliases (#4067) #4080: OLMoE PPL is GPTQ 11.527, GPTAQ 11.538, FOEM 11.566 (base 10.91). Routed experts use dXXᵀ=0 as documented.
-
fix(awq,qqq,paroquant): gauge offset-gain folds and fix QQQ/ParoQuant load paths (#4074) #4081: QQQ bf16 works in memory.
-
fix(hf): run native MoE bridge, remap legacy VL keys, retune AWQ groups (#4073) #4084: the HF bridge on OLMoE-GPTQ-dynamic matches
GPTQModel.load(11.526). VL save/reload is unchanged for Qwen2-VL, Qwen2.5-VL, Qwen3-VL, InternVL3, LFM2.5-VL and gemma-3-4b. -
fix(features): honor GPTQ dynamic exclusions and repair AUTO_NF12/EoRA/rotation/GSQ (#4077) #4086:
-:exclusions match between GPTQModel and HF (22.23 vs 22.24). Post-quant EoRA under auto_nf12 with exclusions works (22.23 → 19.56).
🤖 Generated with Claude Code
Activity
fix(awq): validate group size against the packing kernel (#4095) (#4104)
fix(packing): repair hf_repack_layer and hf_pack_layer GPTQ v1 qzero …
fix(checkpoint): make state_dict() a real checkpoint for every kernel (…
Qubitium commentedon Nov 15, 2026
All three items are now on
main:hf_repack_layerzero points off by one for GPTQ v1, andhf_pack_layer(post_init=True)saving v2 words under agptqlabel —c73793cea, PR fix(packing): repair hf_repack_layer and hf_pack_layer GPTQ v1 qzero format alignment (#4095) #4096.out_features % group_size—1a3943ed3, PR fix(awq): validate group size against the packing kernel (#4095) #4104.Verification worth recording, because the first item was the subtle one:
_restore_gptq_runtime_qzeros()only reaches its newFORMAT.GPTQassignment when the live words are v1 (qzero_format() != 1returns early), so a v2-on-disk layer is never mislabelled. Probed across inline/splitpost_initand repack from v1 and v2 sources — all five paths agree betweenstate_dict()words and live words._copy_packed_statenow copiesnamed_parameters()/named_buffers()instead ofstate_dict(), which is a strict superset and avoids the v1 checkpoint conversion entirely.For item 3,
_kernel_group_size_supportednow asks the resolved kernel's ownvalidate(in_features, out_features, group_size), and-1is used only when per-channel itself validates — otherwise the configured size is left alone, so the non-quantizedrouter:!is not rewritten. End-to-end Phi-tiny-MoE (bf16, AWQ g128): 1664 modules packed, 448×4096 and 4096×448 both retuned to g64, attention projections kept g128.Both fixes are covered by regression tests that fail on the parent commit, on CUDA and ROCm.
Closing as resolved.