Repository navigation
[Bugfix][GLM-5.3-Flash] Honor --mamba-ssm-cache-dtype for the KDA recurrent state - #59147
Conversation
…urrent state Glm5Next's KDA layer and model class call kda_state_dtype() without the ssm cache dtype, so the recurrent state is always float32 and --mamba-ssm-cache-dtype bfloat16 is silently ignored. Pass it through the same way Kimi-K3 does. With bfloat16 the state page halves (attention block 2304 -> 1280 tokens at TP2), which is what bounds decode-instance concurrency with spec decoding. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jared Wen <jaredwen@inferact.ai>
lesj0610
left a comment
There was a problem hiding this comment.
LGTM. The model and layer now agree on the requested recurrent-state dtype, and the default remains FP32. The auto, FP32, and BF16 dtype tests pass.
|
I think this is a good feature for performance. We also enable --mamba-ssm-cache-dtype bfloat16 for Kimi K3. cc @ZJY0516 |
|
I tested the same change (the same two call sites, as a local patch) on nightly Setup: GLM-5.3-Flash, 4× B200, TP1 × DP4 + EP, FP8 KV cache, MTP K=5, Startup, per rank:
InferenceX AgentX trace replay (aiperf), 96 concurrent sessions, 3,600 s, mean prompt about 120K tokens:
Accuracy, with real MTP acceptance:
The throughput arms used synthetic acceptance (length 3.61). The measurements were run with AI assistance (Claude Code). |
|
I'm okay to change it, but according to my experience, it will have accuracy issue when using bf16 |
|
✅ @JaredforReal, CI is now available for this PR.
|
|
/ci run |
|
✅ Triggered Buildkite CI #94083 for commit |
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes correctly use the existing KDA dtype API and include appropriate regression coverage.
0 open findings
What changed in this PR
Fixes GLM-5.3-Flash KDA recurrent-state dtype selection to honor the configured SSM cache dtype.
Changes:
- Passes
mamba_ssm_cache_dtypethrough model- and layer-level dtype calculation. - Adds coverage for automatic, float32, and bfloat16 configurations.
| File | Description |
|---|---|
vllm/models/glm5next/common/model.py |
Propagates the configured SSM cache dtype at model level. |
vllm/models/glm5next/common/kda.py |
Propagates the dtype when constructing KDA layers. |
tests/models/glm5next/test_kda_state_dtype.py |
Verifies consistent dtype selection across model wrappers and layers. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
…ecurrent state (vllm-project#59147) Signed-off-by: Jared Wen <jaredwen@inferact.ai> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
Purpose
Glm5NextLinearAttention.get_state_dtype()andGlm5NextForCausalLM.get_mamba_state_dtype_from_config()callMambaStateDtypeCalculator.kda_state_dtype()without the SSM cache dtype. As a result, the KDA recurrent state is always float32, and--mamba-ssm-cache-dtype bfloat16is silently ignored for GLM-5.3-Flash. Kimi-K3's KDA already passes it through.This PR passes
cache_config.mamba_ssm_cache_dtypein both places.Glm5NextForConditionalGenerationdelegates to the causal-LM class, so it is fixed too.Why it matters: with bfloat16 the recurrent state page halves. Mamba align-mode prefix caching sizes the attention block from that page, so at TP2 the block shrinks from 2304 to 1280 tokens. With speculative decoding, each running request holds
2 + num_speculative_tokensstate blocks per group, so on decode instances this state is what bounds concurrency.Test Plan
tests/models/glm5next/test_kda_state_dtype.py:auto/float32/bfloat16must reach both the model-level and the layer-level recurrent-state dtype;tests/models/glm5next.--mamba-ssm-cache-dtype bfloat16:Test Result
tests/models/glm5next: 14 passed.AI assistance (Claude) was used; every line was reviewed and the tests above were run by the submitter.