Repository navigation
Description
Found on main @ 4f287eb, AMD R9700 (ROCm 10.1). Hymba-1.5B-Base truncated to 2 layers, real weights, fp32, offload_to_disk=False. This is the only mode that loads; see #4888.
Hymba AWQ has two separate defects. The first one hides the second.
1. AWQ crashes: _sanitize_kwargs drops every kwarg of a **kwargs-only forward
File "gptqmodel/looper/awq_processor.py", line 3294, in _search_best_scale
File "gptqmodel/looper/awq_processor.py", line 3854, in _build_chunked_reference_outputs
File "gptqmodel/looper/awq_processor.py", line 4577, in _iter_prepared_forward_outputs
File ".../modeling_hymba.py", line 1744, in forward
res, attn_key_value = self.mixer_forward(hidden_states, cache_params=past_key_value, attention_mask=kwargs['attention_mask'], kv_last_layer=kwargs['kv_last_layer'], position_ids=kwargs['position_ids'], ...)
KeyError: 'attention_mask'
The replayed module2inspect is mamba (HymbaBlock). Its signature is forward(self, hidden_states, past_key_value=None, **kwargs), and it reads attention_mask, kv_last_layer, position_ids, use_cache and use_swa out of **kwargs. AWQProcessor._sanitize_kwargs (looper/awq_processor.py:4837-4854) keeps only keys that appear by name in inspect.signature(module.forward).parameters. It never checks for a VAR_KEYWORD parameter, so it hands the block an empty kwargs dict. The KeyError is not an _AWQScaleGroupError, so quantize() aborts in layer 0.
If _sanitize_kwargs passes everything through when the signature has **kwargs, the same run gets past the scale search for both layers.
2. The Hymba tree names a norm that does not exist, so routed-expert gate/up are folded into input_layernorm
gptqmodel/models/definitions/hymba.py:31-43 declares "post_attention_layernorm": ("post_attention_layernorm:!",) before moe:moe. HymbaDecoderLayer has no such module: the norm in front of the MoE is pre_moe_layernorm (modeling_hymba.py, self.pre_moe_layernorm = HymbaRMSNorm(...), applied right before self.moe(...)). Because the declared norm is absent, the experts block has no producer of its own. awq_get_modules_for_scaling merges it into the preceding norm run and emits:
input_layernorm -> [mamba.in_proj, moe.experts.0.gate_proj, moe.experts.0.up_proj]
The real pipeline (with item 1 bypassed) scales exactly this group in both layers (apply_scale input logged). But gate_proj/up_proj read pre_moe_layernorm(residual + mamba_out), not input_layernorm's output, so the fold is not output-preserving. Folding a random 0.5-1.5 scale into this group on the real weights, the way tests/test_awq_scaling_groups.py does, changes the logits by:
| layer | group | rel. logit change |
|---|---|---|
| 0 | input_layernorm -> [mamba.in_proj, moe.experts.0.gate_proj, moe.experts.0.up_proj] |
5.8e-2 |
| 1 | same | 8.2e-2 |
With the tree corrected to "pre_moe_layernorm": ("pre_moe_layernorm:!",) and "mamba": ("in_proj:0:nosrc", "out_proj:1"), the groups become input_layernorm -> [mamba.in_proj], pre_moe_layernorm -> [gate_proj, up_proj] and up_proj -> [down_proj], and every fold measures 1e-6 or less. nosrc mirrors the #4674 fix for Granite-4.0-H. The current tree only avoids an in_proj -> out_proj fold because the widths happen to differ, and that fold would be non-homogeneous through the conv/SSM/attention path.
The coverage log also shows mamba.x_proj.0, mamba.dt_proj.0 and mamba.conv1d as undeclared. They should be declared :! if staying dense is intended.
Repro
import torch
from gptqmodel import GPTQModel
from gptqmodel.quantization import AWQConfig
from gptqmodel.quantization.config import CalibrationConfig
path = "nvidia/Hymba-1.5B-Base" # num_hidden_layers=2 copy used here
q = GPTQModel.load(path, AWQConfig(bits=4, group_size=32, offload_to_disk=False),
trust_remote_code=True, dtype=torch.float32)
rows = [{"input_ids": torch.randint(3, 32000, (L,)).tolist(), "attention_mask": [1] * L} for L in (40, 48, 56, 64)]
q.quantize(CalibrationConfig(dataset=rows)) # KeyError: 'attention_mask'Fold check for item 2: build HymbaQModel around the loaded HF model, call awq_get_modules_for_scaling(layer, feats, {}), then apply_scale(layer, [(prev, layers, scales, None)]) with random scales and compare logits. Result: 5.8e-2 / 8.2e-2 as above, and 1e-6 with the corrected tree.
Suggested fix
_sanitize_kwargs: if the forward accepts**kwargs, return the kwargs unchanged, or at least keep the keys the parent layer passed to it.HymbaQModel.module_tree: renamepost_attention_layernormtopre_moe_layernorm, markmamba.in_proj:nosrc, and declarex_proj/dt_proj/conv1d:!.
Test that should have caught it
tests/test_awq_scaling_groups.py does not include hymba. The family needs the remote code and mamba kernels, but the fold invariant runs on CPU with the torch reference kernels. Nothing exercises _sanitize_kwargs with a **kwargs-only module2inspect.
Severity
High for Hymba AWQ. Today it is a hard crash. Fixing only item 1 would turn it into silent quality loss: every layer's routed-expert gate/up would be scaled by the wrong norm.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-4891is working on this issue now.Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-root-4891is no longer working on this issue. The issue is free to claim.This host has no Hymba checkpoint and no
nvidia/Hymba-1.5B-Baseremote code cached (HF_HUB_OFFLINE=1), and transformers 5.20.2 ships no nativehymbaconfig/model, so neither half of the issue can be reproduced or validated here. Both parts are needed together: fixing only_sanitize_kwargs(item 1) would convert today's hard crash into silent quality loss, which the issue explicitly warns against.#4888 (the load/offload half) is also released by the same agent for the same reason.
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #5024
One workload with #4888, #4891: both are the Hymba quantization path: root-level parameter offload/dtype guard and the AWQ kwargs/tree defects share the same fixtures
make Hymba quantizable in half precision: root-parameter offload + dtype guard, AWQ **kwargs passthrough and corrected norm tree
test(hymba): bind the required replay kwargs instead of bare reads (#…
fix(awq): replay a `**kwargs` block and fold the norm the layer owns (#…
Qubitium commentedon Nov 17, 2026
Agent release:
agent-root-4891finished this issue. Fix: #5019, squash-merged as 7744cb8.Both defects in the report are fixed, not just the crash:
AWQProcessor._sanitize_kwargsnow passes the captured kwargs through when the forward declares a**kwargscatch-all (minus the processor's private bookkeeping), and_prepare_module_forwardtreatsposition_idsas accepted for such a forward so a 2-D activation is promoted to[1, seq, hidden]for the block'spack(...).definitions/hymba.pynow declarespre_moe_layernorm(the normHymbaDecoderLayeractually owns), marksmamba.in_proj:0:nosrc, and declaresconv1d/x_proj.0/dt_proj.0:!— exactly the tree correction the issue prescribed.Measured on the synthetic replica built from the declared names: on
mainthe group wasinput_layernorm -> [mamba.in_proj, gate_proj, up_proj]and folding a random scale changed the logits by 3.3e-2 (layer 0) / 2.5e-2 (layer 1); with the fix the groups areinput_layernorm -> [in_proj],pre_moe_layernorm -> [gate_proj, up_proj](+moe.gateas a scale consumer),up_proj -> [down_proj], and every fold measures < 1e-7. New test file: 6 failed / 1 passed onmain-> 7 passed. Neighbouring AWQ group suites keep the same failure set on both trees (afmoe/flint/granite, pre-existing on this host).Verification boundary: no
nvidia/Hymba-1.5B-Basecheckpoint, no cached remote code, and nomamba_ssm/causal_conv1don this host, so real-weightquantize()was not validated. A host with the model should re-run the issue's repro and confirm the three groups above.#4888 (the half-precision load half of the report) landed separately in #5021; this fix does not touch it.
Merge origin/main into transformers5-local-models
Port every supported model onto the Transformers 5.23 ABI; never patc…