Repository navigation
feat(plugins): GLM-5.2 MLA absorb decode ops (qkv_a + norms, KC+RoPE+FP8 cache, VC) on forward_absorb_rocm_prepare and _core - #49
Merged
Conversation
irvineoy
had a problem deploying
to
gpu-trusted
November 5, 2026 01:48 — with
GitHub Actions
Failure
irvineoy
had a problem deploying
to
gpu-trusted
November 5, 2026 08:42 — with
GitHub Actions
Failure
irvineoy
had a problem deploying
to
gpu-trusted
November 6, 2026 03:05 — with
GitHub Actions
Failure
irvineoy
had a problem deploying
to
gpu-trusted
November 6, 2026 03:37 — with
GitHub Actions
Failure
irvineoy
marked this pull request as ready for review
November 9, 2026 19:12
irvineoy
requested review from
RuibinCheung,
jiejingzhangamd,
kyle-256,
xiaobochen-amd and
zhenhuang12
as code owners
November 9, 2026 19:12
zhenhuang12
reviewed
Nov 10, 2026
irvineoy
had a problem deploying
to
gpu-trusted
November 10, 2026 02:29 — with
GitHub Actions
Failure
irvineoy
had a problem deploying
to
gpu-trusted
November 10, 2026 02:50 — with
GitHub Actions
Failure
zhenhuang12
force-pushed
the
feat/glm52-mla-absorb-decode
branch
from
November 16, 2026 06:27
39a2a46 to
506786d
Compare
zhenhuang12
temporarily deployed
to
gpu-trusted
November 16, 2026 06:29 — with
GitHub Actions
Inactive
ChengYao-amd
added a commit
that referenced
this pull request
Nov 16, 2026
…-fp8-qkv-a-norm Keeps #49's deepseek_common package as 506786d has it (the two mla_vc schemas it dropped stay dropped) with this branch's mla_qkv_a_norm_fp8 additions; cases.py takes main's new contract ids and this branch's small Point; names.txt regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…FP8 cache, VC) on forward_absorb_rocm_prepare and _core Squashed onto main from: - feat(plugins): MLA absorb KC+RoPE+FP8 cache and VC ops on forward_absorb_rocm_core - fix(plugins): declare the MLA absorb ops' w_scale as one element, not 0-d - fix(plugins): keep the MLA absorb kernels CI measured faster; VC bound for fp8 MFMA sums - docs(plugins): mla_vc bound comment: 21 of 108 input sets failed, not 22 of 102 - feat(plugins): MLA qkv_a projection and latent RMSNorms op on forward_absorb_rocm_prepare - feat(plugins): GLM-5.2 qkv_a projection and latent RMSNorm decode kernels for mla_qkv_a_norm - fix(plugins): drop the TP8 mla_vc schema at 1 token, not faster than sglang - fix(plugins): drop the TP4 mla_kc_rope_cache schema at 64 tokens, not faster than sglang - fix(plugins): keep mla_kc_rope_cache only at TP4 256 tokens, where it beats the qkv_a op it displaces - refactor(plugins): rename the forward_mla_rocm package to deepseek_common - fix(deepseek_common): drop the two mla_vc schemas below the 1.05 bar
zhenhuang12
force-pushed
the
feat/glm52-mla-absorb-decode
branch
from
November 18, 2026 01:27
506786d to
40c576c
Compare
zhenhuang12
had a problem deploying
to
gpu-trusted
November 18, 2026 01:29 — with
GitHub Actions
Error
Resolve tests/plugins/sglang/cases.py and names.txt: main's [email protected] entries (#224) and this branch's three MLA entries are all kept. SMALL_POINTS takes main's Point after this branch's; names.txt keeps contract_id order, the order the snapshot test writes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI run 44219495647 benched both under the 1.05 bar, accuracy ok: e63ffb3a (TP4, 1 token) at 1.03x and 82c901b6 (TP4, 2 tokens) just under 1.05. Run 43385074220 had them at 1.12x and 1.06x. KC serves only TP4 256 tokens, so the core route now leaves TP4 decodes of 1 and 2 tokens to sglang; the other 25 schemas are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's #253 moved CI to sglang 0.5.23, and test_hook requires every route to declare the installed release. forward_mla_rocm.py is the same file in 0.5.22 and 0.5.23, so forward_absorb_rocm_prepare and forward_absorb_rocm_core, the helpers the routes call and the attributes they read are unchanged. The other names the routes import are kept: get_is_capture_mode, get_forward, get_lora, get_token_to_kv_pool and UnquantizedLinearMethod, whose apply changed only on its cutedsl/gemv branch. A decode that 0.5.23 relabels a one-token extend under DP attention fails the core route's mode check and stays on sglang. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
|
@irvineoy this PR conflicts with the latest |
Main moved from a65066c to 7e9cff8, ten commits, among them #253 (sglang 0.5.23, which bcf2f95 already declares), #257 (the GPU jobs run on the aklr-safe runner) and #252 (a tighter tests layout check). Nothing conflicts. CI run 44255030975 on bcf2f95 started on the old runner setup and its GPU prepare job is still queued, so this head's run is the branch's first on aklr-safe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI run 44296931687, the branch's first on sglang 0.5.23 and aiter v0.1.29, benched 95c7c556 at 1.04x, accuracy ok. It had measured 1.09x in run 44219495647. The 1-token Point stays served by the TP4-tuned c609a440, at 1.12x in the same run. The other 24 schemas passed and all 26 workloads were accurate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kyle-256
approved these changes
Nov 19, 2026
ChengYao-amd
added a commit
that referenced
this pull request
Nov 19, 2026
models/deepseek_common is main's (#49 as squash-merged and remeasured by the bot), with this branch's own changes reapplied on it: the block-fp8 branch of the qkv_a prepare route and the mla_qkv_a_norm_fp8 op, contract, baseline, reference, schema, cases and names. The prepare and core routes keep main's sglang 0.5.22 / 0.5.23 declaration; forward_mla_rocm, q_b_proj_forward and the block-fp8 linear's tuple input are unchanged in 0.5.23. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ChengYao-amd
added a commit
that referenced
this pull request
Nov 24, 2026
main's #318 dropped forward_absorb_rocm_core's route and moved mla_kc_rope_cache and mla_vc to aklr/ops/mla_absorb; the prepare route no longer yields to the core. deepseek_common takes main's files with this PR's block-fp8 branch on top (mla_qkv_a_norm_fp8: contract, reference, baseline, api, the prepare route's _block_fp8 selection). Three schemas #49 dropped before it merged (mla_qkv_a_norm 95c7c556, mla_vc 82c901b6 and e63ffb3a) leave this branch as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
This PR has two parts: Part 1, the KC + RoPE + FP8 cache and VC ops on
forward_absorb_rocm_core, and Part 2, the qkv_a projection and latent RMSNorms op onforward_absorb_rocm_prepare(the last section).Why
GLM-5.2's decode on gfx950 runs two absorbed-MLA steps around each attention: the query absorb through
w_kcfused with RoPE and the fp8 KV-cache write (sglang 0.5.22's_fused_bmm_rope_cat_and_cache), andthe value absorb through
w_vc(rocm_absorb_v_bmm). This adds an op for each, with decode kernelscreated by OpenAI for GLM-5.2 at TP4 and TP8, and one route on
forward_absorb_rocm_corethat calls them.Scope
New plugin package
aklr/plugins/sglang/models/deepseek_common/, named after the sglang package itsroutes plug into,
sglang.srt.models.deepseek_common(forward_mla_rocmuntil636710a); it sits directly undermodels/becausepyproject.tomlships only*/*/*/impls/*/*/*.json. Contracts[email protected](q absorb with per-128-group fp8 activations, GPT-J RoPE, fp8 KV write; slot-0rows are padding) and
[email protected](value absorb into a bf16 o_proj input), with reference, baseline,api and route.
7 Triton (Gluon) schemas for gfx950, 8 exact Points:
mla_kc_rope_cache: TP4 (16 heads) at n_tokens 256;mla_vc: TP4 at 4, 8, 128, 256; TP8 at 2, 4, 256.34 schemas were ported (1 to 256 tokens). CI benched them all, and 27 are left out (see Verification):
c1214b9). They beat sglang, but where KC serves, Part 2'sqkv_a op does not, and that op saves more there (Tradeoffs);
bar (
e305682);667ccfa).At those token counts the route leaves the step to sglang, or to Part 2.
The route replaces
DeepseekMLARocmForwardMixin.forward_absorb_rocm_coreon sglang 0.5.22 and 0.5.23 for thebranch where prepare leaves the q absorb to core (
q_nope_unabsorbed: decode or target verify on theDSA backend's fused gfx950 path): the KC op instead of
_fused_bmm_rope_cat_and_cache, sglang'sattention, the VC op instead of
rocm_absorb_v_bmm, theno_proj. Every other branch, and any stepwhose op declines (no schema for the call's token count included), stays on sglang. Deferred: the
qkv_a projection + norms op, which needs a route on
forward_absorb_rocm_prepare; prefill andspeculative-prefill kernels.
Tradeoffs
q_catin fp8, as sglang 0.5.22's fused path does (q_out_dtypeis the pool's dtype). Thekernels compute it in bf16, and
runrounds it with one elementwise copy, which the bench times.Below 128 tokens, sglang's one fused aiter launch (BMM, RoPE and KV write) beat these kernels (speedup
lower bounds 0.51 to 0.90). TP4's 64-token kernel sat at the edge: it measured 1.06, 1.06 and then 0.95
in three runs.
At TP4 128 and TP8 128/256 the kernels beat sglang (lower bounds 1.07 to 1.49). But wherever KC serves, the
prepare route keeps sglang's prepare, so Part 2's qkv_a op does not run, and with a bf16 qkv_a projection
that op saves more. By CI's graph-mode medians (runs 41962335788 and 41982390802):
With a block-fp8 qkv_a projection (GLM-5.2-FP8) the qkv_a op never serves, so those three calls go back
to sglang's fused KC path. The op cannot tell the two checkpoints apart.
minimax_m2's_fp8_lineardoes), in float32 as the kernels do. Its codes are the kernels' bit forbit, so the bounds stay tight.
mla_vc's absolute tolerance is 2^-9, not 2^-12. gfx950's fp8 MFMA sums below fp32, and that errorshows only where an output cancels to near 0 (see Verification).
k_pe, a strided view that dispatch woulddecline; the route rebuilds the contiguous latent from
k_pewithout a copy.q_cat.sglang's kernel writes slot 0 and a query row for them, neither read by any request.
Verification
Environment: head
3350a63. Its CPU checks ran in a Linux container (Python 3.12.16, torch 2.14.1 CPU),as did those at
8f37c2fand from7a12633toad5fc11; those atbcf2f95and the earlier ones ran onmacOS.
GPU validation is this head's CI run 44350793689 with
ci:gpu(MI355X, the CI image: audit + bench against the baseline, and the GPU unit tests).Gate overrides: none
CI run 44350793689 on
3350a63the 25 workloads were accurate, at 1.09x to 2.14x (median 1.12x). KC at 2.14x, VC at 1.09x to 1.34x
(
ef12e987at 1.11x over its two workloads), the qkv_a schemas (Part 2) at 1.09x to 1.16x. Nearest the bar:VC
40cc2f0eand qkv_a780911bcand1db97c67, each at 1.09x.tests/ops/test_sparse_prefill_reference.py::test_csr_prefill_repeated_calls_are_bitwise, themla_prefillHIP kernel's bitwise-repeatability check (mla_prefill HIP kernel (sparse_prefill_mxfp8_n_heads128) is intermittently not bitwise-repeatable #205, closed after fix(mla_prefill): synchronize tail partial publication #217), which failed the same way in about 40% of
PR runs on 2026-11-18, on every
aklr-saferunner. coverage-report failed only because aiter-test did. Thefailed jobs were re-run (attempt 2).
CI bench on
8f37c2f, fixed in3350a638f37c2f, the branch's first on sglang 0.5.23 and aiter v0.1.29, passed the GPU unittests (239 passed, 4 skipped) and benched the 25 schemas. All 26 workloads were accurate: KC at 2.13x, VC at
1.05x to 1.31x, the qkv_a schemas (Part 2) at 1.06x to 1.16x. One fell under 1.05:
95c7c556, Part 2'sTP8-tuned kernel for 1 token, at 1.04x (1.09x in run 44219495647).
3350a63removes it, which leaves 24schemas. The 1-token Point stays served by the TP4-tuned
c609a440, at 1.12x in the same run. Nearest the barthen: VC
ef12e987, whose two workloads (2 and 4 tokens) measured 1.05x and 1.10x, and qkv_a780911bcat1.06x.
3350a63, which already holds main7e9cff8, in the Linux container:pre-commitover CI's code-lint range: passed;aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 358 passed, 129 skipped, 7 failed (the 7 as at8f37c2f);tests/: 11 failed, the same IDs as main7e9cff8's, all environment-only.Main
7e9cff8merged in8f37c2f8f37c2fmerges main7e9cff8, ten commits sincea65066c; nothing conflicts. Among them are #253 (sglang0.5.23, which
bcf2f95already declares), #257 (the GPU jobs run on theaklr-saferunner) and #252 (a tightertests layout check). CI run 44255030975 on
bcf2f95started on the old runner setup and its GPUpreparejobnever left the queue, so this head's CI run is the branch's first on
aklr-safeand its first on sglang 0.5.23.8f37c2f, in a Linux container again:pre-commitover CI's code-lint range (7e9cff8..8f37c2f), fix(tests): restore the run-image mock, tighten approx and the layout check #252's tests layout check included: passed;aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 358 passed, 129 skipped, 7 failed (see the next line);tests/: 11 failed, the same IDs as main7e9cff8's, all environment-only. Seven are intest_aiter_backend_mla_prefill.pyand calltorch.cuda.is_current_stream_capturing(), which CPU torchcannot run.
CI bench on
ad5fc11, fixed in667ccfa; sglang 0.5.23 declared inbcf2f95ad5fc11(maina65066c) benched the 27 schemas. All 28 workloads were accurate:KC at 2.10x, VC at 1.11x to 1.26x, the qkv_a schemas (Part 2) at 1.09x to 1.31x. Two single-workload TP4 VC
schemas fell under 1.05:
e63ffb3a(1 token) at 1.03x and82c901b6(2 tokens) just under 1.05. They hadmeasured 1.12x and 1.06x in run 43385074220.
667ccfaremoves both, which leaves 25 schemas. KC serves only256 tokens, so the core route now leaves TP4 decodes of 1 and 2 tokens to sglang.
bcf2f95declares sglang 0.5.23 on both routes. Main's chore(stack): sglang 0.5.23, vLLM 0.34.0, aiter v0.1.29 #253 moved CI to sglang 0.5.23, andtest_hook.pyfails a route that does not declare the installed release.forward_mla_rocm.pyis the samefile in v0.5.22 and v0.5.23, so the two methods, the helpers the routes call and the attributes they read
are unchanged. The other names the routes import are kept:
get_is_capture_mode,get_forward,get_lora,get_token_to_kv_pool, andUnquantizedLinearMethod, whoseapplychanged only on its cutedsl/gemvbranch. Its CI run did not get a GPU (see the merge above).
bcf2f95, merged locally with mainae03491, on macOS this time:pre-commitover CI's code-lint range: passed (shellcheck skipped: it does not build on macOS, and noshell script changed);
aklr export checkexits 0;pytestontests/core/contract/test_schema.py,tests/core/contract/test_export.py,tests/core/runtime/test_dispatch.pyandtests/ops/test_contracts.py: 169 passed, 2 skipped, 1 failed.The failure,
test_dispatch.py's[0.3.2-True], is environment-only: main fails it too in the Linuxcontainer. The whole
tests/did not run.Main
a65066cmerged inad5fc11The branch is now one commit: it was squashed and rebased onto main, as
506786don78496c0and then40c576cone193b1d, andgit range-diffshows that commit unchanged. Commit IDs further down are from thebranch before the squash.
ad5fc11merges maina65066c, #224 (Kimi-K3.1-Pro kernels for sglang 0.5.24). Both conflicts were lists intests/plugins/sglang:SMALL_POINTSincases.pyandnames.txt. Main's[email protected]entries andthis branch's three are all kept,
names.txtin contract_id order. #224's[email protected]route takesrocm_absorb_v_bmmon bf16 weights at unit scale and is declared only for sglang0.5.24.dev809. This branch'sroutes are declared for
0.5.22, and itsmla_vctakes GLM-5.2's fp8w_vcwith its scale. Where thisbranch's core route leaves the value absorb to sglang, it calls
rocm_absorb_v_bmm.506786dfailed one GPU unit test,test_backend_matches_referencefor[email protected], and so skipped the bench. That failure came from main: fix(semantics): draw distinct int_range values from keys that cannot tie #196changed how that op's test inputs are drawn, and main's fix(plugins): widen Qwen3-Next GDN prefill's delta_state bound to 4e-2 #235 widened the bound. Run 44215966998 on
40c576cwas still waiting for a GPU when main moved.ad5fc11:pre-commitover CI's code-lint range (a65066c..ad5fc11): passed;aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 343 passed, 132 skipped, 7 failed (see the next line);tests/: 11 failed, the same IDs as maina65066c's, all environment-only. Seven are intest_aiter_backend_mla_prefill.pyand calltorch.cuda.is_current_stream_capturing(), which CPU torchcannot run.
Main
1541453merged in39a2a4639a2a46merges main1541453: six commits sincee1a83d3, among them #155 (the hsaco kernel language) and#142 (Qwen3.5 prefill). The one conflict was
GFX950_CONTRACT_IDSintests/plugins/sglang/cases.py: main'stwo
gated_attention_prefillentries and this branch's three are all kept. Since #155,kernel.requiresnames the toolchain a language needs; for Triton that is still
triton, which every schema here names.e305682(main24f36f2) passed. All 28 workloads of the 27 schemas wereaccurate: KC at 2.13x, VC at 1.06x to 1.30x, the qkv_a schemas (Part 2) at 1.07x to 1.54x. The one
workload the bench demoted (
not_faster, under 1.05, shown as 1.05x) is one of TP8 VCef12e987's two(2 and 4 tokens); the schema passed on the other. Run 43372796649 had the two at 1.11x to 1.13x.
39a2a46:pre-commitover CI's code-lint range, ruff 0.15.12 included: passed;aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 284 passed, 109 skipped;tests/: 5 failed, the same IDs as main1541453's, all environment-only.CI bench on
7a12633, fixed ine3056827a12633merges maine1a83d3, which raises the bench's admission bar from 1.02 to 1.05 (#153). Intests/plugins/sglang/cases.py, main's new Points and this branch's three are all kept. Every schema herealready states
kernel.requires(triton >=3.8), which main now checks.CI run 43372796649 (MI355X) benched both parts' 29 schemas, 30 workloads. All passed accuracy with no
violation, and 27 schemas reached 1.05.
0a9f1be8b037e8c0) at 1.03x and TP8's 8-token VC (7f9358af6c7aed80)at 1.04x. Run 42592557691 had them at 1.06x and 1.12x on another machine, so both sit near the bar.
e305682removes them; at those token counts the core route leaves the value absorb to sglang'srocm_absorb_v_bmm, and the other ops are unchanged.e305682, merged with main24f36f2:pre-commitover CI's code-lint range, ruff 0.15.12 included: passed;aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 263 passed, 106 skipped;tests/: 5 failed, the same IDs as main24f36f2's, all environment-only.KC narrowed to TP4 256 in
c1214b9c1214b9removes the TP4 128-token KC schema (886370eeed62a426) and the TP8 128/256-token one(
42afc2f3bee9d95e), for the trade-off in Tradeoffs. Nothing else changes.CPU checks at
c1214b9:aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 185 passed, 66 skipped;tests/adds no failure to main0f2036b's environment-only set.CI bench on
bdc1040, fixed ine7eecea; main merged in0215664CI run 41986682790 (MI355X) benched both parts' 32 schemas, 34 workloads. All passed accuracy with no violation, and 33
were faster than sglang.
6fb7c735f980baaa), at 0.98x with a lower bound of 0.95. It had measured1.06x twice before, so it sits at the edge.
e7eecearemoves it. At 64 tokens, Part 2's qkv_a op (1.50x to 1.53xin this run) now serves the step, and sglang's fused KC path follows.
0215664merges main0f2036b. Intests/plugins/sglang/cases.pyandnames.txt, main'snew cases and this branch's three are all kept, and
names.txtis regenerated.0215664:aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 185 passed, 66 skipped;tests/adds no failure to main0f2036b's environment-only set.CI bench on
e5f4148, fixed inbdc1040CI run 41982390802 (MI355X) benched both parts' 33 schemas, 35 workloads. All passed accuracy with no violation,
VC under its new absolute tolerance of 2^-9 included, and 34 were faster than sglang.
ed7ce19b08587aca): 1.01x, with a lower bound of 1.0009, under the 1.02 gate.bdc1040removes it, so a 1-token call at TP8 stays on sglang's batched GEMM.1.54x (lower bounds 1.09 to 1.54). Per-Point numbers are in the Kernels tables.
bdc1040:aklr export checkexits 0;pytest tests/plugins/sglang tests/ops: 167 passed, 55 skipped;tests/fails a subset of main's failures: 49 failed and 1 collection error, allenvironment-only.
CI bench on
f2393aa, fixed in5a90b0eCI run 41962335788 (MI355X) benched 36 workloads in 34 schemas: 9 passed, 13 were not faster than
sglang, and 14 failed accuracy.
0.90; they are removed. The 4 KC schemas kept measured 1.05 to 2.00. 6 VC schemas measured 0.97 to
1.03 and are removed too, so the next run's gate (> 1.02) cannot fail on them. The 11 VC schemas kept
measured 1.05 to 1.31. Per-Point numbers are in the Kernels table.
attn_bmm_outputunderToleranceBound(abs 2^-12, rel 2^-8):same way:
amax * (1/448),1/scale, a multiply, then fp8 with round-to-nearest-even. On CPU, anyother float32 arithmetic there (a reciprocal one ulp off,
448/amax, another tie rule) movesthousands of codes. That gives violation fractions up to 0.27 and peaks in the hundreds, far from CI.
gemm'scontract notes for its fp8 GEMM; aiter's kernel takes the same
tl.dotpath. The error is absolute,so it breaks a 2^-12 absolute tolerance only where an output cancels to near 0. A CPU model of an
MFMA that keeps 14 bits below the group's largest product gives numbers like CI's, slightly worse:
21 to 30 of 108 sets, up to 137 elements, peak 3.6x to 4.4x.
violation fraction is allowed. The model's peak falls to 0.73x (0.5x with 15 bits). Deliberately
broken kernels still fail every simulated set:
w_scale;CI on
6535c34, fixed inf2393aaCI run 41956009610 (
unittest-aklr) failedtests/core/contract/test_fastkey.py::TestFastKey::test_call_key_is_codec_keyfor[email protected]_isand[email protected]_is. The test views every input's bytes as uint8, whicha 0-d tensor cannot do, and both contracts declared
w_scalewithshape=().f2393aadeclares it asone element,
shape=(1,):w_scale.view(1), a zero-copy view of sglang's 0-d scale;runhandsvc_reconstructthe 0-d view it asserts.The same run passed
test_backend_matches_referencefor both contracts andtest_hook.py's parametercheck of the route.
Contracts
Workloads: GLM-5.2's attention per rank at TP4 and TP8 (qk_nope_head_dim 192, kv_lora_rank 512,
qk_rope_head_dim 64, q_lora_rank 2048, v_head_dim 256) at decode token counts, chosen rather than taken
from an
AKLR_EXPORTrun. KC workloads usen_slots = n_tokens + 1, so most draws hold a padding row,and
n_positions = 65536.Kernels
[email protected]fused_fp8_bmm_rope_cat_and_cache_mla(aiter)bdc1040), 1 Point kept of 5 measured (TP4 256)q_catandkv_cache)[email protected]_absorb_bmm_config, flattenedbdc1040), 43372796649 (7a12633), 43385074220 (e305682) and 44219495647 (ad5fc11), 7 Points kept of 11667ccfa(1.03x and just under 1.05 in run 44219495647) and 2 ine305682(1.03x and 1.04x in run 43372796649)Per Point (CI runs 41986682790, 41982390802 and 41962335788; kernels unchanged between them)
mla_kc_rope_cache1c359c8bb38dc14dmla_vc40cc2f0e672e1c1dmla_vc34ba62a3705d0c1emla_vc1cd8ae22c3acef3cmla_vc5f79e894bad5a839mla_vcef12e9879424fba0mla_vcef12e9879424fba0mla_vc345ba5728058fb4eRemoved:
667ccfa, under the 1.05 bar:mla_vc, 16 (TP4), 1 token,e63ffb3a41f63c51: 1.03x in run 44219495647, after 1.07x, 1.06x and 1.12x in runs 42592557691, 43372796649 and 43385074220, and 1.04x (1.04), 1.08x (1.06), 1.09x (1.09) in the three runs above; 2 tokens,82c901b60c4e96c2: just under 1.05 in run 44219495647, after 1.07x, 1.09x and 1.06x, and 1.15x (1.13), 1.08x (1.08), 1.06x (1.05);e305682, under main's 1.05 bar:mla_vc, 16 (TP4), 16 tokens,0a9f1be8b037e8c0: 1.03x in run 43372796649, 1.06x in run 42592557691, and 1.06x (1.06), 1.09x (1.09), 1.13x (1.06) in the three runs above; 8 (TP8), 8 tokens,7f9358af6c7aed80: 1.04x in run 43372796649, 1.12x in run 42592557691, and 1.04x (1.03), 1.12x (1.11), 1.11x (1.10);c1214b9, for the qkv_a trade-off:mla_kc_rope_cache, 16 (TP4), 128 tokens,886370eeed62a426: 1.50x (1.49), 1.33x (1.32), 1.40x (1.39) in the three runs; 8 (TP8), 128 and 256 tokens,42afc2f3bee9d95e: 1.07x (1.07) and 1.49x (1.49), 1.06x (1.06) and 1.51x (1.51), 1.08x (1.07) and 1.46x (1.38);e7eecea:mla_kc_rope_cache, 16 (TP4), 64 tokens,6fb7c735f980baaa: 0.98x (0.95) in run 41986682790, after 1.06x (1.06) and 1.06x (1.05);bdc1040:mla_vc, 8 (TP8), 1 token,ed7ce19b08587aca: 1.01x (1.0009) in run 41982390802, 1.11x (1.09) in run 41962335788.Under abs 2^-9, runs 41982390802 and 41986682790 found no violation at any Point.
Validation log (audit, CPU; bench is this head's CI run)
Code
pytest tests/plugins/sglang tests/opson CPU: 164 passed, 53 skipped (main: 158 passed, 50 skipped).New tests: the two contracts' small Points in
tests/plugins/sglang/cases.py, both inGFX950_CONTRACT_IDS;names.txtregenerated. The three new skips need the GPU image:test_backend_matches_referencefor each contract andtest_hook.py's parameter check of the route.Whole
tests/on CPU (no triton on this Mac: one module fails to collect and some tests fail for theenvironment). The failure set equals main's in both comparisons:
3fb9033: 49 failed and 1 collection error each;5f63e8aagainst5f63e8a: 55 failed and 1 collection erroreach.
Against main, this branch adds 10 passes, its contracts' cases, and 9 skips: the 3 GPU-image tests
above and 6 fast-key forms that need an input these contracts lack.
pre-commiton the changed files (shellcheck skipped): passed.Route against sglang 0.5.22's source, on CPU.
forward_absorb_rocm_core,_fused_bmm_rope_cat_and_cache,rocm_absorb_v_bmmand_absorb_bmm_configwere taken from v0.5.22and executed with only the aiter kernels stubbed, on a GLM-5.2 layer laid out as 0.5.22's loader and
prepare leave it. The route, its ops computing through
baseline.py:decode and target verify, with both ops, either op, or neither;
dtypes and tile config;
w_scaleas a one-element view of the layer's 0-d scale (samestorage);
The only planned difference: the attention gets
k_rope=Noneonce the op has written the rotated keyinto the pool, and the DSA decode reads
k_ropeonly withk.References, on CPU: equal to a scalar-loop transcription of the contracts' text on tiny Points (fp8
groups of 128 with a narrower last one, GPT-J pairs, padding rows). Against simulated kernels at
GLM-5.2's shapes, the peaks are:
NeoX pairs, a missing
w_scaleand a written padding row fail.The 7 schemas parse as their contracts narrowed; their uuids match; the 8 Points are each served
once.
Not run
0.5.23's baselines: all accurate, at 1.05x to 2.13x, then 1.09x to 2.14x (1.11x to 2.10x against 0.5.22's
in run 44219495647). Dispatch serves only Points measured at or
above
AKLR_MIN_SPEEDUP(1.05 since main's feat(validation): one 5% bar for admission and dispatch, and acceptance criteria for kernel and plugin PRs #153).written back, that run needs
AKLR_MIN_SPEEDUP=0and--kv-cache-dtype fp8_e4m3.Risk
Affects: GLM-5.2 decode and target verify on gfx950 with
SGLANG_USE_AITER=1and the DSA backend'sfused RoPE/cache path:
o_projonly) at TP4 4, 8, 128 and 256 tokens and TP8 2, 4 and 256.Other token counts stay on sglang.
If wrong: wrong attention inputs, KV rows or o_proj inputs give wrong model output. Bench's reference
checks cover the kernels; the route is checked only by the model run. Or a kernel is slower than sglang,
in which case the bench drops those Points.
Undo:
[email protected],[email protected]turns both ops off, and the route then hands everycall back to sglang; otherwise
git revert.Part 2: the qkv_a projection and latent RMSNorms op on
forward_absorb_rocm_prepareWhy
Before each attention, GLM-5.2's decode on gfx950 runs the qkv_a projection (
fused_qkv_a_proj_with_mqa, whichsglang 0.5.22 runs lazily through
fetch_qkv_latent) and then aiter's fused RMSNorm of q's latent and the KVlatent, inside
forward_absorb_rocm_prepare. This adds one op for that step, with decode kernels created byOpenAI that fuse the projection and the norms, and a route on
forward_absorb_rocm_preparethat calls it. It isthe remaining op of the MLA absorb package.
Scope
[email protected]inaklr/plugins/sglang/models/deepseek_common/(next to Part 1's ops), with itsreference, baseline, api and a small test Point. The op takes the hidden states, the bf16 qkv_a weight and the
two norm weights and eps, and returns q's latent and the KV latent, each normalized and scaled, plus the RoPE
key as projected.
64, at n_tokens 1, 2, 4, 8, 16, 32, 64, 128 and 256.
count compute the same Point. CI measures both, and dispatch serves the faster. At 1 token only the
TP4-tuned one is left: the TP8-tuned one fell under 1.05 on sglang 0.5.23 (
3350a63).DeepseekMLARocmForwardMixin.forward_absorb_rocm_prepareon sglang 0.5.22 and 0.5.23 for thecompressed-query branch that normalizes with aiter's fused bf16 RMSNorm (a bf16
q_b_proj).q_b_proj,the indexer, the query absorb unless the core fuses it, and RoPE where prepare applies it.
q_b_proj, aiter off, or two different epsilons;Tradeoffs
[n, 64]tensor. Part 1'smla_kc_rope_cachereads theRoPE key inside the whole qkv latent: its route rebuilds that latent from sglang's strided
k_pe, so itdeclines this op's key. sglang's fused kernel then does the absorb.
_core_falls_backand_kc_arguments, on empty stand-insof sglang's prepare outputs) and leaves prepare to sglang whenever the core route would serve KC.
at 1–128 at TP4. It serves all 9 token counts where KC does not run: a bf16 KV cache, extend, or KC
disabled or not qualified.
unrounded (sums in different orders cross bf16 rounding boundaries), and the bounds admit both roundings.
at 1 token the TP8-tuned one is removed (
3350a63).d3f0956op and route,e5f4148schemas) and can be split.Verification
Environment: head
e5f4148(stacked ona7b94a4). Checks ran on CPU (macOS, Python 3.12.11, torch 2.8.0, noTriton). GPU validation is this head's CI run with
ci:gpu(MI355X, imagelmsysorg/sglang:v0.5.22-rocm10-mi35x,aiter
dbd8bf5): audit and bench against the baseline, and the GPU unit tests.Gate overrides: none
Contracts
Workloads: GLM-5.2's qkv_a projection (hidden 6144, q_lora_rank 2048, kv_lora_rank 512, qk_rope_head_dim 64) at
the decode token counts the kernels are scheduled for. They were chosen, not taken from an
AKLR_EXPORTrun.Bounds, from a CPU model of sglang's and the kernels' arithmetic:
q_latent,kv_latent:ToleranceBound(abs 2^-12, rel 2^-7). Each is rounded to bf16 twice, as sglang roundsit (the qkv latent, then the norm's output).
k_rope:ToleranceBound(abs 2^-6, rel 2^-8). It is rounded once.The model covers fp32 MFMA sums, IEEE or keeping 14 bits below each MFMA's largest product, split-K or one pass,
hidden 6144 and 16384, 1 to 256 tokens. Through AKLR's own compare, they peak at 0.64 of the bound. Deliberately
broken computations fail: dropped or swapped norm weights, the two latents normalized together or by the other's
rms, a lost 32-wide K group, shifted rows, the RoPE key from the wrong columns. An MFMA that keeps only 16 bits
below its accumulator still passes (peak 0.73); one that keeps 14 bits does not (peak 1.1 to 3.4 of the bound).
Kernels
[email protected]UnquantizedLinearMethod(aitertgemm.mm) +fused_qk_rmsnorm_bf16(aiter)e5f4148) and 41986682790 (bdc1040), 18 schemas, 9 Points; run 44296931687 (8f37c2f, sglang 0.5.23, aiter v0.1.29): 17 of 18 kept; run 44350793689 (3350a63): the 17 passed95c7c556(TP8-tuned, 1 token) at 1.04x, removed in3350a63. Run 44350793689: 1.09x to 1.16xValidation log (audit, CPU; bench is this head's CI run)
The same audit against main merged with this branch (
--base 5f63e8a): passed, findings 0.Code
pytest tests/plugins/sglang tests/opson CPU: 167 passed, 55 skipped (164 and 53 ata7b94a4).tests/plugins/sglang/cases.py, inGFX950_CONTRACT_IDS;names.txtregenerated.test_backend_matches_referenceandtest_hook.py's parameter checkof the route.
tests/on CPU (no Triton on this Mac: one module fails to collect and some tests fail for theenvironment). The failure set equals the base's in both comparisons:
a7b94a4: 49 failed and 1 collection error each (543 passed against 537);5f63e8aagainst5f63e8a, both git checkouts: 51 failed and 1 collection erroreach, the same IDs as main's recorded baseline.
pre-commiton the 25 changed files (shellcheck skipped): passed.forward_absorb_rocm_prepareand
forward_absorb_rocm_corewith their callees fromforward_mla_rocm.py,forward_mla.pyanddeepseek_v2.py(prepare_qkv_latent,q_b_proj_forward), and the layer boundary'sAttentionInputs. Thelayer was GLM-5.2's, laid out as 0.5.22 holds it. The ops ran through
baseline.pyafter the contracts'generated dispatch checks:
decode, target verify and extend. The RoPE key has equal values, in a contiguous tensor of its own.
qkv_latent_stays unset), and the q_b_proj, indexer, absorb and RoPE callsget the same tensors.
Where KC serves, the prepare route stays on sglang. Where KC does not, this op serves, VC serves as before
and sglang's fused kernel takes this op's RoPE key.
is served by 2 schemas. sglang-shaped calls at those token counts are served, while 3 or 512 tokens, a strided
hidden state or an fp8 weight decline.
Points.
Not run
accurate, at 1.04x to 1.16x, and
3350a63removes the one under 1.05; run 44350793689 measured the 17left at 1.09x to 1.16x. Runs 43372796649 and 43385074220
had measured 1.07x to 1.50x and 1.07x to 1.54x against 0.5.22's. Dispatch serves
only Points measured at or above
AKLR_MIN_SPEEDUP(1.05).back, that run needs
AKLR_MIN_SPEEDUP=0, and the KC check above needs Part 1's measurements too.Risk
Affects: GLM-5.2 on gfx950 with
SGLANG_USE_AITER=1and a bf16q_b_proj, in the qkv_a projection and latentnorms of
forward_absorb_rocm_prepare:If wrong: wrong q latent, KV latent or RoPE key, so wrong attention and wrong model output. Bench's reference
checks cover the kernels; only the model run checks the route. Or a kernel is slower than sglang (sglang's tuned
GEMM often wins at larger token counts), and then the bench drops its Points.
Undo:
[email protected]turns the op off, and the route then hands every call back to sglang;otherwise
git revert.🤖 Generated with Claude Code