[BUG] Follow-up on #4093/#4087 fixes: #4110 regresses TeleChat2 AWQ (PR test fails on main), native load skips before_model_load (Ouro/Spark crash), legacy remote-code generate still broken, dynamic fallback overrides ignored, AWQ VL rotary crash, 4 more AWQ trees fold #4121
Description
Audit of main @ ffa0502, RTX 4090. Checks the fixes for #4093 (#4108, #4109), #4090 (#4099) and #4087 (#4089).
- fix(macaq): int64 row offsets, device-bound Triton launches, sm_120 K tiles (#4090) #4099 (MACaQ): fixed.
- fix(awq): size scale-search replay by sequence rows and inherit fallback threshold (#4087) #4089: fixed as filed.
- fix(models): restore native remote-code RoPE and repair load/generate paths (#4093) #4108 RoPE restore: correct.
- Still broken: items 1–10 below. They are a regression, incomplete fixes, and sibling definitions with the same pattern.
1. Regression: #4110 breaks #4109's TeleChat2 AWQ fix, and the PR's own test fails on main (high for the family)
#4110 (06c635c, _token_row_replay_kwargs) turns every captured mask with ≥3 dims into an additive float mask. TeleChat2's awq_module_replay_inputs only adds its bool mask when attention_mask is None, so the float mask reaches the remote attention's masked_fill:
pytest tests/test_telechat2_coverage.py
FAILED test_telechat2_awq_quantizes_attention_projections
RuntimeError: masked_fill_ only supports boolean masks, but got mask with dtype c10::Half (modeling_telechat2.py:507)
bisect: passes at 498e980 / c73793c, fails from 06c635c
Fix: in the TeleChat2 hook, convert a non-bool mask with mask < 0. Alternatively, have the #4110 replay keep the captured mask's dtype and meaning.
2. The native (unquantized) load branch never calls before_model_load, so Ouro and Spark-X2.5 native forward/generate crash (high for those families)
models/loader.py native branch (~1803): the hook runs only for quantize (:1887) and quantized reload (:2476). The mask-helper compat patches applied by ouro.py / spark2_5.py in before_model_load are therefore skipped for native loads, including the model_test.py native baseline:
Ouro-1.4B native generate: TypeError create_causal_mask() got an unexpected keyword argument 'input_embeds'
same, with before_model_load called manually: ' Paris.\n\nThe capital of France'
Spark-X2.5-4B: same pair
agnes, brumby, dots3_note, ernie4_5_vl_moe, minicpm_o and minicpmv also do compat work in before_model_load (code read only). Fix: call before_model_load(..., load_quantized_model=False) in the native branch too.
3. #4108 fixed transformers-5 generate() only for ChatGLM; sibling legacy remote-code families still crash, both native and quantized (medium-high)
The ChatGLM-only compat lives in utils/hf.py _normalize_chatglm_remote_code_config_compat (~1455-1487) and chatglm.py _patch_generation_compat. Other families hit the same transformers-5 gaps: a DynamicCache indexed as a legacy tuple, the removed seen_tokens, get_max_length() on an empty cache, and the num_layers → num_hidden_layers alias:
Baichuan2 / DeciLM: TypeError: 'DynamicCache' object is not subscriptable (native AND quantized generate)
EXAONE-3: AttributeError: 'NoneType' object has no attribute 'shape' (prepare_inputs_for_generation)
MiniCPM-2B-dpo (real ckpt): AttributeError: 'DynamicCache' object has no attribute 'seen_tokens'
Nanbeige4.2-3B (real ckpt): ValueError: max() iterable argument is empty (also at a15e6bf)
PanGu-alpha: AttributeError: 'GPTPanguConfig' object has no attribute 'num_hidden_layers' (the alias #4108 added for ChatGLM only)
These families' tests only run ARC, not assertInference. Fix: generalize the ChatGLM approach (a kwargs hook plus num_layers/n_layer aliases), or add a shared legacy-cache adapter.
4. Per-module dynamic fallback overrides are silently ignored in real GPTQ runs (medium, silent)
looper/gptq_processor.py:182: clone_gptq_config_for_module applies the dynamic override (:153), then qcfg_clone.fallback = normalize_fallback(fallback, qcfg_clone.fallback) overwrites it with the processor-level fallback. The real loop always passes quantize_config.fallback (base.py:2599 → module_looper.py:2278). The same pattern is in macaq_processor.py:114, qqq_processor.py:141 and vptq_processor.py:101.
dynamic={"+:.*mlp\.down_proj": {"fallback": {"strategy": "median", "threshold": 1e9}}}, real quantize:
model.layers.0.mlp.down_proj Fallback(strategy=RTN, threshold='0.5%', smooth=None) # expected median / 1e9
tests/test_dynamic.py::test_dynamic_overrides_apply_per_module calls preprocess(module) without fallback, so it misses this. Fix: merge the processor fallback under the override, not over it.
5. normalize_fallback's dict merge drops smooth, both the override's own and the inherited one (low-medium, silent; left over from #4089)
utils/fallback.py:26-31 forwards only strategy and threshold. docs/awq-scale-search-memory.md says it "merges a per-module override onto the config default".
normalize_fallback({"threshold": "2%"}, Fallback(smooth=SmoothMAD(k=2))) -> smooth=None
normalize_fallback({"smooth": "mad"}, ...) -> smooth=None
6. #4109 position fix is incomplete: AWQ still crashes on Qwen2-VL, Qwen2.5-VL and multimodal Gemma3 (high for AWQ on VL)
awq_processor.py:324-330 _get_root_rotary doesn't find model.language_model.rotary_emb, and these definitions don't set rotary_embedding. Now that #4109 drops stale position_embeddings, attention unpacks None:
AWQ Qwen2-VL-2B-Instruct -> TypeError: cannot unpack non-iterable NoneType object (GPTQ on the same model works)
Fix: scan named_modules for the rotary as base.py:3436 does, or set rotary_embedding on the VL definitions. Twelve other VL definitions don't set it either (not run).
7-10. AWQ trees that still fold across a nonlinearity or residual (same class as #4039 / #4093)
Per-group relative error of the AWQ fold on tiny configs (correct groups are ~1e-7):
| Definition | Bad group | rel err | Fix |
|---|---|---|---|
pangu_alpha.py:20-30 (#4109 incomplete) |
c_fc → c_proj across GELU; top-query layer ln_1 → q_proj although q reads custom_query |
4.1e-2; 3.4e-3 | c_fc:0:nosrc; exclude the last layer's q_proj from ln_1 |
olmo_hybrid.py:56 (post-norm attention layers, like OLMo2/3) |
post_attention_layernorm → gate/up |
3.0e-1 | per-layer-type tree / :postnorm on attention layers |
gemma4.py:263,268-271 composite + gemma4_unified.py:71 (the text-tree fix was not copied) |
post_feedforward_layernorm → per_layer_input_gate; v_proj → o_proj on MHA configs |
0.38; 0.19–0.26 | copy :postnorm / v_proj :nosrc from the text tree |
nemotron_h.py:28 |
mixer.up_proj → down_proj across relu² |
2.1e-2 | up_proj:3:nosrc |
Adding these families to FAMILY_MODEL_TYPES in tests/test_awq_scaling_groups.py would catch them.
Plausible, not verified
- MACaQ: non-OOM transient Triton failures (e.g. a cache-dir race) still disable Triton for good. The fallback log names the configured strategy (e.g.
median), but MACaQ always applies RTN and ignoressmooth. tests/test_fallback.py::test_fallback_near_dead_scale_survives_smoothing_and_packingfails on main for every sym=True non-RTN case (zero-point mismatch of 7.0).
Checked, clean
- fix(macaq): int64 row offsets, device-bound Triton launches, sm_120 K tiles (#4090) #4099: M=262444 × K=8192 (past 2^31/K) W4A4 matches Torch (rel 2.6e-3) and Triton stays enabled. Every launch runs under
_launch_device(x.device). HF refusers are registered. MoE with 228 zero-token experts takes the RTN fallback, anddynamic-:reloads as dense. - fix(awq): size scale-search replay by sequence rows and inherit fallback threshold (#4087) #4089: 3-D sizing is correct, and a dict without
thresholddefaults to 0.5%. - fix(models): restore native remote-code RoPE and repair load/generate paths (#4093) #4108 RoPE: Instella, EXAONE-3, DeciLM, internlm, Nanbeige, K2-Horizon and MiniCPM-128k rotary buffers match an fp32 reference exactly. Instella native PPL equals plain HF with a manual inv_freq fix. Instella and K2-Horizon generate.
- fix(models): correct remote-code AWQ trees, coverage, position replay, and looped calibration (#4093) #4109 sweep: 20 more families fold cleanly. No other per-projection trees or looped decoders.
🤖 Generated with Claude Code
Activity
fix(awq): preserve the captured mask form and fallback precedence (#4121
fix(models): run the pre-load hook on native loads and share one lega…
fix(awq): resolve multimodal rotary and stop folding across residual/…
Qubitium commentedon Nov 15, 2026
All ten items are now on
main, in three parts:dynamicfallback precedence, andnormalize_fallbackdroppingsmooth— PR fix(awq): preserve the captured mask form and fallback precedence (#4121, #4125) #4131.before_model_loadon the native load path, and one shared legacy-generation adapter instead of a ChatGLM-only patch — PR fix(models): run the pre-load hook on native loads and share one legacy generate adapter (#4121) #4132.d52b14824, PR fix(awq): resolve multimodal rotary and stop folding across residual/nonlinearity (#4121) #4135.Item 1 was the one that mattered most operationally: a merged PR's own test was red on
main._token_row_replay_kwargsturned every captured mask with ≥3 dims into an additive float mask, while TeleChat2's hook supplies its bool mask only whenattention_mask is None— so the float mask reached the remote attention'smasked_filland raised. The replay now classifies the captured form (additive / bool-keep / bool-masked) from dtype and diagonal and rebuilds the same form and polarity.tests/test_telechat2_coverage.pywent 1 failed / 2 passed → 3 passed.The fold table is worth recording, since the "worst surviving group" is the real measure:
ln_1 → [q,k,v]top-query layerpost_attention_layernorm → gate/uppost_ffn → per_layer_input_gatev_proj → o_projmixer.up_proj → down_proj(relu²)Those five families were also added to
FAMILY_MODEL_TYPESintest_awq_scaling_groups.pyso the existing fold-error harness catches this class automatically — they fail on the parent commit and pass now.Item 3's generalisation is the durable part: the ChatGLM-only shape of the #4108 fix was itself the defect, so the fix is now one shared adapter (cache surface,
num_layers/n_layeraliases) with no per-family copy-paste, andASSERT_INFERENCEis enabled for the affected families instead of ARC only.Two items were reported as exercised-with-caveats rather than fully closed, and that is recorded honestly: Baichuan2 and ChatGLM could not be run end to end here (no
sentencepiecein the venvs), and the real Qwen2-VL crash is capture-ordering dependent — the deterministic repro is a tiny model, with the real checkpoint failing at the replay site.Closing as resolved.