Skip to content

[BUG] #5019 (fix of #4891) incomplete: Hymba AWQ still always crashes on the real checkpoint at layer 2 - HymbaBlock replay lacks kv_last_layer for KV-reuse layers (AssertionError, no fallback) #5098

Closed

Description

@Qubitium

Found on main @ e75181d, AMD R9700 (ROCm 10.1, free-threaded 3.14t), real nvidia/Hymba-1.5B-Base weights.

What is wrong

#5019 (fix of #4891) made the mamba (HymbaBlock) replay receive the captured kwargs through its **kwargs. It was verified only on a synthetic fixture: the commit message says real Hymba weights were not available. On the real checkpoint, AWQ still aborts, now at layer 2:

File "gptqmodel/looper/awq_processor.py", line 3479, in _search_best_scale
File "gptqmodel/looper/awq_processor.py", line 4039, in _build_chunked_reference_outputs
File "gptqmodel/looper/awq_processor.py", line 4816, in _iter_prepared_forward_outputs
    module_output = module(x, **module_kwargs)
File "modeling_hymba.py", line 1744, in forward        # HymbaBlock
File "modeling_hymba.py", line 1653, in cuda_kernels_forward
    assert kv_last_layer is not None
AssertionError

Every Hymba checkpoint shares KV across layers (kv_reuse_group = [[1,2],[3,4],...,[16,17,18],...], 15 consumer layers out of 32). A consumer's HymbaBlock needs the producer layer's KV as kv_last_layer. The decoder-layer forward gets it from ForwardExecutor (looper/forward_executor.py:453-454, additional_inputs["kv_last_layer"] = prev_kv, enabled by HymbaQModel.write_shared_kv_cache = True). That value is injected only into the layer forward and is never part of the cached layer kwargs the AWQ scale search replays. So the input_layernorm -> mamba.in_proj group, whose replay boundary is the whole mamba block, calls HymbaBlock(x, **captured_kwargs) without kv_last_layer.

The crash is an AssertionError, not _AWQScaleGroupError, so the configured fallback never runs and quantize() dies. GPTQ and RTN on the same checkpoint succeed (RTN wikitext PPL 9.23 after save/reload; GPTQ runs past every reuse layer), because they only use the forward-executor path.

The 2-layer slice used to check #5019 has no reuse group, which is why it passes:

2-layer slice (kv_reuse_group=[]): AWQ OK, groups input_layernorm->[mamba.in_proj], pre_moe_layernorm->[experts.0.gate/up], up->down
full 32-layer model:               AWQ AssertionError in layer 2 (first kv_reuse consumer)

Repro

# nvidia/Hymba-1.5B-Base, attn_implementation "sdpa", batch_size=1 (Hymba's remote mask code cannot pad)
q = GPTQModel.load(path, AWQConfig(bits=4, group_size=128), dtype=torch.bfloat16, trust_remote_code=True)
q.quantize(CalibrationConfig(dataset=c4_128_rows, batch_size=1))
# INFO  AWQProcessor: layer 2 sanitized 3 scaling groups; sample=[['mamba.in_proj'], ['moe.experts.0.gate_proj', 'moe.experts.0.up_proj'], ['moe.experts.0.down_proj']]
# -> AssertionError (assert kv_last_layer is not None)

Suggested fix

Either:

  • thread the producer KV into the AWQ replay kwargs for reuse layers, the same way ForwardExecutor does. It has to be packed or sliced per replayed row, since kv_last_layer is token-aligned ([b, heads, seq, d]) and the token-row packing changes the row layout; or
  • for Hymba, score input_layernorm -> mamba.in_proj on in_proj alone instead of the whole HymbaBlock. in_proj is linear, and the block output is not needed to rank the scale.

In both cases, wrap module-replay failures in _AWQScaleGroupError so a replay that cannot run falls back instead of aborting the whole run.

Test that should have caught it

tests/test_hymba_awq_4891.py builds layers without KV reuse. It needs a fixture with kv_reuse_group (a reuse consumer layer), or an end-to-end run on a 3-layer slice of the real config (kv_reuse_group=[[1,2]]).

Severity

AWQ on any real Hymba (Base/Instruct, and the BKE variants) still always crashes. #4891 is not fixed for actual checkpoints.

🤖 Generated with Claude Code

Activity

  1. ZX-ModelCloud commented on Nov 18, 2026

    @ZX-ModelCloud
    Collaborator

    Agent claim released: agent-e6fed67d3888 finished this issue.

    Pull request: #5172

    Reproducing Hymba AWQ KV-reuse replay crash on the real checkpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions