Repository navigation
Description
Follow-up review of the merged fixes for #3973, #3975 and #3974, at main @ 105602e. Each PR's own tests pass (test_awq_scale_folding.py 13/13, test_adapter_scaling.py + test_eora_merge.py 8/8, the AWQ subset of the kernel/dequant tests 16 passed). The problems below are in cases those tests don't cover.
#3989 (AWQ scale folding)
1. Regression: LFM3's FFN/conv scales are folded into the sandwich post-norms (high)
gptqmodel/models/base.py:4407 (_select_prev_op, used at :4555) now picks the last matching-width gain norm in a non-quantized run. That assumes tree order equals forward order.
LFM3's tree lists operator_norm, post_operator_norm before conv, and ffn_norm, post_ffn_norm before feed_forward. In the model, post_*_norm is applied to the block output (use_sandwich_norm: true; modeling_lfm3.py 489-495).
The real LFM3QModel.awq_get_modules_for_scaling on a layer mirroring Lfm3DecoderLayer gives:
prev_op: post_operator_norm -> layers: ['conv.in_proj']
prev_op: post_ffn_norm -> layers: ['feed_forward.w1', 'feed_forward.w3']
relative layer-output change after fold: 0.688
old rule (operator_norm/ffn_norm) relative change: 1.25e-07
- Every AWQ quant of LFM3 / LFM3-VL / LFM3-Omni is silently corrupted.
- The scale search still scores
ffn_norm, so the search and the fold are inconsistent again. - K2-Horizon has the same latent shape:
[input_layernorm, q_norm, k_norm] -> q_proj, where q_norm width == hidden. It would trigger withquery_key_norm=true; no published config sets that today.
Fix: select by data flow, not tree position. Either check during capture that the candidate norm's output is the consumer's input, or add a definition-level flag that marks sandwich post-norms as non-sources. Add LFM3 to tests/test_awq_scale_folding.py.
(The ~220 HF *Norm classes swept for offset detection were all correct, and so were the other ~75 consecutive non-quantized runs under definitions/, including Ouro, which this PR fixed.)
2. The source-text fallback for offset detection can report a false positive (low, latent)
gptqmodel/quantization/awq/quantize/scale.py:62-84, 97: when the live probe is ambiguous, _source_gain_offset greps for 1.0+self.weight and folds as an offset gain.
- HF
MuseSparkTextInputScaledRMSNormscales before normalising (not foldable at all). It resolves to offset=1.0, with fold error 0.115 (fp32) / 0.093 (bf16). - The
self.weight+1pattern also matchesself.weight+1e-6.
No current definition routes such a class into a fold. Fix: if the probe fails, skip the scale (or raise) rather than guess from source text.
#3990 (LoRA/EoRA scaling)
3. alpha_pattern / rank_pattern matching is broader than PEFT's, giving silent 8× scale errors (medium)
gptqmodel/adapter/adapter.py:26-49 (_rank_pattern_matches, now also used for alpha) uses endswith with no dot boundary, then an unanchored re.search. PEFT 0.21.2 get_pattern_key uses re.match(rf"(.*\.)?({key})$", name).
Per-module delta vs real PEFT adapters (r=8, alpha=8, pattern alpha=64):
'1.self_attn.q_proj' -> model.layers.11.self_attn.q_proj gets 8x (PEFT: layer 1 only)
'model.layers.1' -> layers 1, 10, 11 q_proj get 8x (PEFT: matches nothing)
'up_proj' w/ gate_up -> every down_proj gets 8x (12 modules)
The same over-match on rank_pattern changes self.rank and therefore alpha/r.
Fix: use PEFT's exact rule, keep first-match order, and keep the case-insensitive retry only for legacy exports. Consider deriving r from lora_A.shape.
4. A float alpha in alpha_pattern crashes the loader (low-medium)
adapter.py:392: assert isinstance(override, int). An adapter whose adapter_config.json has "alpha_pattern": {"...": 4.0} raises AssertionError in post_init, although PEFT accepts it. Under python -O the assert is skipped. Fix: accept numbers.Real > 0 and use float().
(Verified correct for #3990: alpha≠r, rslora, full-name and regex patterns all match PEFT at ≤ 1.1e-7. The scale is applied exactly once across preload/merge/EoRA. The EoRA dynamic-rank export loads in PEFT with scaling 1.0. The EoRA covariance now matches fp64 uniform XᵀX/N to 8.5e-8, independent of order and device split.)
#3993 (AWQ 8-bit natural order)
5. Incomplete: dequantize_model still assumes the AWQ GEMM layout for every AWQ checkpoint (medium-low; crashes, not silent)
gptqmodel/utils/model_dequant.py:1583-1597 now reads bits, but ignores format/version and per-module dynamic bits. With checkpoints packed by GPTQModel's own .pack():
- GEMM 4-bit / AwqTorch 8-bit: exact.
- AwqGEMV 4-bit:
IndexError: index 106 is out of bounds. - AwqGEMVFast 4-bit:
NotImplementedError: "rshift_cpu" not implemented for 'Half'. - A 4-bit config with an 8-bit
down_projviadynamic: size-mismatchRuntimeError.
Fix: dispatch on format/version (GEMV = [out, in/8], GEMV_FAST = pack_intweight interleave with fp16 scaled zeros) and resolve bits per module.
(Verified correct for #3993: 4/8-bit, gs 128/-1, fp16/bf16 through AwqTorch / AwqMarlin / AllSpark are all within 2.5e-4 to 3.9e-3 of fp64, with no 4-bit regression. swordfish.py:407 still has an 8-bit [0,2,1,3] undo, but it is dead code while SUPPORTS_BITS=[4].)
Plausible, not verified: GPTQModel's natural-order 8-bit AWQ checkpoints are probably mis-read by vLLM awq_marlin, which assumes the [0,2,1,3] byte interleave. A trained DoRA magnitude vector is probably silently ignored (use_dora is accepted).
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 14, 2026
Related: #4013 item 4. GPTQModel's natural-order 8-bit AWQ checkpoints (from #3993) decode wrongly in vLLM 0.11
awq_marlin, which still undoes the[0,2,1,3]interleave: logits error 1.47 against a quantization error of 0.01. vLLM 0.33 rejects 8-bit AWQ outright.fix(awq,adapter): honor norm data flow and PEFT pattern rules (#4002) (…
fix(awq): build scaling groups for norm-less trees and skip non-sourc…
fix(awq): dispatch dequantization on the saved AWQ layout and per-mod…