Conversation
GLM-5.3-Flash's norope MLA layers set qk_rope_head_dim=0 and pass no RoPE tail, but _concat_and_cast_mha_k_rocm always allocates a qk_head_dim-wide buffer and appends k_pe. On the aiter backend the Triton concat kernel is handed a None/zero-width k_pe; on the fallback branch the slice assignment is a no-op that still costs an allocation and a copy. Mirror the CUDA path in forward_mha.py, which already returns k_nope directly when qk_rope_head_dim == 0. No cast is needed on ROCm because the concat branch keeps k_nope's dtype. Recovers sgl-project#37530, which GitHub closed when its base branch xinyuan/glm-5.3-flash-support was merged into main, and supersedes the sgl-project#38541 replacement.
This was referenced Sep 14, 2026
Jacob0226
marked this pull request as ready for review
September 14, 2026 07:56
This was referenced Sep 14, 2026
Open
Jacob0226
requested review from
Fridge003,
ch-wan,
fzyzcjy and
ispobock
as code owners
September 15, 2026 06:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GLM-5.3-Flash's full-attention layers are norope (
qk_rope_head_dim == 0), sok_pereaches_concat_and_cast_mha_k_rocmasNoneor zero-width tensor while the helper still allocates aqk_head_dim-widekand appends it. So, this PR returnsk_nopedirectly.k_peattention_backendNoneaiterlen(k_rope.shape)→ AttributeErrork_nopeNonek[..., self.qk_nope_head_dim:] = k_pe→ TypeErrork_nopeaiterk_nopek[..., self.qk_nope_head_dim:] = k_pe→ TypeErrork_nopeScope
forward_mha_rocm.pyonly. CUDA and every other backend are untouched. ROCm models withqk_rope_head_dim > 0— DeepSeek V3/R1, the roped GLM-5.x MLA layers — never reach the guard and keep current behaviour. No new environment variable, no architecture gate, no dispatch change.k_pewidens totorch.Tensor | Noneto match the CUDA signature.On MI355X this is the default short-prefill path, not an edge case:
handle_attention_dsabackend.use_mhaHybridLinearAttnBackend.use_mhaDeepseekSparseAttnBackend.set_dsa_prefill_implTrueon_IS_GFX95, listed beside SM90/SM100, whenmax_kv_len <= SGLANG_DSA_PREFILL_DENSE_ATTN_KV_LEN_THRESHOLD(2048)resolve_rocm_forward_methodMHA_ONE_SHOT→MHA_ONE_SHOT_ROCMforward_normal_one_shot_rocm_prepare_concat_and_cast_mha_k_rocm(k_nope, k_pe)kin the KV-pool dtype forfa3on an FP8 KV cache; the ROCm branch isk_nope.new_empty(*k_shape)with no override, sok_nope.contiguous()is dtype-identical to what it would have builtTest plan
Unit base
rocm/sgl-dev:v0.5.18-rocm720-mi35x-20260901, the image familypr-test-amd-rocm720.ymlresolves to, onxinyuan/glm-5.3-flash-support@515e865189with no other PRs applied. Both builds run the same test file; the guard is the only variable.cd test && python3 registered/unit/models/test_nope_mha_k_cast.py.Nonecases and zero-width onaiterfailZero-width on the non-
aiterbackend passes either way, per the Summary table's last row; it is kept so both backends are pinned to one behaviour rather than one of them resting on that accident.End to end, since no single PR here can serve the model on its own:
mainplus the eight open Day-0 PRs — #39338, #39339, #39340, #39341, #38545, #38546, #38547 and #39317 — which all merge cleanly onto it.rocm/sgl-dev:v0.5.19-rocm720-mi35x-20260909, MI355X TP4, decode CUDA graphs on, 1,319 GSM8K examples, one scoring pass each. Only the checkpoint differs between the two rows:zai-org/GLM-5.3-Flash, block FP8amd/GLM-5.3-Flash-Quark-MXFP4Accuracy: not attributable to this PR in isolation, and there is no standalone baseline — GLM-5.3-Flash does not start on ROCm without the rest of the stack.
register_cpu_ci(suite="base-a-test-cpu"), unchanged — the four cases are mocked and GPU-free, and this change removes a kernel call rather than adding onepre-commitvalidate registered test CI registriesreports the same 582 pre-existing taxonomy violations as pristinemain, i.e. none addedCI States
Latest PR Test (Base): ❌ Run #34937435623
Latest PR Test (Extra): ❌ Run #34937435289
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.