Skip to content

fix: close the #5978 follow-ups (AWQ scale search, dtype/eval round trip, PARO/offload, LFM3 tests) - #5980

Merged
Qubitium merged 6 commits into
mainfrom
fix/pr4620-followups
Nov 22, 2026
Merged

Qubitium merged 6 commits into
mainfrom
fix/pr4620-followups

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #5978 (the #4620 regression fixes). #5978 deliberately left four
items out of scope; this PR closes all of them plus two red tests it left
behind on main.

1. AWQ scale search restored

#5978 disabled AWQ scaling for four families by returning empty fold groups.
Each family now emits every group that measures output-neutral on its real
forward, and only the provably non-neutral folds stay suppressed.

Family Restored groups Dropped (measured non-neutral)
gpt_pangu ln_1 -> k/v, attn.v_proj -> attn.c_proj, ln_2 -> mlp.c_fc top block ln_1 -> q_proj (reads custom_query); c_fc -> c_proj stays nosrc
bailing_moe generic planner on dense/mla/hybrid/legacy_gqa, worst delta 1.9e-07 none
nemotron_h generic planner for dense Mamba / full-attention / dense-MLP mixers, 6e-08..1.5e-07 native NemotronHMoE mixer stays plain: shared-expert-only fold 2.4e-2, and latent widths break the group
inkling2_loop per-expert up_proj -> down_proj (23 folds), 1.9e-07..3.5e-06 post_attention_layernorm group 8.2e-2..2.9e-1; o_proj.linear -> gate_proj 1.2e-1..3.8e-1

Two latent bugs surfaced while qualifying the folds:

  • nemotron_h: A_log/D/dt_bias are Parameters, not modules. Listed last
    in the mixer tuple they closed the q/k/v subset and folded o_proj from
    the block norm (8.1e-2). They are now separate trailing subsets.
  • inkling2_loop: module-tree order is not this layer's data flow — q/k/v read
    input_layernorm through attention_input, and o_proj.gate_proj reads the
    attention input. The two tree-order groups are dropped rather than folded.

Tests build the real production configs, assert exact emitted groups, assert
neutrality under a random scale, and pin the dropped folds as non-neutral so a
planner change cannot silently reintroduce them.

2. Pre-existing failures

Bug Root cause Evidence
checkpoint dtype auto dtype honored quantize_config.device only for MiMo, so a CPU quantization on an MPS host saved fp16 and reloaded bf16 embed_tokens.weight now bf16; subfolder logits exact instead of 191/320 mismatched
PARO guard packing-only callers pass a one-element pairs/theta/channel_scales placeholder; the #5659 shape guard raised (8,128) vs (1,) placeholder keeps identity rotation; a real krot mismatch still raises
failed-run offload humming's cached ModuleNotFoundError kept its traceback, pinning the model so the offload finalizer never ran no offload/run-* left after del model
HummingLinear fusion HummingLinear/AwqHummingLinear were in neither kernel_specs() nor EXCLUDED shape-padded JIT operands have no concatenable layout; now excluded with rationale
eager vs compiled bf16 decode wide decode cast fp16 scales to bf16 before the multiply; the compiled path rounds once eager and compiled decode are bitwise equal
in-session vs reloaded logits freshly installed kernel modules stayed in training mode, which restores the checkpoint zero-point layout model.eval() at the end of quantize(); torch.equal is true

3. main was red from #5978

tests/test_awq_scale_folding.py and tests/test_lfm3_native_coverage.py
still asserted the pre-#5978 LFM3 fold contract (4 and 10 failures). They now
match the shipped behavior and pin the suppressed operator_norm -> q/k/v
fold with its measured 5.5e-2 error. The two TorchInt8Linear cache-race
tests are skipped on darwin, which has no INT8 implementation.

4. The "full-suite-only" interns1/internvl failures do not reproduce

A full pytest tests/module_tree run (4,198 collected, OMP_NUM_THREADS=1)
passed all 15 test_interns1_local_port.py tests and the
test_internvl_chat_local_port.py LlamaForCausalLM case. They were almost
certainly resource contention from eight concurrent audit agents; no product
code changed for them. A full run also aborted at
test_parallel_branch_calibration_uses_each_branch_inputs[896]. That is a
separate, pre-existing flaky native crash, not an interns/internvl failure: the
test process exits 139/137/133 in roughly half of repeated runs with libmalloc
"memory corruption of free block" and faulthandler showing concurrent
quantization workers (gptq.py::_propagate_block_error, logbar
_update_slot_widths). The code involved predates #4620
(test_parallel_branch_calibration.py from #4153/#4724, concurrent-branch code
from 8a2f668813). Excluding that one file, the tail ran
1,402 passed / 29 skipped / 2 xfailed in 67s. It needs a separate owner follow-up
on concurrent quantization/logbar thread safety.

Verification

  • AWQ + fix set (17 files): 834 passed, 213 skipped
  • dtype / eval / offload / kernel set: 145 passed, 33 skipped
  • fusion contract + cache race: 42 passed, 152 skipped
  • ruff + git diff --check: clean

Known environment-only gaps, unrelated to these changes: tests/kernels/test_gptq_bf16_fp16_scales_5740.py needs triton; test_quantize_references_source_embedding_in_offload_dir needs an MPS device pool; tests/test_load_strict_kwargs_4945.py is intermittently NaN on a clean HEAD export too.

…kling2

#5978 deferred AWQ scaling for four families by returning empty fold groups.
Restore every group that measures output-neutral on the real forward and keep
only the folds that are provably non-neutral:

- gpt_pangu: generic planner, minus the top block's `attn.q_proj` in the
  `ln_1` group (it consumes `custom_query`, not the norm). `ln_1 -> k/v`,
  `attn.v_proj -> attn.c_proj`, `ln_2 -> mlp.c_fc` are neutral; the
  `c_fc -> c_proj` source stays `nosrc`.
- bailing_moe: drop the `isinstance(BailingConfig): return []` override and
  use the generic planner. All groups are neutral on dense/mla/hybrid/
  legacy_gqa (worst 1.9e-07).
- nemotron_h: generic planner for dense Mamba/attention/MLP mixers. Only the
  native `NemotronHMoE` mixer stays plain (one norm feeds shared and routed
  experts; shared-only fold 2.4e-2). Also move `A_log`/`D`/`dt_bias` out of
  the `mixer` tuple: as Parameters they closed the q/k/v subset and folded
  `o_proj` from the block norm (8.1e-2).
- inkling2_loop: keep the per-expert `up_proj -> down_proj` folds
  (1.9e-07..3.5e-06). Drop the tree-order `post_attention_layernorm` and
  `o_proj.linear -> gate_proj` groups, which follow module order rather than
  data flow and change the layer output by 8e-2..4e-1.

Tests pin neutrality on production configs and pin the dropped folds as
non-neutral, so a future planner change cannot silently reintroduce them.
…l in eval

Three independent round-trip bugs that made an in-session model disagree with
the checkpoint it just saved:

- loader: auto dtype only followed `quantize_config.device` for MiMo sources.
  On an MPS/CUDA host a CPU quantization therefore loaded and re-saved the
  dense source in the host dtype (fp16) while a CPU reload resolved bf16,
  so the round trip was not dtype-preserving. Honor the quantization device
  for every `BaseQuantizeConfig`.
- torch qlinear: wide `_decode_248_weight` cast fp16 scales to bf16 before
  the multiply while the fused/compiled path multiplies in fp32 and rounds
  once. Compute wide decodes in fp32 (fp64 when requested) and cast the
  product once, so eager and compiled decode are bitwise equal (#5740).
- base: the quantize loop installs fresh kernel modules that start in
  training mode; their `train` transition also restores the checkpoint
  zero-point layout. Call `model.eval()` at the end of `quantize()` so an
  in-session forward decodes through the same path as the saved checkpoint.
…rom failing runs

- paro_processor: `pack_module()` treated the minimal placeholder triple
  `pairs=(1,)`, `theta=(1,)`, `channel_scales=(1,)` used by packing-only
  callers as real rotation state and raised the #5659 `(8,128)` vs `(1,)`
  shape error. Keep the freshly built layer's identity rotation for that
  exact placeholder; a real krot mismatch still raises.
- humming: the optional-import `ModuleNotFoundError` was cached with its
  traceback. Kernel discovery imports every qlinear module from inside
  `quantize()`, so the retained stack pinned the model and its run-exit
  state; `del model` could never run the offload finalizer and left
  `offload/run-*` behind (#4595). Clear `__traceback__`/`__context__`/
  `__cause__`; type and message are unchanged.
- test_fusion_kernel_backends: `HummingLinear`/`AwqHummingLinear` were added
  by #5966 without a fusion spec or an `EXCLUDED` entry, so the registry
  contract failed. Humming's `post_init()` replaces checkpoint tensors with
  shape-padded JIT operands and a per-layer `LayerConfig`; there is no
  concatenable native layout, so list both as excluded with that rationale.
- test_paro: `_replay_layer_outputs()` now always passes `consume_inputs=`
  (since #5928) but the first `_DummyLooper` stub kept the old signature.
  Accept and discard the keyword; test semantics are unchanged.
#5978 suppresses the `operator_norm -> q/k/v` fold on LFM3 attention layers
because the sigmoid gate consumer is left on the divided norm (uncompensated
delta 5.5e-2; compensating it rewrites non-quantized gate weights). The conv
layer still folds both input norms. Update the LFM3 tests to that contract
instead of the pre-#5978 expectation, and pin the suppression plus its
measured error so the decision is explicit.
`TorchInt8Linear` has no darwin implementation, so the two race tests failed
with a backend-availability error rather than exercising the cache. Gate the
module on the platform the kernel supports.
Comment thread gptqmodel/nn_modules/qlinear/torch.py Resolved
@Qubitium
Qubitium merged commit 8d42d0c into main Nov 22, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/pr4620-followups branch November 22, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant