Skip to content

[BUG] Module-tree subset ordering violates data flow in 6 definitions: a consumer is quantized in the same subset as, or before, its producer (LongCat-Flash, Kimi-Linear, Nemotron-H, LFM2-MoE, bailing_hybrid MLA, DeepSeek-VL2 MLA) #4372

Closed

Description

@Qubitium

Severity: medium. These do not crash. Sequential replay feeds non-quantized activations to the affected consumers, which lowers GPTQ/AWQ quality, and in the AWQ case also affects the scale grouping. Kind: new bugs of the same class as #4041. That audit fixed deepseek_v2/v3/v32/v4, lfm2, falcon_mamba, minimax and jamba; those fixes were re-verified as correct here.

How this was found (CPU, def6e61)

  1. Plan check. simple_layer_modules was resolved the way the looper does it. The models were meta-built from real config.json files in the local model store, and the real checkpoint tensor names were compared against each plan.
  2. Data-flow check. About 100 tiny random native models were built (tests/test_awq_scaling_groups.py::_tiny_config). Noise was added to each Linear's output, and the test recorded which Linears' inputs changed. A violation means a consumer's subset index is ≤ its producer's.

Findings

Definition Problem Data-flow evidence Expected
longcat_flash.py:27-35 Both attention sub-blocks run before both MLPs, but the forward order is attn0 → mlps.0 → attn1 → mlps.1. MLA q_a/q_b and kv_a/kv_b also share a subset. mlps.0.{gate,up,down}_proj → self_attn.1.{q_a,q_b,kv_a,kv_b,o_proj}: the consumer is quantized 2–3 subsets before its producer. Also q_a_proj[0] → q_b_proj[0] and kv_a_proj_with_mqa[0] → kv_b_proj[0]. attn0 (q_a/kv_a → 0, q_b/kv_b → 1, o → 2), mlps.0 (gate/up → 3, down → 4), attn1 (3 subsets), mlps.1
kimi_linear.py:20-38 o_proj:1 shares subset 1 with g_b_proj, forget_gate.f_b_proj, q_b_proj and kv_b_proj. This is the native path that Kimi-Linear-48B-A3B-Instruct dispatches to. g_b_proj[1] → o_proj[1] and f_b_proj[1] → o_proj[1] (KDA layers); q_b_proj[1] → o_proj[1] and kv_b_proj[1] → o_proj[1] (MLA layers) o_proj:2
nemotron_h.py:35 (and the NemotronOmniQModel copy, #4355) Mamba2 mixer "in_proj:2", "out_proj:2" mixer.in_proj[2] → mixer.out_proj[2]. The real NVIDIA-Nemotron-3-Nano-30B-A3B plan has a ['mixer.in_proj','mixer.out_proj'] subset. out_proj:3 (each layer has a single mixer type, so the extra index is free)
lfm2_moe.py:29 "conv": ("in_proj", "out_proj") has no subset digits. Incomplete fix of #4041, which fixed lfm2.py but not this file. conv.in_proj[0] → conv.out_proj[0] ("in_proj:0", "out_proj:1"), as in lfm2
bailing_moe.py:37,40 (bailing_hybrid native MLA, Ling 3.0) kv_b_proj:1 and o_proj:1 self_attn.kv_b_proj[1] → self_attn.o_proj[1] o_proj:2
deepseek_vl_v2.py:45 (MLA checkpoints: vl2-small, vl2) q_a_proj:0 is with q_b_proj:0, and kv_a_proj_with_mqa:0 is with kv_b_proj:0. This copy was missed by the #4041 fix to deepseek_v2.py. Static only: the remote code needs timm. q_a/kv_a → 0, q_b/kv_b → 1, o → 2

Quick repro (plan side)

from types import SimpleNamespace
from gptqmodel.models.auto import MODEL_MAP
q = SimpleNamespace(dynamic=None)
print(MODEL_MAP["longcat_flash"].simple_layer_modules(SimpleNamespace(model_type="longcat_flash", n_routed_experts=2), q)[:6])
print(MODEL_MAP["lfm2_moe"].simple_layer_modules(SimpleNamespace(model_type="lfm2_moe", num_experts=2), q)[0])  # ['conv.in_proj', 'conv.out_proj']

Data-flow side: build AutoModelForCausalLM.from_config(_tiny_config("longcat_flash")) and add noise to the output of mlps.0.down_proj. The input of self_attn.1.q_a_proj changes.

Suggestion: a generic data-flow test like the one above, run in CI over every native definition, would stop this class of bug from coming back.


Found during an AI-assisted review (Claude Code, round 12) of def6e61; repros were run at that commit (A/B against 842d666 where noted) on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    Taking this. I'll investigate against current main, add a targeted regression test, and open a PR. Will report back here if the claim turns out to be invalid or already fixed.

  3. self-assigned this
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions