Experiment 007

PD × Monokernel

GLM-5.3 FP8 on MI355X: AMD's fused decode kernels behind prefill-decode disaggregation over MoRI, measured on InferenceX AgentX against one node and against two nodes of the same hardware.

MI355X 上的 GLM-5.3 FP8: 把 AMD 的融合 decode kernel 放到基于 MoRI 的 PD 分离后面, 在 InferenceX AgentX 上分别和单节点、同样硬件的两节点服务对比。

Hardware硬件2 × 8 MI355X · 8 × 400G RoCE / node
Image镜像sglang-rocm v0.5.23 (2026-11-05)
Model模型GLM-5.3 FP8 · TP8 · MTP 3/1/4
Client客户端InferenceX AgentX · 900 s
Change改动sgl-amd-mono#136
Data数据data/glm53-pd-monokernel-mi355x

01Question问题

TileRT reports 469 tok/s per user for GLM-5.3 on eight MI355X by decoding one request at a time inside a single persistent kernel and handing prefill to another server (TileRT blog). Our own first PD runs looked twice as slow as one node. That raised two questions. Why was PD slow? And can PD together with AMD's monokernels beat the single-node monokernel curve on the AgentX chart, whose default axes are P90 E2E-normalized interactivity (x) and total tokens per second per GPU (y)?

TileRT 公布的数据是: 在 8 张 MI355X 上, GLM-5.3 的单用户速度达到 469 tok/s。 做法是用一个常驻 kernel 一次只 decode 一个请求, prefill 交给另一台服务(TileRT 博客)。 我们最初的 PD 测试看起来比单节点慢一倍, 于是有了两个问题: PD 为什么慢?PD 加上 AMD 的 monokernel, 能不能在 AgentX 图上超过单节点 monokernel 的曲线?这张图默认的 x 轴是 P90 E2E 归一化交互性, y 轴是每 GPU 的总吞吐量。

Verdict. Disaggregation does not make decode faster; the decode kernel does. Our PD decode server ran SGLang's own path because the monokernel refused every PD server. Once it accepts a MoRI decode server, per-user decode speed rises from 213 to 474 tok/s at concurrency 1, with the same GSM8K score. On the same 16 GPUs, though, 1P1D does not beat two single-node replicas on this workload: about 95% of prompt tokens hit the prefix cache, so the prefill node idles while it doubles the GPU count. The lever for the chart is monokernel coverage at mid concurrency.

结论。 PD 分离本身不会让 decode 变快, 变快靠的是 decode kernel。 我们的 PD decode 服务走的是 SGLang 自己的路径, 因为 monokernel 拒绝所有 PD 服务。 让它接受使用 MoRI 的 decode 服务之后, c1 的单用户 decode 速度从 213 提高到 474 tok/s, GSM8K 不变。 但在同样的 16 张卡上, 对这个负载来说, 1P1D 超不过两份单节点副本: 约 95% 的 prompt token 命中 prefix cache, prefill 节点大部分时间空闲, 却让 GPU 数量翻了一倍。 对这张图来说, 真正有用的是 monokernel 在中等并发下的覆盖率。

02Setup实验设置

Three deployments serve the same model, image, recipe and client. Everything differs only in where prefill and decode run and how many GPUs are counted.

三种部署使用同样的模型、镜像、recipe 和客户端, 区别只在 prefill 和 decode 在哪里运行, 以及计入多少张 GPU。

Plate I · three ways to spend GPUs三种使用 GPU 的方式
A · agg, one node (8 GPUs) prefill + decode share 8 GPUs monokernel on decode steps ≤ 8 rows = 2 × 4 tokens B · agg, two nodes + router (16) node 1node 2 c / 2 usersc / 2 users cache_aware C · PD 1P1D + router (16) prefillstock path decodemonokernel KV over MoRI, 8 × 400G pd router tok/s/GPU divides by every GPU drawn: 8 for A, 16 for B and C.

B is the honest baseline for C: same GPUs, same users, only the split of work changes.

B 才是 C 的公平基线: GPU 一样, 用户一样, 变的只是工作怎么分。

Why not compare PD with one node at half the concurrency? Because the AgentX client replays a different set of sessions at each concurrency, so "one node at c/2" serves a different workload. B serves the identical trace set at the same total concurrency, with a cache-aware router so that a session's turns keep landing where their prefix is cached.

为什么不直接拿 PD 和“单节点跑一半并发”比较?因为 AgentX 客户端在每个并发档位回放的会话集合不同, “单节点 c/2”跑的其实是另一份负载。 B 在同样的总并发下回放同一组 trace, router 按缓存分流, 让同一个会话的后续轮次落在已经缓存了它前缀的节点上。

Method: fresh servers for every point; 900-s window after 10 warmup requests per lane; MTP acceptance simulated at 2.94 as the InferenceX recipe does (realized 2.95 in every run); quality arms use real acceptance. A run counts only if neither server nor router restarted, no KV transfer failed, and the window holds at most one request error. Run-to-run spread, from two fresh single-node servers at concurrency 1: tok/s/GPU −0.6%, ITL −0.5%, E2EL P90 −4.0%, TTFT P50 −11.8%, P90 E2E-normalized interactivity +25%.

方法: 每个点都新起服务;每条通道先跑 10 个 warmup 请求, 再测 900 秒;MTP acceptance 按 InferenceX recipe 模拟为 2.94(每次运行实测都是 2.95);质量测试使用真实 acceptance。 一次运行只有在服务和 router 都没有重启、没有 KV 传输失败、测量窗口内最多 1 个请求错误时才计入。 同一配置跑两次的波动(单节点 c1, 两次新起服务): 吞吐量 −0.6%, ITL −0.5%, E2EL P90 −4.0%, TTFT P50 −11.8%, P90 E2E 归一化交互性 +25%。

03Quality质量

GSM8K, all 1319 questions, strict match, concurrency 2, real MTP acceptance. The comparison is paired: McNemar counts the questions one arm gets right and the other gets wrong, which is what changes when a code path is wrong.

GSM8K 全部 1319 题, strict match, 并发 2, 真实 MTP acceptance。 比较方式是配对的: McNemar 只统计“一边对、另一边错”的题目, 代码路径出错时变化的正是这部分。

arm测试臂GSM8Konly ref right仅基线对only arm right仅本臂对p
agg, no monokernel (reference)agg, 无 monokernel(基线)0.9750———
agg, monokernelagg, monokernel0.9750551.000
PD, no decode radixPD, 无 decode radix0.9773250.453
PD + decode radixPD + decode radix0.9742541.000
PD + decode radix + decode monokernelPD + decode radix + decode monokernel0.9742541.000

Why not greedy token parity? On this FP8 + MTP stack two fresh servers without monokernels already differ on near-tie tokens, so a parity gate would fail correct code. The 32 greedy prompts are kept only as a liveness check: every arm returns text for all of them.

为什么不用 greedy 逐 token 对比?在这个 FP8 + MTP 的栈上, 两个新起的、不开 monokernel 的服务, 在概率接近的 token 上就已经会不一样, 所以逐 token 对比会把正确的代码判为错误。 32 条 greedy prompt 只用来确认服务能正常返回: 每个测试臂都全部返回了内容。

04PD with and without monokernelsPD 开关 monokernel

Why the PD decode server ran the slow path

为什么 PD 的 decode 服务走了慢路径

A monokernel is a fused kernel for a narrow set of server configurations, so each model's spec declares the features it was validated with, and SGLang's binding refuses to start when a feature in use is missing from that list. PD disaggregation is one such feature: setting --disaggregation-mode marks it in use. The DeepSeek-V4.1 spec declares it (sgl-amd-mono#70); the GLM-5.3 spec did not, so a GLM-5.3 PD server either refused --enable-amd-monokernel or ran without it.

monokernel 是为一小组服务配置专门融合的 kernel, 所以每个模型的 spec 都会声明它验证过哪些功能;只要正在使用的某个功能不在这个列表里, SGLang 就拒绝启动。 PD 分离就是这样一个功能: 设置 --disaggregation-mode 就算在使用。 DeepSeek-V4.1 的 spec 声明了它(sgl-amd-mono#70), GLM-5.3 的没有, 所以 GLM-5.3 的 PD 服务要么拒绝 --enable-amd-monokernel, 要么只能不开它运行。

The change (sgl-amd-mono#136) declares the feature on the target and NextN draft specs and refuses every PD role except a decode server on MoRI. Decode only, because prefill steps are long chunks that the monokernel was never built for. Safe on decode, because the kernels read only the MLA KV cache and the indexer's key cache, and SGLang's DSA pool hands both to the transfer engine, so MoRI fills exactly the buffers the kernels read. MoRI only, because that is the backend this was validated on; another backend would be an untested claim.

这次的改动(sgl-amd-mono#136)在 target 和 NextN draft 的 spec 里声明了这个功能, 并且只放行使用 MoRI 的 decode 服务, 其他 PD 角色一律拒绝。 只放行 decode, 是因为 prefill 跑的是长分块, monokernel 本来就不是为它设计的。 在 decode 上是安全的, 因为 kernel 只读 MLA KV cache 和 indexer 的 key cache, 而 SGLang 的 DSA 池会把这两块都交给传输引擎, MoRI 填的正好是 kernel 要读的缓冲区。 只放行 MoRI, 是因为只在这个后端上验证过, 换别的后端就是没有验证过的说法。

Plate II · per-user decode speed, PDPD 的单用户 decode 速度
0250500 213474205467 208466148162 c1c2c4c10 off decode monokernel on

Interactivity P50 (tok/s/user) of 1P1D with the decode radix cache. Past 2 requests a step the monokernel hands the step back, which is why c10 gains only 10%.

1P1D(开 decode radix cache)的单用户速度 P50(tok/s/user)。 每步超过 2 个请求时, monokernel 会把这一步交回 SGLang 自己的路径, 所以 c10 只提高 10%。

concmonokernelmonokernelintvty P50 / P90ITL P50 / P90 msTTFT P50 sE2EL P90 stok/s/GPU
1off关213 / 2004.69 / 4.990.3114.611308
1on开474 / 4322.11 / 2.320.308.721448
2off关205 / 1714.88 / 5.840.3915.051186
2on开467 / 3212.14 / 3.110.419.441373
4off关208 / 1644.82 / 6.090.2521.131263
4on开466 / 2522.15 / 3.960.2410.141706
10off关148 / 1216.77 / 8.250.3617.454108
10on开162 / 1286.18 / 7.840.3413.244231

One trap on the way. The PD router checks the prefill server's /health with a 5-s timeout. A prefill busy with 32K-token cold chunks of 200K-token contexts misses three checks in a row, the router marks it dead, and every request fails with “no available prefill workers”. The PD points with monokernels use a 120-s timeout; a run in which no check times out routes identically either way.

中途踩到的一个坑。 PD router 检查 prefill 服务的 /health 时, 默认超时是 5 秒。 prefill 正在处理 20 万 token 上下文的冷启动分块(每块 32K token), 连续 3 次没能及时回应, router 就判定它挂了, 之后所有请求都报“no available prefill workers”。 开 monokernel 的 PD 点都把超时改成了 120 秒;只要运行中没有出现检查超时, 两种设置下的路由行为完全一样。

05Against single-node serving对比单节点服务

Against one node with monokernels, PD wins the tail from concurrency 2 up: at c4 its ITL P90 is 3.96 ms against 7.14 ms, because another user's prefill no longer shares the decode GPUs. It pays about half the tokens per GPU, since it uses twice the GPUs for the same users.

和开 monokernel 的单节点相比, 从 c2 起 PD 在尾延迟上占优: c4 时它的 ITL P90 是 3.96 ms, 单节点是 7.14 ms, 因为其他用户的 prefill 不再和 decode 共用同一批 GPU。 代价是每张 GPU 的吞吐量只有一半左右, 因为同样的用户用了两倍的 GPU。

The fair comparison is B, two single-node replicas on the same 16 GPUs:

公平的比较对象是 B, 也就是同样 16 张卡上的两份单节点副本:

concdeployment部署GPUsintvty P50 / P90ITL P50 / P90 msTTFT P50 sE2EL P90 stok/s/GPU
4one node单节点8390 / 1402.57 / 7.140.2211.483636
4two nodes两节点16456 / 1652.19 / 6.060.219.671876
4PD + mono16466 / 2522.15 / 3.960.2410.141706
10one node单节点8124 / 838.07 / 12.030.3016.638021
10two nodes两节点16216 / 1304.62 / 7.680.239.354492
10PD + mono16162 / 1286.18 / 7.840.3413.244231

Why does disaggregation lose here? Its benefit is isolating decode from prefill, and its price is a node that only prefills. On these agentic traces about 95% of prompt tokens are prefix-cache hits, so each turn's new prefill is a few thousand tokens and the prefill node sits idle most of the time. Two replicas spend the same GPUs on decode for half the users each, which shrinks each node's decode batch, and smaller batches are exactly where the monokernel applies. PD keeps an edge only in the tail at c4; at c10 the two replicas lead on median interactivity (216 against 162), TTFT, E2EL and tokens per GPU, and the tails are even.

为什么 PD 在这里会输?它的好处是把 decode 和 prefill 隔开, 代价是有一台节点只做 prefill。 在这批 agentic trace 上, 约 95% 的 prompt token 命中 prefix cache, 每一轮新的 prefill 只有几千个 token, prefill 节点大部分时间空闲。 两份副本把同样的 GPU 都用在 decode 上, 每份只服务一半用户, 每台节点的 decode 批次就变小了, 而批次小正是 monokernel 能起作用的情况。 PD 只在 c4 的尾延迟上还保有优势;到 c10, 两份副本在交互性中位数(216 对 162)、TTFT、E2EL 和每 GPU 吞吐量上都领先, 尾部持平。

06The AgentX axesAgentX 的两个轴

The dashboard's AgentX chart plots P90 E2E-normalized interactivity against total tokens per second per GPU (InferenceX's published_metrics.py). Published points come from InferenceX's own 3600-s runs (API; TileRT's run). Our points are 900-s local runs, so their x values sit lower and are compared only with each other.

仪表盘的 AgentX 图把 P90 E2E 归一化交互性和每 GPU 总吞吐量画在一起(见 InferenceX 的 published_metrics.py)。 公开的点来自 InferenceX 自己的 3600 秒运行(API;TileRT 的运行记录)。 我们的点是本地 900 秒的运行, x 值整体偏低, 只在彼此之间比较。

Plate III · x: P90 E2E-normalized interactivity · y: tok/s/GPUx: P90 E2E 归一化交互性 · y: 每 GPU 吞吐量
published · 3600 s TileRT c1 (16) sglang FP8 mono (8) c1c2c4c10 4010014009000 local · 900 s mono c22 nodes c10mono c10 PD + mono c4 c1c4c1c2c10c4 40100140 one node (8) two nodes (16) PD + mono (16)

Left: TileRT's single point is already below and left of the published single-node monokernel curve. Right: the local frontier (dashed) is one node at c2, two nodes at c10 and one node at c10; no PD point reaches it.

左: TileRT 唯一的点已经落在公开的单节点 monokernel 曲线左下方。 右: 本地数据的前沿(虚线)由单节点 c2、两节点 c10 和单节点 c10 组成, PD 的点一个都没有到达前沿。

TileRT's interactivity comes from batch-1 decode, and so does its cost: at 16 GPUs for one user, its tokens per GPU are about half of a single node's. The published single-node monokernel point at c1 (128.4, 2834 tok/s/GPU on 8 GPUs) sits above and to the right of TileRT's (98.4, 1534 on 16). The question the chart actually poses is therefore whether we can move our own curve, and PD on this workload is not the way.

TileRT 的交互性来自 batch 为 1 的 decode, 代价也来自这里: 一个用户占 16 张卡, 每张卡的吞吐量只有单节点的一半左右。 公开的单节点 monokernel c1 点(128.4, 8 张卡 2834 tok/s/GPU)在 TileRT(98.4, 16 张卡 1534)的右上方。 所以这张图真正的问题是: 能不能把我们自己的曲线往右上推?在这个负载上, PD 不是办法。

07Coverage覆盖率

The published curve falls from 122.8 at c4 to 58.7 at c10. The decode logs say why: at c10 only 35% of decode steps carry at most two requests, the most the monokernel takes, and every wider step runs the stock path.

公开曲线从 c4 的 122.8 掉到 c10 的 58.7。 decode 日志说明了原因: c10 时只有 35% 的 decode 步骤同时最多只有 2 个请求, 这是 monokernel 能处理的上限, 更宽的步骤都走了 SGLang 自己的路径。

Plate IV · requests per decode step, one node at c10单节点 c10 每个 decode 步骤的请求数
1234567891011 8 rows: 35% 12 rows: 47% 16 rows: 61% 32 rows: 98% running requests in a decode step (MTP: 4 rows each)

1095 samples, one every 40 decode steps. At c4 the same count is 96%, so widening the kernel mostly matters from c6 up.

共 1095 个样本, 每 40 个 decode 步骤采样一次。 c4 时同样的比例是 96%, 所以加宽 kernel 主要对 c6 以上有意义。

Why only 8 rows? A step of MTP verify carries 4 tokens per request, so 8 rows is 2 requests. The kernel keeps a workgroup's working set in its local data share, with a static budget of 32,768 words (128 KiB). Several stages stage every row there at once; the tail and the NextN entry hold each row's hidden state in bf16, 3,072 words a row at GLM-5.3's hidden size of 6,144, so 12 rows alone need 36,864 words. The easy way out is one launch per 8 rows, which reads every weight once per launch. That is acceptable for the tail, which runs once a step, but not for every layer, where avoiding weight re-reads is the reason a decode monokernel exists. The layers have to fit 12 rows into the same budget.

为什么只有 8 行?MTP verify 的每一步, 每个请求带 4 个 token, 所以 8 行就是 2 个请求。 kernel 把一个 workgroup 的工作数据放在 LDS 里, 静态预算是 32768 个字(128 KiB)。 有几个阶段要一次性把所有行都放进 LDS: tail 和 NextN 入口阶段要保存每一行的 bf16 hidden state, GLM-5.3 的 hidden size 是 6144, 每行占 3072 个字, 12 行就要 36864 个字。 最省事的办法是每 8 行启动一次, 但每次启动都要把权重再读一遍。 tail 每步只跑一次, 可以接受;每一层都这样做就不行了, 因为 decode monokernel 存在的意义就是避免重复读权重。 所以每一层都必须在同样的预算里放下 12 行。

08Widening to 12 rows加宽到 12 行

Twelve rows (3 requests) would lift c10 coverage from 35% to 47%. The work is in progress; this is where it stands. Each limit below surfaced only after the previous one was gone, through the repository's own layer check (test/kernels/glm53/check_layer.py, random weights, eight GPUs) and a server run with per-layer comparison against SGLang.

12 行(3 个请求)能把 c10 的覆盖率从 35% 提到 47%。 这项工作还在进行, 下面是目前的状态。 下面每一处限制, 都是在解决了前一处之后才暴露出来的, 用的是仓库自带的逐层检查工具(test/kernels/glm53/check_layer.py, 随机权重, 8 张卡)和一次逐层对比 SGLang 参考实现的服务运行。

Plate V · the 12-row path through one decode step一个 decode 步骤里 12 行要经过的路径
step tablespow-2 range input proj.per-group units attentionnew-row region routerunchanged up/gate → down4-row groups tail8 + 4 launch NextNcap 8 green: works at 12 rows · red: verify rows time out at the down stage's wait for the FP8 mid tile check_layer at 12 rows: shared p0, dense v4, head pass · shared v4, index v4 deadline

Dense layers already match SGLang at 12 rows (streams cosine 0.99993); the first MoE layer is where verify-shaped batches stop.

dense 层在 12 行下已经和 SGLang 吻合(streams 的 cosine 为 0.99993), MTP verify 形状的批次停在第一个 MoE 层。

#limit限制change改法status状态
1the width table stops at 8宽度表只到 8add 12加入 12done已完成
2the tail stages all rows in LDStail 要把所有行放进 LDSan 8-row and a 4-row launch that write one shared output; the step's synchronization counts both拆成 8 行和 4 行两次启动, 写入同一份输出;这一步的同步计数把两次启动都算进去done已完成
3the NextN entry has the same LDS needNextN 入口有同样的 LDS 需求draft widths capped at 8; wider draft steps take SGLang's pathdraft 宽度限制在 8, 更宽的 draft 步骤走 SGLang 路径done已完成
4the indexer projection streams half its weight units, which only one group of 8 rows can consumeindexer 投影只先发出一半权重单元, 流式发出的部分只够一组 8 行使用each group of rows issues its own units每组行各自重新发出权重单元done已完成
5this step's new KV rows are staged in a region that holds 8 rows at TP8本步新写入的 KV 行暂存的区域, 在 TP8 下只放得下 8 行stage them past the arena when they overflow (layouts up to 8 rows unchanged)放不下时暂存到工作区末尾(8 行及以下布局不变)done已完成
6a Triton table kernel's arange needs a power of 2一个 Triton 表 kernel 的 arange 需要 2 的幂range over the next power of 2, masked to the width范围改用下一个 2 的幂, 按宽度加 maskdone已完成
7MoE up/gate → down hand-off laid out for two groups of 4 rowsMoE 从 up 和 gate 到 down 的交接按两个 4 行组设计regroup the down stage's tasks for three groups按 3 个组重新划分 down 阶段的任务open未解决

How the last one was found: a wait that never completes sets a per-GPU error word to its site number plus one, and site numbers are handed out in trace order. Logging each site's call stack while the kernel is traced mapped the failing wait to the down stage's poll of the FP8 mid tile. One-request-per-row batches pass at 12 rows and verify batches do not, which points at how rows that pick the same experts are grouped, not at the buffers' sizes.

最后这一处是这样找到的: 一个永远等不到的等待, 会把这张 GPU 的错误字设为它的等待位置编号加 1, 而等待位置编号是 kernel 追踪时按顺序分配的。 在追踪时记录每个等待位置的调用栈, 就把超时的等待对应到了 down 阶段对 FP8 中间结果的轮询上。 每个请求 1 行的批次在 12 行下能通过, verify 批次不能, 这说明问题出在“选中相同 expert 的多行怎么分组”, 而不是缓冲区大小。

09Reproduce复现

The exact server, router and client commands, with host names replaced by placeholders, are in commands.md. Every table above is a view of a CSV next to it: agentx_l1.csv (23 runs), gsm8k.csv, decode_batch_sizes.csv, inferencex_published.csv and width12_kernel_checks.csv.

服务、router 和客户端的完整命令写在 commands.md 里, 主机名换成了占位符。 上面每张表都来自同目录下的 CSV: agentx_l1.csv(23 次运行)、gsm8k.csv、decode_batch_sizes.csv、inferencex_published.csv 和 width12_kernel_checks.csv。

10Epilogue结语

Three things carry over to the next model. A disaggregation result needs a baseline that spends the same GPUs, or it measures "one more node" instead of "a different split". Per-GPU throughput charges PD for its prefill node, so PD pays off when prefill is expensive and contends with decode; agentic traces with high prefix-cache hit rates are the opposite case. And on the AgentX chart the decode kernel's coverage is the lever: the width that a fused kernel can take decides where the curve bends. The previous entry in this line, Experiment 006, is how the single-node monokernel curve got where it is.

有三点可以用到下一个模型上。 第一, 评估 PD 分离时, 基线必须用同样多的 GPU, 否则测到的是“多了一台机器”, 而不是“换了一种分工”。 第二, 按每 GPU 吞吐量算, PD 要为 prefill 节点买单, 所以只有 prefill 很重、并且会和 decode 争抢资源时, PD 才划算;prefix cache 命中率很高的 agentic trace 恰恰相反。 第三, 在 AgentX 图上, 起决定作用的是 decode kernel 的覆盖范围: 一个融合 kernel 能处理多宽的步骤, 决定了曲线在哪里拐弯。 这个系列的上一篇 Experiment 006 讲的是单节点 monokernel 的曲线是怎么一步步推上来的。