Skip to content

[Perf] [AMD] GLM5.3: Run KDA decode and HIP prefill on a BF16 state pool on gfx950 - #49036

Open
Raiden-Makoto wants to merge 4 commits into
sgl-project:mainfrom
Raiden-Makoto:RM/glm53-kda-bf16-state-pr
Open

Raiden-Makoto wants to merge 4 commits into
sgl-project:mainfrom
Raiden-Makoto:RM/glm53-kda-bf16-state-pr

Conversation

@Raiden-Makoto

@Raiden-Makoto Raiden-Makoto commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

GLM-5.3-Flash keeps the recurrent state of its 34 KDA layers in FP32 (mamba_ssm_dtype resolves to float32). Decode and MTP verify are bound by reading and rewriting that state, and the state pool takes GPU memory that the KV cache and prefix cache could use.

--mamba-ssm-dtype bfloat16 already exists, but on gfx950 both fast paths reject a BF16 pool: the row-streaming packed decode (#44659) and the HIP chunked prefill fall back to the generic Triton kernels. This change runs both on a BF16 state pool. All recurrence math stays FP32; only the stored state is BF16.

Depends on #44659, which adds the row-streaming decode kernel. This branch carries that commit; the change under review is a06475153e.

Modifications

  • Accept a BF16 state pool in the row-streaming KDA packed decode. The kernel already loads the state into FP32 and stores it in the pool dtype.
  • Add per-head-count BF16 launch tables, measured on MI355X for 16 local heads (TP4) and 8 local heads (TP8). TP4 batches 23-31 keep the generic kernel, where it measured faster. Other head counts with a BF16 pool keep the generic kernel. The FP32 path is unchanged.
  • Run the HIP KDA chunked prefill on a BF16 pool: the recurrence kernels load the BF16 state into FP32 and store the final state as BF16 (round to nearest even). Outputs, final states and tracking snapshots are bit-identical to the FP32 kernel run on the same values and rounded to BF16, with no extra copies or allocations.
  • Extend the gfx950 tests: every BF16 decode config bucket with two seeds, padded slots and the untouched pool, 16 decode steps, the generic-kernel cells, determinism and CUDA-graph replay; BF16 prefill against the rounded FP32 kernel and against Triton chunk_kda across every recurrence path, tracking snapshots, and no Triton fallback from TritonKDAKernel.extend.

Enable with:

--mamba-ssm-dtype bfloat16

Accuracy Tests

Focused validation passed 15 gfx950 tests and 105 subtests on upstream main 56e38dfe0f with #44659 and this change.

Full GLM-5.3-Flash GSM8K on snapshot b5688f25491202978c19c4d036eef579f61bbe07: 1,319 examples, thinking enabled, temperature 1.0, top-p 0.95, sampling seed unset.

Configuration Score Stop rate Truncated rate Error rate
TP4 — --mamba-ssm-dtype bfloat16 96.89% 100.00% 0.00% 0.00%
TP8 — --mamba-ssm-dtype bfloat16 96.51% 99.47% 0.53% 0.00%

TP4 used a 65,536-token context, 64 evaluator threads, and 32,768 maximum output tokens. TP8 used a 131,072-token context, 1,200 evaluator threads, and 4,096 maximum output tokens.

Speed Tests and Profiling

Environment:

  • Hardware: AMD Instinct MI355X (gfx950)
  • Docker image: rocm/sgl-dev:v0.5.23-rocm724-mi35x-20261102
  • Model: amd/GLM-5.3-Flash-Quark-MXFP4, snapshot b5688f25491202978c19c4d036eef579f61bbe07
  • AITER: 3015e3639 (285579b62 with GLM-5.3 MXFP4 MoE changes)
  • Validated source SHA: a8e0045395 (GLM-5.3 integration branch with this change)

Decode state update latency

One KDA decode step per layer, CUDA-graph replay. FP32 is the current row-streaming path; BF16 is this change.

TP Batch FP32 state (µs) BF16 state (µs) Delta
4 1 2.69 2.37 -12.1%
4 8 4.28 3.43 -19.9%
4 16 6.40 4.47 -30.1%
4 32 9.55 6.72 -29.7%
4 64 21.00 10.36 -50.7%
4 80 26.27 14.52 -44.7%
8 1 2.60 2.34 -10.2%
8 16 4.93 3.43 -30.4%
8 64 10.81 6.75 -37.5%
8 128 21.10 10.40 -50.7%
8 256 41.37 22.15 -46.5%
8 512 88.04 41.73 -52.6%

Every enabled BF16 row-streaming cell beat the generic BF16 kernel, 0.7-29%, across all decode CUDA-graph batch sizes.

Prefill latency

One KDA layer, HIP chunked prefill. The last column is a BF16 pool without this change, which falls back to Triton chunk_kda.

TP Sequences x tokens FP32 state (µs) BF16 state (µs) Delta BF16 before this change (µs)
4 1 x 8,192 185 181 -1.9% 599
4 1 x 16,384 317 312 -1.8% 1,153
4 2 x 8,192 350 345 -1.2% 874
4 16 x 1,024 169 168 -0.6% 714
4 4 x 8,192 540 537 -0.6% 1,456
8 1 x 8,192 126 125 -0.3% 497
8 1 x 16,384 202 201 -0.5% 863
8 2 x 8,192 244 242 -0.4% 577
8 16 x 1,024 119 119 -0.3% 352
8 4 x 8,192 358 358 -0.0% 839

The BF16 pool runs at FP32 speed and removes the 2.3-4.3x Triton fallback. The end-to-end and agentic results below were measured with an earlier revision of this change that copied the BF16 state to FP32 around the same kernel (21-33 µs per call).

MTP verify latency

KDA target verify, 6 draft tokens per request, chain, CUDA-graph replay. The verify kernel already supports a BF16 pool; this is the effect of the state dtype.

TP Requests FP32 state (µs) BF16 state (µs) Delta
4 1 8.41 7.34 -12.7%
4 16 24.25 18.05 -25.6%
4 64 93.45 42.95 -54.0%
4 80 124.95 64.06 -48.7%
8 1 7.51 6.73 -10.4%
8 16 19.38 13.40 -30.9%
8 64 41.17 26.48 -35.7%
8 80 56.81 31.34 -44.8%

With MTP on TP4 GSM8K, the mean accept length was 2.875 with the FP32 state and 2.809 with the BF16 state (-2.3%).

End-to-end serving

GLM-5.3-Flash snapshot b5688f25491202978c19c4d036eef579f61bbe07, TP4, 65,536 context, random 8K input / 1K output. Both arms use source a8e0045395 and differ only by --mamba-ssm-dtype bfloat16.

A. FP32 state — dtype unset:

Concurrency TTFT (ms) ITL (ms) E2EL (ms) Output tok/s
4 419.11 6.060 6787.83 603.19
8 658.88 6.770 7988.16 1025.42
16 1137.03 7.915 10108.17 1618.72
32 2083.36 9.380 13506.65 2425.14
64 3998.27 11.545 19573.46 3348.49

B. BF16 state — --mamba-ssm-dtype bfloat16 (delta versus FP32 state):

Concurrency TTFT (ms) Delta ITL (ms) Delta E2EL (ms) Delta Output tok/s Delta
4 421.69 +0.62% 6.000 -0.99% 6729.94 -0.85% 608.42 +0.87%
8 661.38 +0.38% 6.690 -1.18% 7908.15 -1.00% 1034.99 +0.93%
16 1140.05 +0.27% 7.750 -2.08% 9950.53 -1.56% 1644.13 +1.57%
32 2095.80 +0.60% 9.060 -3.41% 13190.01 -2.34% 2481.42 +2.32%
64 4010.26 +0.30% 10.980 -4.89% 19002.78 -2.92% 3447.99 +2.97%

The BF16 state improves ITL by 0.99-4.89%, E2E latency by 0.85-2.92%, and output throughput by 0.87-2.97% across the complete TP4 matrix; TTFT is within 0.62%.

TP8 end-to-end serving

GLM-5.3-Flash TP8, 131,072 context, random 8K input / 1K output. Both arms use source a8e0045395 and differ only by --mamba-ssm-dtype bfloat16.

A. FP32 state — dtype unset:

Concurrency TTFT (ms) ITL (ms) E2EL (ms) Output tok/s
4 363.60 5.490 6110.41 669.91
8 593.69 5.990 7074.63 1157.16
16 1046.76 6.540 8554.72 1914.13
32 1950.89 7.570 11398.20 2872.91
64 3762.66 8.915 16411.67 3992.11

B. BF16 state — --mamba-ssm-dtype bfloat16 (delta versus FP32 state):

Concurrency TTFT (ms) Delta ITL (ms) Delta E2EL (ms) Delta Output tok/s Delta
4 367.73 +1.13% 5.460 -0.55% 6084.84 -0.42% 672.80 +0.43%
8 596.39 +0.45% 5.940 -0.83% 7033.68 -0.58% 1163.79 +0.57%
16 1049.12 +0.23% 6.450 -1.38% 8459.84 -1.11% 1935.36 +1.11%
32 1951.23 +0.02% 7.400 -2.25% 11222.30 -1.54% 2916.90 +1.53%
64 3761.69 -0.03% 8.650 -2.97% 16136.69 -1.68% 4060.14 +1.70%

The BF16 state improves TP8 ITL by 0.55-2.97%, E2E latency by 0.42-1.68%, and output throughput by 0.43-1.70% across the complete matrix; TTFT is within 1.13%.

Agentic serving

InferenceX AgentX agentic benchmark, TP4, MTP speculative decoding, concurrency 64, 3,600 s profiling. Both arms in each table differ only by the KDA state dtype.

With HiCache, write_through, TileLang DSA, measured acceptance length:

KDA state Per-GPU tok/s P90 interactivity ITL p50 (ms) ITL p90 (ms) TTFT p90 (s) Profiled requests
FP32 — dtype unset 43,202 14.7 23.61 67.85 8.75 5,133
BF16 — --mamba-ssm-dtype bfloat16 49,610 18.5 20.89 53.96 7.01 5,787
Delta +14.8% +25.8% -11.5% -20.5% -19.9% +12.7%

With HiCache, write_back (--hicache-io-backend kernel --hicache-mem-layout page_first), 216 GB/rank, Triton DSA, simulated acceptance length 3.56, with #48112; mean of two runs per arm:

KDA state Per-GPU tok/s P90 interactivity ITL p50 (ms) ITL p90 (ms) TTFT p90 (s) Profiled requests
FP32 — dtype unset 81,437 48.0 12.20 20.87 1.29 8,824
BF16 — --mamba-ssm-dtype bfloat16 87,873 59.7 11.43 16.73 1.05 9,399
Delta +7.9% +24.6% -6.3% -19.8% -18.6% +6.5%

Every arm passed the InferenceX health check with 0 crashes, 0 OOM warnings, and 0.0% errors. The BF16 state nearly doubles the state-pool slots in about the same memory (841 to 1,630 slots at write_back) and raises device KV capacity from 12,351,744 to 13,031,168 tokens. With write_through it also raises the server prefix-cache hit rate from 87.2% to 89.5%; with write_back the hit rate is already 95.7% for FP32 and 96.4% for BF16. Repeated write_back runs agree within 1.1% on throughput and 2.7 points on P90 interactivity.

Checklist

Scoped pre-commit (isort, Ruff, Ruff format, codespell, registered-test validation) passes.


CI States

Latest PR Test (Base): Not run yet
Latest PR Test (Extra): ⊘ Skipped -- add the run-ci-nv-extra label to opt in.
Latest PR Test (AMD ROCm 10): ❌ Run #44584237150

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

Add a gfx950 row-streaming packed KDA decode kernel and route validated safe-gate KDA geometry through it. Unsupported hardware, layouts, dtypes, dimensions, and indices retain the existing decode path.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@Raiden-Makoto
Raiden-Makoto force-pushed the RM/glm53-kda-bf16-state-pr branch from 36505a3 to a064751 Compare November 13, 2026 16:04
Raiden-Makoto added a commit to Raiden-Makoto/squidward that referenced this pull request Nov 13, 2026

@Jacob0226 Jacob0226 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bingxche

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@Raiden-Makoto
Raiden-Makoto force-pushed the RM/glm53-kda-bf16-state-pr branch from a064751 to ea980f3 Compare November 18, 2026 23:38
@github-actions

This comment has been minimized.

jhinpan pushed a commit to sgl-project/sgl-amd-mono that referenced this pull request Nov 26, 2026
## Motivation

On `main`, `--enable-amd-monokernel` with `--mamba-ssm-dtype bfloat16`
stops a GLM-5.3-Flash server at startup, so a bf16 state runs only
without the monokernel. With this PR, the monokernel loads and stores a
bf16 state; the math stays f32. On a bf16 state, monokernel off → on
raises AgentX P90 interactivity 41.9% at conc 1 and 51.4% at conc 4.
Against `main` (f32 state), P90 interactivity is unchanged within noise
(conc 1, 4, 8: +3.6%, +0.2%, +1.0%), and GSM8K and RULER2 NIAH (300K,
640K) show no difference resolved.

- **SGLang:** `cbd4439f3d`
(`rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115`) plus
sgl-project/sglang#49036 (`1695988c28`). `main` is the image's
sgl-amd-mono `7113024`; this PR's kernels are `e83543d` (`ae27495` adds
only `time_layers.py --state-bf16`; `e388920` changes where `_build`
reads the dtype, the tests and the README). `7113024` to `572ddf1`, this
PR's base, changes no `glm53_flash` file.

## Modifications

The steps the monokernel runs do not change: decode and target-verify
steps of up to 16 rows, TP 2, 4 and 8 (TP 2 up to 4 rows). Wider steps
run SGLang's path, as on `main`. The f32 build does not change (bitwise,
below). No new `SGLANG_READS` key: `mamba2_state_dtype` is already
declared. The README's Requirements name sgl-project/sglang#49036 and
its base #44659. No new env var or fault-injection site.

| File | Change |
| --- | --- |
| `glm53_flash/gfx950/kernel.py` | `FlashBuild.state_bf16`. A KDA launch
loads the recurrent state as bf16, converts it to f32, and stores it
rounded to nearest even (as `torch.Tensor.to(torch.bfloat16)`). A verify
launch carries the state in f32 registers across its draft rows and
writes each row's verify scratch (`inter_rec`) in bf16. The conv state
was bf16 already. |
| `glm53_flash/spec.py` | `_config_disable_reasons` accepts an f32 or
bf16 KDA state; any other dtype still refuses at startup. `_bind_kda`
requires the verify scratch in the state's dtype. Both read
`mamba2_state_dtype(None)`, the dtype SGLang allocates the pool in:
GLM-5.3-Flash's cache params name none, so only `--mamba-ssm-dtype` sets
it. |
| `glm53_flash/gfx950/runner.py` | Each launch checks the state and
scratch dtypes against the build. |
| `test/kernels/glm53_flash/check_layer.py` | `--check-state-bf16` for
`--kind kda`, `dense` (layers 1–2) and `embed` (layer 0), with or
without `--verify L` (below) |
| `test/kernels/test_glm53_flash_kernels.py` |
`test_a_bf16_state_launch_matches_the_f32_launch`: the three kinds, TP
2, 4 and 8 |
| `test/kernels/glm53_flash/time_layers.py` | `--state-bf16`: KDA
launches on a bf16 recurrent state (below) |
| `test/unit/test_glm53_flash_spec.py` | A bf16 state is accepted; an
f16 state refuses; a checkpoint's `mamba_ssm_dtype` is ignored. On a
bf16 pool, `_build` builds every KDA, dense and embed launch for a bf16
state. `_bind_kda` binds an f32 or bf16 state and refuses scratch of
another dtype |
| `test/unit/test_glm53_flash_runner.py` | A launch refuses a state or
scratch of another dtype than its build |
| `test/e2e/glm53_flash_server.py`,
`test/e2e/test_glm53_flash_server.py` | `BF16_STATE`.
`TestMonokernelBf16State`: MTP's GSM8K and accept length, and
`SGLANG_AMD_MONO_CHECK=1` numerics, on a bf16 state. `ARGS` keeps the
f32 state. |
| `README.md` | The GLM-5.3-Flash row names the bf16 state; Requirements
name sglang#49036 and #44659 |

## Accuracy Tests

With a bf16 state, the monokernel off and on match. Against an f32
state, accept length is 1.2% lower; the monokernel-off side shows it
too, so it comes from the bf16 state. 20 samples a task do not resolve
`mv_niah_hard` (copy the Nth of 4 questions with the same number): a
second 640K run gave `main` 41.67 and this PR 20.16, so it ran again
with 100 samples. Every difference sits inside its bootstrap 95% CI, and
this PR's own two 100-sample runs differ by as much. On a bf16 state,
each layer's numerics stay near the f32 ones.

| Item | Setup |
| --- | --- |
| Kernel check | MI355X, TP as below. `--check-state-bf16` gives both
builds the same inputs and state values; it passes when outputs are
bitwise equal and the written state equals the f32 one rounded to bf16 |
| End to end | `amd/GLM-5.3-Flash-Quark-MXFP4`, TP4, MTP3, real
acceptance, 4 requests at a time (up to 16 rows a step, all on the
monokernel); each pair at once on one node, GPUs 0–3 and 4–7 |
| GSM8K | sgl-eval, thinking, temperature 1.0, top-p 0.95, 4096 tokens |
| `test/e2e` | `test_glm53_flash_server.py`, the image's SGLang without
#49036 (SGLang's Triton prefill runs on the bf16 state); GSM8K 200
questions. The 20261122 image (SGLang `4cbe4cbf43`, the newest, which
the CI picks) ran the whole file at `f4df9ec`, with this PR installed
over the image's sgl-amd-mono as the CI does; the 20261115 image ran the
numerics table below |
| RULER2 NIAH | sgl-eval, thinking, 8192 tokens, the AgentX server flags
below with `--max-running-requests 8 --cuda-graph-max-bs-decode 8`; the
command below, and `--ruler2-dataset-size 100 --ruler2-tasks
mv_niah_hard` for 100 samples |

| Kernel check | TP | Rows a launch | Result |
| --- | --- | --- | --- |
| bf16 build vs f32 build, decode and verify | 2, 4, 8 | decode 2, 4, 8,
16; verify 4 × MTP3, 16 × MTP3, 8 × MTP5, 12 × MTP5 (TP 2: up to 4 rows)
| equal |
| bf16 build vs f32 build, `dense` and `embed` kinds (layers 0–2) | 2,
4, 8 | decode 2, 8 (TP 2: 2); verify 4 × MTP3 | equal |
| f32 build, this PR vs `main` (`25723f1`; `glm53_flash` is unchanged
from it to `b504de5`) | 4 | decode 2, 8, 12, 16; verify 8 × MTP5, 12 ×
MTP5, 8 × MTP3, 16 × MTP3 | bitwise equal |
| Negative control: the bf16 load or store handles its four 8-element
groups out of order | 4 | decode 4, verify 8 × MTP3 | fails: outputs,
`rec_state` (decode) and `inter_rec` (verify) differ |
| `test/kernels/test_glm53_flash_kernels.py` (8 GPUs, 20261106 image) |
2, 4, 8 | all | 11 passed (36 min) |
| `test_a_bf16_state_launch_matches_the_f32_launch` with the `dense` and
`embed` kinds (8 GPUs, 20261115 image) | 2, 4, 8 | as above | passed (13
min) |
| `test/unit/test_glm53_flash_{spec,runner,check}.py`,
`test/unit/test_contract.py`, 20261115 image's SGLang | 1 GPU | | 121
passed, 3 failed; `main` fails the same 3 (`kimi_k3`, `kimi_k31` and
`qwen38_flash_next` contracts) |
| `TestMonokernelBf16State` GSM8K, MTP3 | 4 | decode 1–16 requests,
verify 1–4 × MTP3 | 98.5%, accept length 3.18 (bounds 90%, 2.5) |
| Whole `test_glm53_flash_server.py`, 20261122 image | 4 | as each test
| 9 passed. GSM8K: 98% (decode), 98% with accept length 3.23 (MTP3), 99%
with 3.26 (MTP3, bf16 state) |
| Negative controls in the unit tests: `_build` never picks the bf16
build; no `_bind_kda` dtype checks; no runner dtype checks | 1 GPU | |
each fails one test: the bf16 build, the bind, and the runner test |

| GSM8K 1319, mean of seeds 0–2 | Accuracy | Accept length |
| --- | --- | --- |
| bf16 state, monokernel off | 96.97% | 3.178 |
| bf16 state, this PR | 97.09% | 3.182 |
| f32 state, `main` | 97.09% | 3.200 |
| bf16 state, this PR | 97.17% | 3.163 |

| `SGLANG_AMD_MONO_CHECK=1`, worst check, 20261115 image; both tests
passed | f32 state (`TestMonokernelCheck`) | bf16 state
(`TestMonokernelBf16State`) |
| --- | --- | --- |
| `kda.state` rel (775 checks) | 0.00128 | 0.00203 |
| `kda.streams` cosine / rel | 0.98938 / 0.146 | 0.98844 / 0.152 |
| `dense.state` rel (75) | 0.00070 | 0.00126 |
| `dense.streams` cosine / rel | 0.99945 / 0.0331 | 0.99945 / 0.0333 |
| `dsa.streams` cosine / rel (275) | 0.97783 / 0.211 | 0.99034 / 0.140 |
| `dsa.kv` cosine / rel | 0.99917 / 0.0408 | 0.99916 / 0.0410 |

| RULER2 NIAH, 20 samples a task, score (%) | 300K `main` | 300K this PR
| 640K `main` | 640K this PR |
| --- | --- | --- | --- | --- |
| `mk_niah_basic` | 100 | 100 | 100 | 100 |
| `mk_niah_hard` | 90.00 | 85.00 | 100 | 95.00 |
| `mv_niah_basic` | 100 | 98.75 | 96.25 | 97.50 |
| `mv_niah_hard` | 65.25 | 64.72 | 40.39 | 30.03 |
| All four | 88.81 | 87.12 | 84.16 | 80.63 |

| `mv_niah_hard`, 100 samples, score (%) | 300K | 640K |
| --- | --- | --- |
| f32 state, `main` | 57.10 | 42.20 |
| bf16 state, this PR | 58.07 | 39.17 |
| This PR − `main`, bootstrap 95% CI; samples higher `main` / this PR |
+1.0 [−8.1, +10.1]; 14 / 17 | −3.0 [−12.1, +6.1]; 15 / 11 |
| bf16 state, monokernel off | 53.93 | 36.17 |
| bf16 state, this PR, second run | 56.06 | 41.85 |
| On − off, bootstrap 95% CI; samples higher off / on | +2.1 [−7.9,
+12.6]; 14 / 18 | +5.7 [−3.8, +14.9]; 11 / 17 |
| This PR, second run − first run | −2.0 [−12.8, +8.8] | +2.7 [−7.2,
+12.6] |

```bash
python3 -m sgl_eval.cli run ruler2 --base-url http://127.0.0.1:30250/v1 --ruler2-seq-len 640000 \
  --ruler2-tokenizer amd/GLM-5.3-Flash-Quark-MXFP4 --ruler2-dataset-size 20 \
  --ruler2-tasks mk_niah_basic mk_niah_hard mv_niah_basic mv_niah_hard --num-threads 4 --max-tokens 8192 \
  --chat-template-kwarg enable_thinking=true --out-dir niah/pr_640000
```

## Speed Tests and Profiling

Cells read `main` → this PR, or monokernel off → on where named. On a
bf16 state at conc 1 and 4, 97.5–99.9% of logged decode batches have 1–2
requests, and off → on raises P90 interactivity 41.9% and 51.4%. Against
`main`, P50 interactivity and the decode step at decode batch 1–2
improve in all 9 rounds; P90 moves −3.7% to +5.9% (conc 4 round 1's P90
requests ran at decode batch 2.06 vs 1.70). At conc 16, P90
interactivity and throughput match within 1.1%: its P90 requests ran
past the width. The KDA launch alone is 2–5% faster.

| Item | Setup |
| --- | --- |
| AgentX | 20261115 image, TP4, 3,600-s windows after a 1,800-s warmup,
golden accept length. `main` runs its default f32 state; this PR adds
`--mamba-ssm-dtype bfloat16`. Both at once on one node, `main` on GPUs
0–3 in rounds 1 and 3, on 4–7 in round 2 |
| bf16 state, off → on | Conc 1 (MTP5) and conc 4 (MTP3), one round
each: monokernel off (GPUs 0–3) → this PR (`ae27495`) with
`--enable-amd-monokernel` (GPUs 4–7), both with `--mamba-ssm-dtype
bfloat16`. No GPU-swapped round: in the three `main` rounds (round 2
swapped), the P90 change spans 1.0 point at conc 1 and 6.4 at conc 4.
Aggregate JSONs:
[comment](#141 (comment))
|
| Control point | Conc 16 with MTP5, InferenceX's setting, which runs
without the monokernel. Both sides on a bf16 state: monokernel off (GPUs
0–3) → this PR with `--enable-amd-monokernel` (GPUs 4–7). Steps of 3 or
more requests (18 rows) pass the 16-row width and run SGLang's path; 53%
of the on side's logged decode batches had 1–2 requests |
| Kernel-only | `time_layers.py --rows 2,4,8,12,16`, TP4, decode
launches; f32 and `--state-bf16` alternated twice on GPUs 0–3 (the two
runs differ by 0.6% or less). `--kind kda`: 12 KDA launches; `--kind
model`: the served step's 41 launches (30 KDA, 11 sparse attention). KDA
verify launches, which also write `inter_rec` in bf16, are not timed:
`--verify` times sparse attention only |

| Concurrency | Round | P90 interactivity (tok/s/user) | P50
interactivity (tok/s/user) | Median ms a token at decode batch 1–2
(server log) | P90 E2E-normalized interactivity (tok/s/user) | P90 TTFT
(s) | Total tok/s/GPU | Requests completed (each run also drops 3.4–5.4%
as empty responses) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Conc 1, MTP5 | 1 | 429.4 → 445.5 (+3.8%) | 467.4 → 482.7 (+3.3%) |
2.15 → 2.09 (−2.8%) | 211.9 → 224.4 (+5.9%) | 0.729 → 0.746 | 6,569 →
6,704 (+2.0%) | 306 → 309 |
| Conc 1, MTP5 | 2 | 429.0 → 446.1 (+4.0%) | 468.8 → 482.7 (+3.0%) |
2.16 → 2.08 (−3.7%) | 218.5 → 232.1 (+6.2%) | 0.690 → 0.696 | 6,572 →
6,712 (+2.1%) | 306 → 309 |
| Conc 1, MTP5 | 3 | 432.8 → 445.9 (+3.0%) | 467.7 → 483.0 (+3.3%) |
2.15 → 2.09 (−2.8%) | 213.1 → 231.0 (+8.4%) | 0.744 → 0.741 | 6,568 →
6,705 (+2.1%) | 306 → 309 |
| Conc 4, MTP3 | 1 | 389.1 → 374.9 (−3.7%) | 547.7 → 555.6 (+1.4%) |
1.80 → 1.75 (−2.8%) | 205.0 → 180.8 (−11.8%) | 0.614 → 0.657 | 9,122 →
9,408 (+3.1%) | 698 → 724 |
| Conc 4, MTP3 | 2 | 396.2 → 406.8 (+2.7%) | 543.0 → 565.0 (+4.1%) |
1.80 → 1.74 (−3.3%) | 198.1 → 200.9 (+1.4%) | 0.623 → 0.636 | 9,133 →
9,236 (+1.1%) | 703 → 709 |
| Conc 4, MTP3 | 3 | 393.2 → 399.4 (+1.6%) | 541.3 → 545.6 (+0.8%) |
1.81 → 1.76 (−2.8%) | 201.8 → 204.0 (+1.1%) | 0.614 → 0.613 | 9,131 →
9,633 (+5.5%) | 702 → 736 |
| Conc 8, MTP3 | 1 | 270.9 → 270.7 (−0.1%) | 419.8 → 450.8 (+7.4%) |
1.95 → 1.87 (−4.1%) | 175.7 → 181.1 (+3.0%) | 0.646 → 0.630 | 15,706 →
15,650 (−0.4%) | 1,406 → 1,403 |
| Conc 8, MTP3 | 2 | 261.3 → 276.7 (+5.9%) | 414.3 → 448.8 (+8.3%) |
1.94 → 1.88 (−3.1%) | 172.7 → 181.4 (+5.1%) | 0.668 → 0.657 | 15,746 →
15,599 (−0.9%) | 1,410 → 1,399 |
| Conc 8, MTP3 | 3 | 269.3 → 261.9 (−2.7%) | 425.9 → 446.2 (+4.8%) |
1.96 → 1.88 (−4.1%) | 180.0 → 174.0 (−3.4%) | 0.674 → 0.636 | 15,590 →
15,626 (+0.2%) | 1,399 → 1,402 |
| Mean, conc 1 | | 430.4 → 445.8 (+3.6%) | 468.0 → 482.8 (+3.2%) | | | |
6,570 → 6,707 (+2.1%) | |
| Mean, conc 4 | | 392.8 → 393.7 (+0.2%) | 544.0 → 555.4 (+2.1%) | | | |
9,129 → 9,426 (+3.3%) | |
| Mean, conc 8 | | 267.2 → 269.8 (+1.0%) | 420.0 → 448.6 (+6.8%) | | | |
15,681 → 15,625 (−0.4%) | |
| Conc 1, MTP5, bf16 state, monokernel off → this PR | 1 | 314.2 → 445.7
(+41.9%) | 329.6 → 481.9 (+46.2%) | 3.04 → 2.09 (−31.3%) | 203.8 → 252.3
(+23.8%) | 0.471 → 0.509 | 5,486 → 6,805 (+24.0%) | 279 → 311 |
| Conc 4, MTP3, bf16 state, monokernel off → this PR | 1 | 260.5 → 394.5
(+51.4%) | 301.5 → 559.3 (+85.5%) | 3.13 → 1.75 (−44.1%) | 169.4 → 227.3
(+34.2%) | 0.413 → 0.433 | 7,912 → 9,737 (+23.1%) | 612 → 745 |
| Conc 16, MTP5, control: bf16 state, monokernel off → this PR | 1 |
136.5 → 135.1 (−1.1%) | 220.1 → 227.4 (+3.3%) | 3.07 → 2.26 (−26.4%) |
88.7 → 88.9 (+0.2%) | 0.962 → 1.008 | 26,986 → 27,220 (+0.9%) | 2,532 →
2,548 |

| Rows | µs a KDA launch, f32 → bf16 | µs a step of 41 launches, f32 →
bf16 |
| --- | --- | --- |
| 2 | 43.5 → 42.6 (−2.1%) | 1,879 → 1,837 (−2.3%) |
| 4 | 54.5 → 52.5 (−3.8%) | 2,335 → 2,248 (−3.7%) |
| 8 | 81.1 → 77.3 (−4.7%) | 3,434 → 3,330 (−3.0%) |
| 12 | 112.8 → 107.8 (−4.5%) | 4,893 → 4,756 (−2.8%) |
| 16 | 128.2 → 124.1 (−3.2%) | 5,539 → 5,411 (−2.3%) |

Server, this PR at conc 4:

```bash
export PYTHONPATH=<sgl-amd-mono>:<sglang>/python HSA_NO_SCRATCH_RECLAIM=1
export SGLANG_SIMULATE_ACC_LEN=2.99 SGLANG_SIMULATE_ACC_METHOD=match-expected SGLANG_SIMULATE_ACC_TOKEN_MODE=real-draft-token
export SGLANG_DSA_MQA_LOGITS_FREE_MEM_FRACTION=0.04 SGLANG_TIMEOUT_KEEP_ALIVE=900 AITER_QUICK_REDUCE_QUANTIZATION=INT4 ROCM_QUICK_REDUCE_QUANTIZATION=INT4
python3 -m sglang.launch_server --model-path amd/GLM-5.3-Flash-Quark-MXFP4 --served-model-name amd/GLM-5.3-Flash-Quark-MXFP4 --host 0.0.0.0 --port 30204 --trust-remote-code --tp 4 --ep-size 1 --kv-cache-dtype bfloat16 --dsa-prefill-backend tilelang --dsa-decode-backend tilelang --moe-runner-backend aiter --mamba-radix-cache-strategy extra_buffer --tool-call-parser glm47 --reasoning-parser glm45 --chunked-prefill-size 16384 --mem-fraction-static 0.85 --max-running-requests 8 --cuda-graph-max-bs-decode 8 --cuda-graph-backend-prefill breakable --cuda-graph-max-bs-prefill 2560 --model-loader-extra-config '{"enable_multithread_load": true, "num_threads": 32}' --mamba-full-memory-ratio 0.9 --speculative-algorithm EAGLE --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4 --watchdog-timeout 1800 --enable-metrics --mamba-ssm-dtype bfloat16 --enable-amd-monokernel
```

| Concurrency | `--speculative-num-steps` /
`--speculative-num-draft-tokens` | `SGLANG_SIMULATE_ACC_LEN` |
`--max-running-requests`, `--cuda-graph-max-bs-decode` |
| --- | --- | --- | --- |
| 1 | 5 / 6 | 3.56 | 8 |
| 4 | 3 / 4 | 2.99 | 8 |
| 8 | 3 / 4 | 2.99 | 16 |

| Side | Differs from the command above |
| --- | --- |
| `main` | No `--mamba-ssm-dtype bfloat16`; the image's sgl-amd-mono
(`7113024`) on `PYTHONPATH` |
| bf16 state, monokernel off | No `--enable-amd-monokernel`; only
`<sglang>/python` on `PYTHONPATH` |

Client: aiperf from InferenceX `bee3405ca` (`utils/aiperf` at
`754356e9`):

```bash
export AIPERF_HTTP_TCP_USER_TIMEOUT=900000
aiperf profile --scenario inferencex-agentx-mvp --url http://localhost:30204 --endpoint /v1/chat/completions --endpoint-type chat --streaming --model amd/GLM-5.3-Flash-Quark-MXFP4 --tokenizer amd/GLM-5.3-Flash-Quark-MXFP4 --concurrency 4 --benchmark-duration 3600 --stats-interval 30 --random-seed 42 --failed-request-threshold 0.10 --trajectory-start-min-ratio 0.25 --trajectory-start-max-ratio 0.75 --warmup-requests-per-lane 10 --trace-idle-gap-cap-seconds 300 --warmup-grace-period 1800 --use-server-token-count --no-gpu-telemetry --tokenizer-trust-remote-code --num-dataset-entries 393 --slice-duration 1.0 --public-dataset semianalysis_cc_traces_weka_062126 --server-metrics http://localhost:30204/metrics
```

<details><summary>Aggregate JSONs: per concurrency, the round whose P90
change is nearest the 3-round mean (conc 1 round 1, conc 4 round 3, conc
8 round 1), `main` and this PR</summary>

<details><summary>Conc 1, MTP5, round 1, `main`, f32 state (GPUs
0–3)</summary>

```json
{
  "hw": "mi355x",
  "conc": 1,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 318,
  "num_requests_successful": 306,
  "request_accounting": {
    "records_total": 318,
    "records_profiled": 306,
    "records_dropped_total": 12,
    "records_warmup_dropped": 11,
    "records_error_dropped": 12,
    "error_categories": {
      "InvalidInferenceResultError": 12
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3601,
      "mean": 0.0847,
      "p50": 0.0,
      "p75": 0.0,
      "p90": 0.0,
      "p95": 1,
      "std": 0.2863
    },
    "latency": {
      "ttft": {
        "mean": 0.40993,
        "p50": 0.30719,
        "p75": 0.38934,
        "p90": 0.72888,
        "p95": 1.17537,
        "std": 0.40643
      },
      "e2el": {
        "mean": 4.74654,
        "p50": 2.56876,
        "p75": 6.36431,
        "p90": 11.65478,
        "p95": 14.94193,
        "std": 5.4926
      },
      "itl": {
        "mean": 0.00217,
        "p50": 0.00214,
        "p75": 0.00223,
        "p90": 0.00233,
        "p95": 0.00248,
        "std": 0.00037
      },
      "tpot": {
        "mean": 0.00217,
        "p50": 0.00214,
        "p75": 0.00223,
        "p90": 0.00233,
        "p95": 0.00248,
        "std": 0.00037
      },
      "intvty": {
        "mean": 461.60688,
        "p50": 467.36214,
        "p75": 447.91133,
        "p90": 429.3704,
        "p95": 403.43802,
        "std": 61.17044
      },
      "e2e_norm_intvty": {
        "mean": 285.00999,
        "p50": 398.05247,
        "p75": 316.50997,
        "p90": 211.93999,
        "p95": 141.76316,
        "std": 104.23052
      },
      "full_response_itl": {
        "mean": 0.00217,
        "p50": 0.00214,
        "p75": 0.00223,
        "p90": 0.00233,
        "p95": 0.00248,
        "std": 0.00037
      },
      "full_response_intvty": {
        "mean": 461.33557,
        "p50": 467.28996,
        "p75": 447.87024,
        "p90": 429.30347,
        "p95": 403.39441,
        "std": 59.78446
      }
    },
    "tokens": {
      "input": {
        "mean": 307501.29412,
        "p50": 339536.5,
        "p75": 446983.75,
        "p90": 556716.5,
        "p95": 589717.5,
        "std": 180326.84704
      },
      "output_actual": {
        "mean": 2004.16013,
        "p50": 864.5,
        "p75": 2771,
        "p90": 5082.5,
        "p95": 6834.25,
        "std": 2551.34657
      },
      "output_expected": {
        "mean": 2165.48693,
        "p50": 1133.5,
        "p75": 3047.75,
        "p90": 5445.5,
        "p95": 6908.25,
        "std": 2792.8635
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 26106.92354
      },
      "output": {
        "tokens_per_second": 170.15361
      },
      "total": {
        "tokens_per_second": 26277.07715
      },
      "duration_seconds": 3604.23149,
      "per_gpu": {
        "total_tput_tps": 6569.26929,
        "output_tput_tps": 42.5384,
        "input_tput_tps": 6526.73088
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.98318
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 84,
    "cache": {
      "gpu_cache_hit_rate": 0.9678,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.9678,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 91755520
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.05,
      "gpu_total_tokens": 12557568,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 94808292,
      "generation_total": 613275,
      "requests_completed": 306,
      "prompt_by_source": {
        "gpu_cache_hit": 91755520,
        "cpu_or_external_cache_hit": null,
        "computed": 3702551,
        "raw": {
          "device": 91755520
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 12557568
}
```

</details>

<details><summary>Conc 1, MTP5, round 1, this PR, bf16 state (GPUs
4–7)</summary>

```json
{
  "hw": "mi355x",
  "conc": 1,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 321,
  "num_requests_successful": 309,
  "request_accounting": {
    "records_total": 321,
    "records_profiled": 309,
    "records_dropped_total": 12,
    "records_warmup_dropped": 11,
    "records_error_dropped": 11,
    "error_categories": {
      "InvalidInferenceResultError": 11
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3600,
      "mean": 0.08556,
      "p50": 0.0,
      "p75": 0.0,
      "p90": 0.0,
      "p95": 1,
      "std": 0.28657
    },
    "latency": {
      "ttft": {
        "mean": 0.41493,
        "p50": 0.31432,
        "p75": 0.38678,
        "p90": 0.7464,
        "p95": 1.17341,
        "std": 0.40785
      },
      "e2el": {
        "mean": 4.58431,
        "p50": 2.46243,
        "p75": 6.12533,
        "p90": 11.20629,
        "p95": 14.44469,
        "std": 5.27578
      },
      "itl": {
        "mean": 0.00209,
        "p50": 0.00207,
        "p75": 0.00216,
        "p90": 0.00224,
        "p95": 0.00236,
        "std": 0.00034
      },
      "tpot": {
        "mean": 0.00209,
        "p50": 0.00207,
        "p75": 0.00216,
        "p90": 0.00224,
        "p95": 0.00236,
        "std": 0.00034
      },
      "intvty": {
        "mean": 478.0586,
        "p50": 482.67949,
        "p75": 462.10087,
        "p90": 445.51982,
        "p95": 423.31773,
        "std": 56.24082
      },
      "e2e_norm_intvty": {
        "mean": 290.23001,
        "p50": 410.94209,
        "p75": 320.96833,
        "p90": 224.43585,
        "p95": 153.11824,
        "std": 107.76823
      },
      "full_response_itl": {
        "mean": 0.00209,
        "p50": 0.00207,
        "p75": 0.00216,
        "p90": 0.00225,
        "p95": 0.00236,
        "std": 0.00034
      },
      "full_response_intvty": {
        "mean": 477.75773,
        "p50": 482.41996,
        "p75": 461.96984,
        "p90": 445.33398,
        "p95": 423.29703,
        "std": 55.37054
      }
    },
    "tokens": {
      "input": {
        "mean": 310676.3657,
        "p50": 340695,
        "p75": 456942,
        "p90": 560271.4,
        "p95": 596060.6,
        "std": 182290.53959
      },
      "output_actual": {
        "mean": 1997.50162,
        "p50": 867,
        "p75": 2759,
        "p90": 5075.6,
        "p95": 6793,
        "std": 2540.51605
      },
      "output_expected": {
        "mean": 2167.04531,
        "p50": 1139,
        "p75": 3061,
        "p90": 5428.4,
        "p95": 6907.2,
        "std": 2784.2599
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 26643.07345
      },
      "output": {
        "tokens_per_second": 171.30232
      },
      "total": {
        "tokens_per_second": 26814.37577
      },
      "duration_seconds": 3603.15026,
      "per_gpu": {
        "total_tput_tps": 6703.59394,
        "output_tput_tps": 42.82558,
        "input_tput_tps": 6660.76836
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.98339
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 84,
    "cache": {
      "gpu_cache_hit_rate": 0.96826,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.96826,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 93964800
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.05,
      "gpu_total_tokens": 12631040,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 97044560,
      "generation_total": 617231,
      "requests_completed": 309,
      "prompt_by_source": {
        "gpu_cache_hit": 93964800,
        "cpu_or_external_cache_hit": null,
        "computed": 3727368,
        "raw": {
          "device": 93964800
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 12631040
}
```

</details>

<details><summary>Conc 4, MTP3, round 3, `main`, f32 state (GPUs
0–3)</summary>

```json
{
  "hw": "mi355x",
  "conc": 4,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 748,
  "num_requests_successful": 702,
  "request_accounting": {
    "records_total": 748,
    "records_profiled": 702,
    "records_dropped_total": 46,
    "records_warmup_dropped": 44,
    "records_error_dropped": 34,
    "error_categories": {
      "InvalidInferenceResultError": 34
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3596,
      "mean": 0.19494,
      "p50": 0.0,
      "p75": 0.0,
      "p90": 1,
      "p95": 1,
      "std": 0.42723
    },
    "latency": {
      "ttft": {
        "mean": 0.35165,
        "p50": 0.26957,
        "p75": 0.3684,
        "p90": 0.61383,
        "p95": 0.84878,
        "std": 0.41552
      },
      "e2el": {
        "mean": 2.99079,
        "p50": 1.27805,
        "p75": 3.48199,
        "p90": 7.86757,
        "p95": 11.5757,
        "std": 4.55997
      },
      "itl": {
        "mean": 0.00207,
        "p50": 0.00185,
        "p75": 0.00216,
        "p90": 0.00254,
        "p95": 0.00286,
        "std": 0.00124
      },
      "tpot": {
        "mean": 0.00207,
        "p50": 0.00185,
        "p75": 0.00216,
        "p90": 0.00254,
        "p95": 0.00286,
        "std": 0.00124
      },
      "intvty": {
        "mean": 483.81291,
        "p50": 541.31702,
        "p75": 463.76296,
        "p90": 393.22815,
        "p95": 349.8837,
        "std": 1057.54901
      },
      "e2e_norm_intvty": {
        "mean": 239.76049,
        "p50": 378.25688,
        "p75": 292.38831,
        "p90": 201.78607,
        "p95": 131.05537,
        "std": 123.23745
      },
      "full_response_itl": {
        "mean": 0.00206,
        "p50": 0.00185,
        "p75": 0.00216,
        "p90": 0.00254,
        "p95": 0.00286,
        "std": 0.00124
      },
      "full_response_intvty": {
        "mean": 484.61994,
        "p50": 540.49856,
        "p75": 463.56221,
        "p90": 392.96253,
        "p95": 350.0932,
        "std": 631.22029
      }
    },
    "tokens": {
      "input": {
        "mean": 186054.75641,
        "p50": 117045,
        "p75": 248089,
        "p90": 528091.3,
        "p95": 600337.1,
        "std": 181615.04166
      },
      "output_actual": {
        "mean": 1306.79345,
        "p50": 446,
        "p75": 1484.25,
        "p90": 3759.8,
        "p95": 5414.1,
        "std": 2251.41019
      },
      "output_expected": {
        "mean": 1795.09972,
        "p50": 722,
        "p75": 2586.25,
        "p90": 4848,
        "p95": 6303.05,
        "std": 2624.02633
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 36267.87995
      },
      "output": {
        "tokens_per_second": 254.73484
      },
      "total": {
        "tokens_per_second": 36522.61479
      },
      "duration_seconds": 3601.2703,
      "per_gpu": {
        "total_tput_tps": 9130.6537,
        "output_tput_tps": 63.68371,
        "input_tput_tps": 9066.96999
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.97879
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 84,
    "cache": {
      "gpu_cache_hit_rate": 0.95674,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.95674,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 126379776
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.09,
      "gpu_total_tokens": 11822336,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 132094472,
      "generation_total": 917372,
      "requests_completed": 702,
      "prompt_by_source": {
        "gpu_cache_hit": 126379776,
        "cpu_or_external_cache_hit": null,
        "computed": 7163998,
        "raw": {
          "device": 126379776
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 11822336
}
```

</details>

<details><summary>Conc 4, MTP3, round 3, this PR, bf16 state (GPUs
4–7)</summary>

```json
{
  "hw": "mi355x",
  "conc": 4,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 782,
  "num_requests_successful": 736,
  "request_accounting": {
    "records_total": 782,
    "records_profiled": 736,
    "records_dropped_total": 46,
    "records_warmup_dropped": 44,
    "records_error_dropped": 40,
    "error_categories": {
      "InvalidInferenceResultError": 40
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3600,
      "mean": 0.20417,
      "p50": 0.0,
      "p75": 0.0,
      "p90": 1,
      "p95": 1,
      "std": 0.44564
    },
    "latency": {
      "ttft": {
        "mean": 0.37045,
        "p50": 0.27331,
        "p75": 0.37554,
        "p90": 0.61319,
        "p95": 0.84718,
        "std": 0.54372
      },
      "e2el": {
        "mean": 2.98412,
        "p50": 1.28455,
        "p75": 3.37288,
        "p90": 8.0563,
        "p95": 10.84711,
        "std": 4.54257
      },
      "itl": {
        "mean": 0.00201,
        "p50": 0.00183,
        "p75": 0.00212,
        "p90": 0.0025,
        "p95": 0.00292,
        "std": 0.00115
      },
      "tpot": {
        "mean": 0.00201,
        "p50": 0.00183,
        "p75": 0.00212,
        "p90": 0.0025,
        "p95": 0.00292,
        "std": 0.00115
      },
      "intvty": {
        "mean": 496.84879,
        "p50": 545.63843,
        "p75": 472.45202,
        "p90": 399.43084,
        "p95": 342.44456,
        "std": 365.72962
      },
      "e2e_norm_intvty": {
        "mean": 246.58045,
        "p50": 385.65627,
        "p75": 293.40734,
        "p90": 203.95136,
        "p95": 133.79847,
        "std": 127.84651
      },
      "full_response_itl": {
        "mean": 0.00201,
        "p50": 0.00183,
        "p75": 0.00212,
        "p90": 0.00251,
        "p95": 0.00292,
        "std": 0.00115
      },
      "full_response_intvty": {
        "mean": 497.47395,
        "p50": 545.56149,
        "p75": 472.52118,
        "p90": 398.84685,
        "p95": 342.42402,
        "std": 318.71912
      }
    },
    "tokens": {
      "input": {
        "mean": 187433.25,
        "p50": 119401,
        "p75": 256764,
        "p90": 520505.5,
        "p95": 597327.75,
        "std": 178591.20163
      },
      "output_actual": {
        "mean": 1311.19158,
        "p50": 461.5,
        "p75": 1521,
        "p90": 3721.5,
        "p95": 5353.75,
        "std": 2217.54197
      },
      "output_expected": {
        "mean": 1762.83832,
        "p50": 710,
        "p75": 2525.25,
        "p90": 4848,
        "p95": 5987.25,
        "std": 2582.29357
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 38266.20895
      },
      "output": {
        "tokens_per_second": 267.69173
      },
      "total": {
        "tokens_per_second": 38533.90067
      },
      "duration_seconds": 3605.03107,
      "per_gpu": {
        "total_tput_tps": 9633.47517,
        "output_tput_tps": 66.92293,
        "input_tput_tps": 9566.55224
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.97769
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 84,
    "cache": {
      "gpu_cache_hit_rate": 0.95562,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.95562,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 133247232
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.09,
      "gpu_total_tokens": 11869952,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 139434913,
      "generation_total": 965040,
      "requests_completed": 736,
      "prompt_by_source": {
        "gpu_cache_hit": 133247232,
        "cpu_or_external_cache_hit": null,
        "computed": 7637058,
        "raw": {
          "device": 133247232
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 11869952
}
```

</details>

<details><summary>Conc 8, MTP3, round 1, `main`, f32 state (GPUs
0–3)</summary>

```json
{
  "hw": "mi355x",
  "conc": 8,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 1495,
  "num_requests_successful": 1406,
  "request_accounting": {
    "records_total": 1495,
    "records_profiled": 1406,
    "records_dropped_total": 89,
    "records_warmup_dropped": 87,
    "records_error_dropped": 63,
    "error_categories": {
      "InvalidInferenceResultError": 63
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3604,
      "mean": 0.38984,
      "p50": 0.0,
      "p75": 1,
      "p90": 1,
      "p95": 2,
      "std": 0.63806
    },
    "latency": {
      "ttft": {
        "mean": 0.35241,
        "p50": 0.24357,
        "p75": 0.38177,
        "p90": 0.64611,
        "p95": 0.91981,
        "std": 0.42253
      },
      "e2el": {
        "mean": 3.28926,
        "p50": 1.54664,
        "p75": 3.66411,
        "p90": 7.92539,
        "p95": 11.84163,
        "std": 4.92508
      },
      "itl": {
        "mean": 0.00266,
        "p50": 0.00238,
        "p75": 0.00305,
        "p90": 0.00369,
        "p95": 0.00453,
        "std": 0.00115
      },
      "tpot": {
        "mean": 0.00266,
        "p50": 0.00238,
        "p75": 0.00305,
        "p90": 0.00369,
        "p95": 0.00453,
        "std": 0.00115
      },
      "intvty": {
        "mean": 376.32233,
        "p50": 419.84256,
        "p75": 327.51581,
        "p90": 270.93819,
        "p95": 220.71264,
        "std": 121.40468
      },
      "e2e_norm_intvty": {
        "mean": 235.97839,
        "p50": 323.30414,
        "p75": 241.41353,
        "p90": 175.73987,
        "p95": 137.52826,
        "std": 112.4784
      },
      "full_response_itl": {
        "mean": 0.00265,
        "p50": 0.00238,
        "p75": 0.00305,
        "p90": 0.00369,
        "p95": 0.00453,
        "std": 0.00115
      },
      "full_response_intvty": {
        "mean": 376.87667,
        "p50": 420.29332,
        "p75": 327.64283,
        "p90": 270.86925,
        "p95": 220.72279,
        "std": 211.12236
      }
    },
    "tokens": {
      "input": {
        "mean": 159905.90825,
        "p50": 108280,
        "p75": 180490.75,
        "p90": 383242,
        "p95": 500272.5,
        "std": 139520.26284
      },
      "output_actual": {
        "mean": 1153.84139,
        "p50": 446.5,
        "p75": 1227.75,
        "p90": 2948,
        "p95": 4575.75,
        "std": 1884.50171
      },
      "output_expected": {
        "mean": 1947.96,
        "p50": 1012,
        "p75": 2655.5,
        "p90": 4796,
        "p95": 6727,
        "std": 2500.83018
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 62373.14815
      },
      "output": {
        "tokens_per_second": 450.06918
      },
      "total": {
        "tokens_per_second": 62823.21733
      },
      "duration_seconds": 3604.55923,
      "per_gpu": {
        "total_tput_tps": 15705.80433,
        "output_tput_tps": 112.51729,
        "input_tput_tps": 15593.28704
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.97831
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 86,
    "cache": {
      "gpu_cache_hit_rate": 0.95252,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.95252,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 214711808
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.14,
      "gpu_total_tokens": 11729152,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 225414424,
      "generation_total": 1622304,
      "requests_completed": 1406,
      "prompt_by_source": {
        "gpu_cache_hit": 214711808,
        "cpu_or_external_cache_hit": null,
        "computed": 13396801,
        "raw": {
          "device": 214711808
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 11729152
}
```

</details>

<details><summary>Conc 8, MTP3, round 1, this PR, bf16 state (GPUs
4–7)</summary>

```json
{
  "hw": "mi355x",
  "conc": 8,
  "image": "rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261115",
  "recipe_fingerprint": "",
  "model": "amd/GLM-5.3-Flash-Quark-MXFP4",
  "infmax_model_prefix": "glm5.3flash",
  "framework": "sglang",
  "precision": "fp4",
  "spec_decoding": "mtp",
  "disagg": false,
  "scenario_type": "agentic-coding",
  "is_multinode": false,
  "num_gpus": 4,
  "tp": 4,
  "ep": 1,
  "dp_attention": "false",
  "kv_offloading": "none",
  "kv_offload_backend": null,
  "allocated_cpu_dram_gb": 0,
  "num_requests_total": 1492,
  "num_requests_successful": 1403,
  "request_accounting": {
    "records_total": 1492,
    "records_profiled": 1403,
    "records_dropped_total": 89,
    "records_warmup_dropped": 87,
    "records_error_dropped": 63,
    "error_categories": {
      "InvalidInferenceResultError": 63
    }
  },
  "pp": 1,
  "dcp_size": 1,
  "pcp_size": 1,
  "dataset": {
    "source_type": "public_dataset",
    "loader": "semianalysis_cc_traces_weka_062126",
    "hf_dataset_name": "semianalysisai/cc-traces-weka-062126",
    "hf_split": "train",
    "num_dataset_entries": 393
  },
  "request_metrics": {
    "qps": {
      "window_seconds": 1,
      "samples": 3595,
      "mean": 0.38999,
      "p50": 0.0,
      "p75": 1,
      "p90": 1,
      "p95": 2,
      "std": 0.64492
    },
    "latency": {
      "ttft": {
        "mean": 0.34498,
        "p50": 0.23925,
        "p75": 0.3801,
        "p90": 0.63031,
        "p95": 0.92386,
        "std": 0.39613
      },
      "e2el": {
        "mean": 3.16041,
        "p50": 1.4999,
        "p75": 3.31859,
        "p90": 7.49822,
        "p95": 11.83163,
        "std": 4.8997
      },
      "itl": {
        "mean": 0.00251,
        "p50": 0.00222,
        "p75": 0.00285,
        "p90": 0.00369,
        "p95": 0.00433,
        "std": 0.00113
      },
      "tpot": {
        "mean": 0.00251,
        "p50": 0.00222,
        "p75": 0.00285,
        "p90": 0.00369,
        "p95": 0.00433,
        "std": 0.00113
      },
      "intvty": {
        "mean": 398.56722,
        "p50": 450.82389,
        "p75": 351.14666,
        "p90": 270.68176,
        "p95": 230.72751,
        "std": 130.12662
      },
      "e2e_norm_intvty": {
        "mean": 241.61861,
        "p50": 340.72492,
        "p75": 250.81431,
        "p90": 181.09559,
        "p95": 137.69279,
        "std": 119.93024
      },
      "full_response_itl": {
        "mean": 0.00251,
        "p50": 0.00222,
        "p75": 0.00285,
        "p90": 0.00369,
        "p95": 0.00433,
        "std": 0.00114
      },
      "full_response_intvty": {
        "mean": 399.14382,
        "p50": 450.73379,
        "p75": 351.20374,
        "p90": 270.8554,
        "p95": 230.79718,
        "std": 253.19981
      }
    },
    "tokens": {
      "input": {
        "mean": 159290.32431,
        "p50": 108276,
        "p75": 179177.5,
        "p90": 380991,
        "p95": 497824,
        "std": 138596.33951
      },
      "output_actual": {
        "mean": 1151.67783,
        "p50": 445,
        "p75": 1219.5,
        "p90": 2950.4,
        "p95": 4577.1,
        "std": 1886.39553
      },
      "output_expected": {
        "mean": 1942.7394,
        "p50": 1012,
        "p75": 2654,
        "p90": 4780.4,
        "p95": 6727,
        "std": 2497.69627
      }
    },
    "throughput": {
      "input": {
        "tokens_per_second": 62150.83575
      },
      "output": {
        "tokens_per_second": 449.35397
      },
      "total": {
        "tokens_per_second": 62600.18972
      },
      "duration_seconds": 3595.83781,
      "per_gpu": {
        "total_tput_tps": 15650.04743,
        "output_tput_tps": 112.33849,
        "input_tput_tps": 15537.70894
      }
    },
    "cache": {
      "theoretical_cache_hit_rate": 0.97823
    }
  },
  "server_metrics": {
    "present": true,
    "adapter": "sglang",
    "metric_count": 84,
    "cache": {
      "gpu_cache_hit_rate": 0.95218,
      "cpu_cache_hit_rate": null,
      "external_cache_hit_rate": null,
      "overall_cache_hit_rate": 0.95218,
      "prefix_cache_hits": null,
      "prefix_cache_queries": null,
      "external_prefix_cache_hits": null,
      "external_prefix_cache_queries": null,
      "cached_tokens_by_source": {
        "device": 213355776
      },
      "frontend_cache_hit_rate": null,
      "router_kv_hit_rate": null,
      "router_shared_cache_hit_rate": null,
      "frontend_cached_tokens": null,
      "frontend_input_tokens": null
    },
    "kv_cache": {
      "gpu_usage_pct": 0.12,
      "gpu_total_tokens": 11821824,
      "cpu_usage_pct": null,
      "cpu_used_tokens": null,
      "cpu_total_tokens": null
    },
    "kv_offload": {
      "bytes_gpu_to_cpu": null,
      "bytes_cpu_to_gpu": null,
      "time_gpu_to_cpu": null,
      "time_cpu_to_gpu": null,
      "bandwidth_gpu_to_cpu_bytes_per_second": null,
      "bandwidth_cpu_to_gpu_bytes_per_second": null
    },
    "tokens": {
      "prompt_total": 224071038,
      "generation_total": 1615807,
      "requests_completed": 1403,
      "prompt_by_source": {
        "gpu_cache_hit": 213355776,
        "cpu_or_external_cache_hit": null,
        "computed": 13386341,
        "raw": {
          "device": 213355776
        }
      }
    },
    "sources": []
  },
  "kv_cache_pool_tokens": 11821824
}
```

</details>

</details>

## Checklist

- [x] `pre-commit run --all-files` passes. (The hooks' isort 7.0.0, ruff
0.15.1 and codespell 2.4.1 on the changed files.)
- [x] Tests under `test/` cover the change.
- [x] The SGLang commit or PR this was tested against is named above.
- [x] Accuracy and speed results are attached when kernel or forward
code changes.
- [ ] A new model adds one line to `.github/CODEOWNERS` that names its
owner. (No new model.)
@Raiden-Makoto

Copy link
Copy Markdown
Contributor Author

NVIDIA CI is all green at 0f0f273 (PR Test Base, PR Test Extra).

@Raiden-Makoto

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

2 similar comments
@Raiden-Makoto

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@Raiden-Makoto

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

jhinpan pushed a commit to sgl-project/sgl-amd-mono that referenced this pull request Dec 3, 2026
…ct across CTAs (#188)

## Motivation

At concurrency 1 and 4, time per output token grows with context, and
AgentX's P90 requests are the longest ones. On `main`, each
sparse-attention layer picks a row's top 512 KV pools (160K pools at
640K tokens) on one of the 256 CTAs. This PR splits that select over up
to 32 CTAs for rows past 100K tokens and writes a verify request's cache
rows in one pass; outputs stay bitwise equal. AgentX P90 interactivity:
+12.6% (mean of 3 rounds: +13.9%, +13.1%, +10.7%) at concurrency 1,
+8.2% (mean of 3 rounds: +10.1%, −0.3%, +14.9%) at concurrency 4.

- **SGLang:** `3a41a59919` (the 20261118 image) plus
sgl-project/sglang#49036 and its base #44659, which #141 needs.
- **Base:** `main` below is #141's head `f4df9ec`; its `glm53_flash`
files equal today's `main` (#141 merged as `129e6e5`).
- **Merge order:** #189 changes other lines of `kernel.py`; either order
applies.

## Modifications

The steps the monokernel runs do not change: decode and target-verify
steps of up to 16 rows, TP 2, 4 and 8. No new `SGLANG_READS` key, env
var, `Requirements` entry or fault-injection site. Only the
sparse-attention launch changes.

| File | Change |
| --- | --- |
| `glm53_flash/gfx950/kernel.py` | Pool select: a row's scored pools are
cut into slices of 512 threads × `ISEL_ITEMS` pools, one CTA a slice.
For each of the 4 radix digits, every slice writes its 256-bin
histogram, and each CTA sums the row's histograms to find the same
threshold. Each slice then counts its pools above the threshold and its
ties; a prefix over the slices gives each pool the slot the one-CTA
select gives it. Rows of at most `ISEL_ONE_POOLS` (25,000) pools, 100K
tokens, keep the one-CTA select in their slice 0 task, on the CTA the
one-CTA build gives the row: there the exchanges cost more than they
split. |
| `glm53_flash/gfx950/kernel.py` | Verify cache rows: `cache_chain`
writes a request's 4 or 6 consecutive rows (KV cache, index ring,
completed index pools) in one task: one poll for all rows' inputs, their
norms in one pair of barriers. `main` ran `cache_row` once a row. Decode
steps and pad rows still use `cache_row`. |
| `glm53_flash/gfx950/kernel.py` | `FlashBuild.select_ctas` (default
on). Off builds the one-CTA select for every row; only `check_layer.py
--compare-select` builds it, as the reference. |
| `glm53_flash/gfx950/layout.py` | `ISEL_ONE_POOLS = 25_000`.
`isel_slices(samples, max_pools)`: pools a thread and slices a row (at
most 32, and `samples` × slices ≤ 256 CTAs). Scratch `isel_h` (row ×
digit × slice × 256 counts, 2.0 MiB at the 16-row build) and `isel_c` (8
counts a slice, 16 KiB). The AgentX conc 1 server (widths 6 and 12)
allocates a KV pool of 12,629,760 → 12,629,248 tokens (−512, −0.004%). |
| `test/kernels/glm53_flash/check_layer.py` | `--compare-select`: with
`--check-keys`, the slice select's tokens and the launch's outputs equal
a one-CTA build's, bitwise, every row. |
| `test/kernels/test_glm53_flash_kernels.py` |
`test_long_rows_attend_their_tail` and the 1M-context key check run
`--compare-select`; new case: one launch with 8 rows from 2,051 to
650,000 tokens. Rows up to 100K tokens select on one CTA and longer rows
on up to 32 CTAs, so one launch tests both paths together. |

## Accuracy Tests

The kernel checks hold bitwise. GSM8K and RULER2 below ran on both sides
at once with real acceptance. At 100 samples, PR − `main` reads −3.40
(95% CI −13.5 to +6.5) at 300K `mv_niah_hard` and 0.00 (±7.0) at 640K
`mk_niah_hard`: within noise.

| Item | Setup |
| --- | --- |
| Kernel check | MI355X, TP4 unless named. `--check-keys` compares the
selected pools with a torch top-512; `--compare-select` with the one-CTA
select; `--verify L` checks a verify launch against its draft tokens'
decode launches (outputs, caches, kpool rings) |
| End to end | `amd/GLM-5.3-Flash-Quark-MXFP4`, TP4, MTP3 with real
acceptance, BF16 KV, bf16 KDA state, TileLang DSA,
`--max-running-requests 8 --cuda-graph-max-bs-decode 8`; `main` (GPUs
0–3) and this PR (GPUs 4–7) at once, each with its own `HOME` |
| GSM8K | sgl-eval, 1319 questions, thinking, temperature 1.0, top-p
0.95, 4096 tokens, seed 0 |
| RULER2 NIAH | sgl-eval, thinking, 8192 tokens, 4 threads; the command
below, and `--ruler2-dataset-size 100` with one task (`mv_niah_hard` at
300K, `mk_niah_hard` at 640K) for 100 samples |

| Kernel check | Rows a launch, context | Result |
| --- | --- | --- |
| Slice select vs one-CTA select, `--check-keys --compare-select` | 4
rows, short; 8 rows at 400,001, 262,150, 331,001, 65,537, 2,051, 3,000,
262,148, 100,003 tokens | tokens and outputs equal, every row and rank |
| Same, 16 rows | the 8 above plus 1, 2, 262,144, 262,145, 4,097, 500,
128, 129 | tokens and outputs equal, every row; the check fails on row 8
(1 token) as on `main`: perturbing its one token does not change the row
|
| Verify launch vs its decode launches, `--verify` | width 8 with 2, 4,
6 and 8 rows a request; width 16, 4 rows a request; width 12, 6 rows a
request; width 8, 4 rows a request at 400,001 and 300,003 tokens; width
8, 6 rows at 262,147 | equal |
| Two launches back to back, `--launches 2` | 8 rows to 400,001 tokens |
equal |
| Rows on both sides of the one-CTA threshold (100K tokens),
`--check-keys --compare-select` | 4 and 8 rows to 650,000 tokens:
100,003, 100,007, 99,999, 65,537, 3,000, 2,051, 262,150, 650,000 |
tokens and outputs equal, every row |
| Negative control: each slice's prefix includes its own counts |
`--kind dsa --max-len 655360 --max-pools 262144 --rows 4 --check-keys
--compare-select --lens 331001,262149,650000,100003` | fails, 41 `False`
|
| `test/kernels/test_glm53_flash_kernels.py` (8 GPUs) | TP 2, 4, 8 | 11
passed |
| `test/unit` | CPU | 644 passed, 12 failed; `main` fails the same 12,
none a `glm53_flash` test (`kimi_k3`, `kimi_k31`, `qwen35_a17b` and
`qwen38_flash_next` contracts, `kimi_k3` and `kimi_k31` drift, three
`glm53` tests) |

| GSM8K 1319, seed 0 | Accuracy | Accept length |
| --- | --- | --- |
| `main` | 97.27% (1283/1319) | 3.218 |
| this PR | 96.66% (1275/1319) | 3.204 |

| RULER2 NIAH, 20 samples a task, score (%) | 300K `main` | 300K this PR
| 640K `main` | 640K this PR |
| --- | --- | --- | --- | --- |
| `mk_niah_basic` | 100.00 | 100.00 | 100.00 | 100.00 |
| `mk_niah_hard` | 75.00 | 80.00 | 100.00 | 85.00 |
| `mv_niah_basic` | 97.50 | 98.75 | 98.75 | 96.25 |
| `mv_niah_hard` | 60.38 | 60.00 | 35.03 | 25.03 |
| All four, mean | 83.22 | 84.69 | 83.45 | 76.57 |

| RULER2, 100 samples, score (%) | `main` | this PR | This PR − `main`
(paired bootstrap 95% CI) | Samples higher, this PR / `main` |
| --- | --- | --- | --- | --- |
| `mv_niah_hard` at 300K | 55.26 | 51.86 | −3.40 (−13.48 to +6.47) | 13
/ 18 |
| `mk_niah_hard` at 640K | 88.00 | 88.00 | +0.00 (−7.00 to +7.00) | 6 /
6 |

```bash
python3 -m sgl_eval.cli run ruler2 --base-url http://127.0.0.1:30260/v1 --ruler2-seq-len 640000 \
  --ruler2-tokenizer amd/GLM-5.3-Flash-Quark-MXFP4 --ruler2-dataset-size 20 \
  --ruler2-tasks mk_niah_basic mk_niah_hard mv_niah_basic mv_niah_hard --num-threads 4 --max-tokens 8192 \
  --chat-template-kwarg enable_thinking=true --out-dir niah/pr_640000
```

## Speed Tests and Profiling

Cells read `main` → this PR. P90 interactivity: +12.6% (mean of 3
rounds: +13.9%, +13.1%, +10.7%) at conc 1, +8.2% (mean of 3 rounds:
+10.1%, −0.3%, +14.9%) at conc 4; the conc 16 control −0.4%. At conc 1
the chunk gap from 75K to 625K tokens grows 6.72 → 8.09 ms on `main` and
6.66 → 7.04 ms here (figure). One 6-row request's launch is 4–40% faster
from 2K to 600K tokens.

| Item | Setup |
| --- | --- |
| AgentX | The image above, TP4, 3,600-s windows after InferenceX's
warmup, golden accept length. Both sides use the same command; only the
sgl-amd-mono tree on `PYTHONPATH` differs. `main` and this PR at once on
one node, `main` on GPUs 0–3 in rounds 1 and 3, on 4–7 in round 2 |
| Control point | Conc 16, MTP5 (6 rows a request): steps of 3 or more
requests pass the 16-row width and run SGLang's path; one round |
| Kernel-only | `time_layers.py --kind dsa --layers 11 --reps 100
--trials 5 --state-bf16`, TP4, µs a sparse-attention launch; `main` and
this PR alternated, two rounds (mean shown) |

| Concurrency | Round, `main` GPUs | P90 interactivity (tok/s/user) |
P50 interactivity (tok/s/user) | P90 E2E-normalized interactivity
(tok/s/user) | P90 TTFT (s) | Total tok/s/GPU | Requests completed |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Conc 1, MTP5 | 1, 0–3 | 438.4 → 499.4 (+13.9%) | 476.6 → 513.9 (+7.8%)
| 267.6 → 269.4 (+0.7%) | 0.370 → 0.363 | 6,754 → 7,020 (+3.9%) | 310 →
316 |
| Conc 1, MTP5 | 2, 4–7 | 438.1 → 495.5 (+13.1%) | 476.5 → 514.5 (+8.0%)
| 269.1 → 273.2 (+1.5%) | 0.381 → 0.369 | 6,726 → 7,021 (+4.4%) | 309 →
316 |
| Conc 1, MTP5 | 3, 0–3 | 440.3 → 487.4 (+10.7%) | 476.9 → 515.1 (+8.0%)
| 265.5 → 272.2 (+2.5%) | 0.377 → 0.356 | 6,754 → 7,030 (+4.1%) | 310 →
316 |
| Conc 4, MTP3 | 1, 0–3 | 385.8 → 424.9 (+10.1%) | 549.2 → 597.3 (+8.8%)
| 232.9 → 233.2 (+0.1%) | 0.377 → 0.406 | 9,228 → 9,591 (+3.9%) | 712 →
729 |
| Conc 4, MTP3 | 2, 4–7 | 392.8 → 391.5 (−0.3%) | 543.8 → 592.8 (+9.0%)
| 232.9 → 237.1 (+1.8%) | 0.363 → 0.402 | 9,185 → 9,837 (+7.1%) | 709 →
749 |
| Conc 4, MTP3 | 3, 0–3 | 396.4 → 455.3 (+14.9%) | 557.9 → 595.8 (+6.8%)
| 237.9 → 235.8 (−0.9%) | 0.426 → 0.376 | 9,395 → 10,073 (+7.2%) | 727 →
744 |
| Conc 16, MTP5, control | 1, 0–3 | 177.2 → 176.6 (−0.4%) | 263.3 →
257.7 (−2.1%) | 130.5 → 128.6 (−1.4%) | 0.663 → 0.667 | 27,903 → 27,858
(−0.2%) | 2619 → 2611 |
| Mean, conc 1 | | 439.0 → 494.1 (+12.6%) | 476.7 → 514.5 (+7.9%) | | |
6,745 → 7,024 (+4.1%) | |
| Mean, conc 4 | | 391.7 → 423.9 (+8.2%) | 550.3 → 595.3 (+8.2%) | | |
9,270 → 9,834 (+6.1%) | |

Conc 4 round 2's P90 requests shared steps with a second request more
often (below); with stalls removed (gaps past twice a request's median,
mostly others' prefill) every round rises 12–15%.

| Conc 4, MTP3, `main` → this PR | Round 1 | Round 2 | Round 3 |
| --- | --- | --- | --- |
| P90 interactivity with each request's stalls removed (tok/s/user) |
406.2 → 465.4 (+14.6%) | 408.2 → 459.6 (+12.6%) | 415.9 → 472.4 (+13.6%)
|
| Mean decode batch of the P85–P95 requests by TPOT | 1.98 → 1.86 | 1.94
→ 2.12 | 1.86 → 1.71 |

![Median gap between output chunks against context, AgentX conc 1, bs-1
requests](https://gist.githubusercontent.com/Jacob0226/22608f2dc735633bbb849bd7bfc6eeee/raw/pr188_gap_ctx_c1_r3.png)

x: a bs-1 request's context (ISL + OSL / 2); y: its median gap between
streamed chunks (one verify cycle); lines: the median of each 50K-token
bin of at least 10 requests. The same, by context:

| Median chunk gap (ms), requests at decode batch 1, conc 1 round 3, by
context | `main` | this PR |
| --- | --- | --- |
| 0–100K | 6.71 | 6.64 (−1.0%) |
| 100–200K | 6.85 | 6.76 (−1.3%) |
| 200–300K | 7.15 | 6.84 (−4.3%) |
| 300–400K | 7.47 | 6.93 (−7.2%) |
| 400–500K | 7.65 | 6.95 (−9.2%) |
| 500–600K | 7.87 | 6.99 (−11.2%) |
| 600–800K | 8.09 | 7.05 (−12.9%) |

| Rows a launch | Context (tokens) | µs a sparse-attention launch,
`main` → this PR |
| --- | --- | --- |
| 8 (1 × MTP5) | 2,048 | 112.3 → 105.3 (−6.2%) |
| 8 (1 × MTP5) | 32,768 | 120.2 → 114.1 (−5.1%) |
| 8 (1 × MTP5) | 65,536 | 128.2 → 122.0 (−4.8%) |
| 8 (1 × MTP5) | 100,000 | 137.2 → 131.7 (−4.0%) |
| 8 (1 × MTP5) | 131,072 | 145.2 → 131.2 (−9.6%) |
| 8 (1 × MTP5) | 200,000 | 161.4 → 135.7 (−15.9%) |
| 8 (1 × MTP5) | 450,000 | 215.8 → 145.6 (−32.5%) |
| 8 (1 × MTP5) | 600,000 | 249.1 → 150.4 (−39.6%) |
| 8 (2 × MTP3) | 200,000 | 179.3 → 145.4 (−18.9%) |
| 16 (4 × MTP3) | 200,000 | 263.2 → 259.0 (−1.6%) |
| 2, decode | 200,000 | 120.4 → 99.8 (−17.1%) |
| 8, decode | 200,000 | 228.8 → 210.2 (−8.1%) |
| 16, decode | 200,000 | 383.8 → 393.4 (+2.5%) |

16 decode rows × 13 slices fill 208 of the 256 CTAs (+2.5%); the MTP
servers above never build that launch.

Server, this PR at conc 1:

```bash
export PYTHONPATH=<sgl-amd-mono>:<sglang>/python HSA_NO_SCRATCH_RECLAIM=1
export SGLANG_SIMULATE_ACC_LEN=3.56 SGLANG_SIMULATE_ACC_METHOD=match-expected SGLANG_SIMULATE_ACC_TOKEN_MODE=real-draft-token
export SGLANG_DSA_MQA_LOGITS_FREE_MEM_FRACTION=0.04 SGLANG_TIMEOUT_KEEP_ALIVE=900 AITER_QUICK_REDUCE_QUANTIZATION=INT4 ROCM_QUICK_REDUCE_QUANTIZATION=INT4
python3 -m sglang.launch_server --model-path amd/GLM-5.3-Flash-Quark-MXFP4 --served-model-name amd/GLM-5.3-Flash-Quark-MXFP4 --host 0.0.0.0 --port 29301 --trust-remote-code --tp 4 --ep-size 1 --kv-cache-dtype bfloat16 --dsa-prefill-backend tilelang --dsa-decode-backend tilelang --moe-runner-backend aiter --mamba-radix-cache-strategy extra_buffer --tool-call-parser glm47 --reasoning-parser glm45 --chunked-prefill-size 16384 --mem-fraction-static 0.85 --max-running-requests 8 --cuda-graph-max-bs-decode 8 --cuda-graph-backend-prefill breakable --cuda-graph-max-bs-prefill 2560 --model-loader-extra-config '{"enable_multithread_load": true, "num_threads": 32}' --mamba-full-memory-ratio 0.9 --mamba-ssm-dtype bfloat16 --hybrid-cache-checkpoints-level 3 --speculative-algorithm EAGLE --speculative-num-steps 5 --speculative-eagle-topk 1 --speculative-num-draft-tokens 6 --watchdog-timeout 1800 --enable-metrics --enable-amd-monokernel
```

| Concurrency | `--speculative-num-steps` /
`--speculative-num-draft-tokens` | `SGLANG_SIMULATE_ACC_LEN` |
`--max-running-requests`, `--cuda-graph-max-bs-decode` |
| --- | --- | --- | --- |
| 1 | 5 / 6 | 3.56 | 8 |
| 4 | 3 / 4 | 2.99 | 8 |
| 16 | 5 / 6 | 3.56 | 32 |

Client: aiperf from InferenceX `bee3405ca` (`utils/aiperf` at
`754356e9`):

```bash
export AIPERF_HTTP_TCP_USER_TIMEOUT=900000
aiperf profile --scenario inferencex-agentx-mvp --url http://localhost:29301 --endpoint /v1/chat/completions --endpoint-type chat --streaming --model amd/GLM-5.3-Flash-Quark-MXFP4 --tokenizer amd/GLM-5.3-Flash-Quark-MXFP4 --concurrency 1 --benchmark-duration 3600 --stats-interval 30 --random-seed 42 --failed-request-threshold 0.10 --trajectory-start-min-ratio 0.25 --trajectory-start-max-ratio 0.75 --warmup-requests-per-lane 10 --trace-idle-gap-cap-seconds 300 --warmup-grace-period 1800 --use-server-token-count --no-gpu-telemetry --tokenizer-trust-remote-code --num-dataset-entries 393 --slice-duration 1.0 --public-dataset semianalysis_cc_traces_weka_062126 --server-metrics http://localhost:29301/metrics
```

Aggregate JSONs of every point:
[gist](https://gist.github.com/Jacob0226/22608f2dc735633bbb849bd7bfc6eeee)

## Checklist

- [x] `pre-commit run --all-files` passes.
- [x] Tests under `test/` cover the change.
- [x] The SGLang commit or PR this was tested against is named above.
- [x] Accuracy and speed results are attached when kernel or forward
code changes.
- [ ] A new model adds one line to `.github/CODEOWNERS` that names its
owner. (No new model.)

This branch has not been deployed

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

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants