Skip to content

[BUG] Module trees: wrong subset order (DeepSeek-V4, DeepSeek-V2, LFM2 conv), silently unquantized linears (Jamba x_proj, AXK2), untagged shared-input siblings #4041

Closed

Description

@Qubitium

Module-tree audit across all models/definitions at main @ 8f2efe5 / transformers 5.22.1.

Method: 134 definitions whose model_type exists natively. Tiny random models were built through the real loader path (defuser + _convert_model_with_defuser), then checked for:

  • Coverage: find_modules(layer) vs the tree.
  • Shared inputs: forward hooks recording each linear's input.
  • Data flow: perturb each module's weight and see which later modules' inputs change.

Good news on :in= tags: there are no wrong shared-input tags in any of the 100 definitions that completed a forward, including unverified ones with tags forced on. So Hessian dedup is never fed a different module's input.

1. Wrong subset order: a consumer is quantized together with, or before, its producer (silent; loses true-sequential compensation)

  • deepseek_v4.py:1445-1451: q_b_proj:0 shares subset 0 with its producer q_a_proj:0, and kv_proj:2 comes after o_b_proj:1, which consumes it. The perturbation test confirms both dependencies. Fix: q_a/kv → 0, q_b → 1, o_b → 2.
  • deepseek_v2.py:34: q_a, q_b, kv_a and kv_b are all in subset 0, while deepseek_v3, kimi_k25 and minicpm3 split them 0/1.
  • lfm2.py:23: "conv": ("in_proj", "out_proj") has no subset digits, so out_proj shares subset 0 with its producer in_proj. AWQ then also scales out_proj from operator_norm (3e-4).
  • Minor: falcon_mamba in_proj / x_proj (falcon_mamba.py:21); minimax lightning output_gate / out_proj (minimax_m2.py:90-91).

2. Linears silently not quantized (low)

  • jamba: mamba.x_proj is a called nn.Linear that isn't in the tree and isn't marked :! (falcon_mamba does quantize it).
  • axk2: the gated-norm MLPs (*_layernorm.mlp.fc1/fc2) and the DSA indexer linears aren't in the tree and are only implicitly excluded.

Everything else is either covered or intentionally excluded: routers, mllama cross-attention via should_quantize_layer, conv1d / dt_proj, indexers marked :!.

3. Siblings with bitwise-identical input but no :in= tag (performance only: Hessian dedup is off)

These are in addition to the list in #4020.

  • q/k/v and/or gate/up: afmoe, axk2, cohere2_moe, deepseek_v2/v4, deepseek_vl, ernie4_5_moe, flint (dense MLP), gemma4_unified, glm4v, glm_ocr, granitemoe(_swa), hrm_text, hy_v3, inkling, internvl, jamba, laguna, lfm2(_vl), llava, minicpm3, ministral3, the minimax family, mllama, muse_glimmer, olmo3, olmo_hybrid, olmoe, opt, ovis2, phimoe, qwen2_audio, qwen2/2.5/3-VL, smolvlm, solar_open, starcoder2, gpt_neo.
  • Parallel blocks where attention and MLP read the same input: cohere/cohere2, falcon, gpt_neox, gptj, phi, codegen.

4. dynamic names: no mismatch found

Module full names are layers_prefix + relative and use anchored re.match. Negative rules are sorted first by QuantizeConfig, so filter_not_quantize_module (models/base.py:1580) testing relative names is intended.

Unverified: these native 5.22 layouts differ from their trees, but the definitions rely on remote code, so they'd only break when a checkpoint loads without it:

  • nemotron_h backbone (see the compat issue)
  • kimi_k25 language_model.model
  • voxtral
  • unlimited_ocr
  • the bare qwen2_vl_text / qwen2_5_vl_text TextModels

🤖 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