Repository navigation
[AMD] [GLM-5.3-Flash Day 0] Route mHC through AITER on gfx950 - #37626
Closed
Raiden-Makoto wants to merge 4 commits into
Closed
Raiden-Makoto wants to merge 4 commits into
Raiden-Makoto wants to merge 4 commits into
Conversation
Route GLM-5.3-Flash mHC through AITER with safe Torch fallback and add isolated production-dimension and checkpoint-driven coverage.
Raiden-Makoto
marked this pull request as ready for review
September 2, 2026 18:38
Raiden-Makoto
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
September 2, 2026 18:38
The k-pool indexer is CUDA-only end to end. forward_cuda raises
NotImplementedError off CUDA, the paged (decode) path picks between a
tilelang kernel whose selector returns False off CUDA and DeepGEMM, and
the ragged (prefill) path calls deep_gemm.fp8_mqa_logits directly.
DeepGEMM has no ROCm build, so GLM-5.3-Flash cannot start.
Open the forward gate to HIP and route both logits paths to AITER:
- paged: aiter_paged_mqa_logits(..., preshuffle=True), resolved through
DSAPagedMQALogitsBackend so --dsa-paged-mqa-logits-backend reaches
this path rather than branching on is_hip() at the call site.
resolve() already pins ROCm to AITER.
- ragged: _fp8_mqa_logits() picks aiter.ops.triton.fp8_mqa_logits on
HIP. It takes the fp8 values and scales as separate arguments where
DeepGEMM takes a tuple.
AITER's paged kernel reads the index-K cache in a 16x16 tile order, so
kpool_fp8_index has to write it that way. The four write kernels and the
one read kernel now share _kpool_cache_k_offsets, which follows
_set_k_and_s_triton_kernel in index_buf_accessor.py -- the non-pooled
indexer already lays its cache out this way for the same AITER kernel,
and the two must agree.
aiter_paged_mqa_logits inserts the next_n dim itself, so q_fp8 stays
[tokens, heads, dim] through the dispatch and the tilelang and DeepGEMM
branches unsqueeze at their own call sites.
Add layout coverage. A write/read disagreement here does not raise, it
silently returns the wrong top-k, so the offsets are pinned against an
independent reference, checked for collisions, and round-tripped through
the reader. The round trip follows the runtime tile rather than pinning
16, so it also holds on a build without AITER's preshuffle kernel.
Co-authored-by: Cursor <[email protected]>
Raiden-Makoto
requested review from
1am9trash,
Fridge003,
YAMY1234,
hubertlu-tw,
kkHuang-amd and
rainj-me
as code owners
September 3, 2026 15:27
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 uses mHC in all 45 decoder layers (
hc_mult=4,hidden_size=4096). The support branch already carries the flattened mHC state contract andMHCLayerCommunicator, buthc_preandhc_posthave no AITER dispatch: enablingSGLANG_USE_AITER=1still leaves them on TileLang when its flags are set, or on the Torch fallback otherwise.This is a Day-0 correctness blocker on gfx950, not a performance-only path. Every attention and FFN sublayer crosses an mHC pre/post boundary before DSA, KDA, or MoE can produce a model output.
SGLANG_USE_AITER=1aiter.ops.mhc.mhc_pre/mhc_postThe AITER imports stay lazy because this module is imported during model-registry discovery. No AITER symbol is required until the gfx950 runtime actually selects this backend.
Scope
python/sglang/kernels/ops/layernorm/mhc.pyis the only production file changed.The fused
mhc_post_preboundary is intentionally untouched. It is a later launch-fusion optimization; this PR enables the standalonemhc_post -> mhc_presequence required for correctness. DSA, k-pool, MLA, MoE, CUDA graphs, and full-model serving are outside this PR.Test plan
Docker:
rocm/sgl-dev:v0.5.18-rocm720-mi35x-20260901.Base:
xinyuan/glm-5.3-flash-support@545bd6f839.The same three test files were run in both arms;
mhc.pyis the only variable._try_aiter_mhc_pre/_try_aiter_mhc_postdo not exist. The checkpoint-only tensor audit passes.The gfx950 arm covers production
hidden_size=4096,hc_mult=4, token counts 0/1/8/17/32/64/128, 2 and 20 Sinkhorn iterations, norm fused/unfused, deterministic replay, and the complete attention-to-FFN pre/post flow.The checkpoint arm uses
zai-org/GLM-5.3-Flashandamd/GLM-5.3-Flash-Quark-MXFP4@b5688f2549without loading either model. It verifies all 270 mHC tensors are complete and byte-identical, runs every real attention and FFN parameter set across layers 0-44 through AITER against the Torch oracle, and runs the complete two-sublayer flow for every layer.register_cpu_ci(suite="base-a-test-cpu"); gfx950 coverage usesregister_amd_ci(suite="stage-b-test-1-gpu-small-amd-mi35x")pre-commitCI States
Latest PR Test (Base): ❌ Run #33835290186
Latest PR Test (Extra): ❌ Run #33835290053
Latest PR Test (AMD ROCm 7.2): ❌ Run #33835290197