01The short version先给结论
Together Compiler (TKCC) recasts inference optimization from a compiler translation problem into an agentic search problem, and then spends most of its engineering on one thing: making every agent experiment both fast and trustworthy.
Together Compiler(TKCC) 把推理优化从一个编译器翻译问题, 改写成一个由 agent 驱动的搜索问题; 然后把大部分工程投入到一件事上: 让每一次 agent 实验既快又可信。
The argument runs in four steps:
论文的论证分四步:
- The target moves. Inference traffic drifts on a timescale of days, so the best forward pass is a moving target (§3).
- 目标在动。 推理流量以天为单位漂移, 所以最快的 forward pass 是一个移动的目标(§3)。
- Agents are only as good as their measurements. Offline kernel benchmarks on random data are fast and misleading; relaunching a full engine per experiment is faithful and slow (§3).
- agent 的上限取决于测量。 用随机数据跑离线 kernel 基准又快又误导; 每次实验都重启整个引擎则可信但太慢(§3)。
- Keep the engine, swap the forward pass. TKCC keeps one engine resident and hot-reloads candidate forward passes, with a fast tier to filter and a slow tier to confirm; a cost model picks the parallelism to start from (§4.2, §4.3).
- 引擎常驻, 只换 forward pass。 TKCC 让一个引擎常驻, 热加载候选 forward pass: 快档负责筛选, 慢档负责确认; 再用成本模型选出起步的并行配置(§4.2、 §4.3)。
- Then delete the scaffolding. A custom IR, a knowledge base, expert strategies and research logs all lowered the ceiling once agents got good enough (§4.4).
- 然后拆掉脚手架。 自定义 IR、 知识库、 专家策略和研究日志, 在 agent 足够强之后都压低了上限(§4.4)。
What it means for us
对我们意味着什么
Three things transfer directly to AMD. Build the persistent engine before the agents: without it, every idea costs minutes of cold start. Measure on real inputs: the paper's cautionary top-k kernel was a HIP kernel for GLM-5.3's indexer on MI350-class GPUs. On MI355X, look for wins in fusing communication into compute and in tuning-table gaps, where the paper's agents found them, before betting on persistent kernels. And treat any IR as a verifier, not as the optimization surface.
有三点可以直接迁移到 AMD。 先建常驻引擎, 再上 agent: 没有它, 每个想法都要付出几分钟的冷启动。 用真实输入测量: 论文里那个反面教材 top-k kernel, 正是 GLM-5.3 indexer 在 MI350 系列 GPU 上的 HIP kernel。 在 MI355X 上, 先到 「通信融进计算」 和 「调优表缺口」 里找收益, 那是论文的 agent 实际找到收益的地方, 然后才考虑押注常驻 kernel。 此外, 把 IR 当作验证器, 而不是优化的操作面。
02Why a compiled forward pass goes stale编译好的 forward pass 为什么会过时
Start from first principles. The fastest forward pass is a function of three inputs: the model, the hardware and the traffic. A classic compiler treats the first two as fixed and the third as absent. Together's production data says the third moves fast (§3):
从第一性原理出发。 最快的 forward pass 是三个输入的函数: 模型、 硬件和流量。 传统编译器把前两个当作固定值, 而把第三个当作不存在。 Together 的生产数据说明, 第三个变化得很快(§3):
- Behavior: the same model sees an input length of about 97k tokens during one country's working hours and about 70k off-hours.
- 行为: 同一个模型, 在某国工作时间的输入长度约 97k token, 非工作时间约 70k。
- Bursts: one customer's P90 input length grew from 18k to 33k tokens in three days, output length from 1k to 1.9k, and the cache hit rate fell 4 points.
- 突发: 某客户的 P90 输入长度在三天内从 18k 涨到 33k, 输出长度从 1k 涨到 1.9k, cache 命中率下降 4 个百分点。
- Gradual shift: a lab's new checkpoint doubled output length; another model's context drifted from 10K to 18K while its cache hit rate rose 8% in two weeks.
- 渐变: 某实验室的新 checkpoint 让输出长度翻倍; 另一个模型的上下文在两周内从 10K 漂到 18K, cache 命中率上升 8%。
If traffic shifts in days and a hand-tuned kernel takes weeks, the kernel is always tuned for last month's traffic. The only way out is a loop whose iteration time is much shorter than the drift time. That single requirement drives every design decision that follows. The paper's own example shows why it matters: on Kimi K3, a persistent MoE down-projection is 2.8–5% faster at concurrency 22–78 but 6.6% slower at concurrency 8, so TKCC applies it by active batch size (§5.2).
如果流量以天为单位变化, 而一个手调 kernel 要花几周, 那么 kernel 永远是为上个月的流量调的。 唯一的出路, 是一个迭代周期远短于漂移周期的循环。 后面所有设计决定, 都由这一个要求推出来。 论文自己的例子说明了它的重要性: 在 Kimi K3 上, 常驻式 MoE down-projection 在并发 22–78 时快 2.8–5%, 在并发 8 时却慢 6.6%, 所以 TKCC 按当前 batch 大小决定是否启用它(§5.2)。
Why not autotune once per model? Because the optimum depends on the traffic regime (batch size, input length, cache hit rate), and the regime moves after deployment. Why not let agents loop on offline kernel benchmarks? Because that trades the drift problem for a fidelity problem, which Plate I lays out.
为什么不每个模型调一次就够了? 因为最优解取决于流量状态(batch 大小、 输入长度、 cache 命中率), 而部署之后流量状态会变。 为什么不让 agent 在离线 kernel 基准上循环? 因为那只是把漂移问题换成了保真度问题, 图版 I 说明了这一点。
The two existing options sit at opposite corners. TKCC's move is to keep fidelity by keeping the real engine, and to win back throughput by never restarting it. Candidate counts are from GLM 5.3 on B200 (Figure 2).
现有的两种做法处在相反的两个角上。 TKCC 的做法是: 保留真实引擎来保住保真度, 再通过永不重启来夺回吞吐。 候选数量来自 B200 上的 GLM 5.3(图 2)。
03What Inductor misses, and the rules behind itInductor 漏掉了什么, 背后是什么规律
Part 1 of the road blog examines Torch Inductor on Llama 1B (669 tokens per second at batch 1) and finds three failures. Each generalizes into a rule that any compiler, including ours, has to answer.
road 博客的第一部分在 Llama 1B 上检查了 Torch Inductor(batch 1 时 669 tokens/s), 发现了三个问题。 每个问题都可以推广成一条规律, 任何编译器(包括我们的) 都要面对。
Rule 1 · Search, don't guess规律 1 · 搜索, 而不是猜
Inductor's freezing flag gives +10–26% at large batch sizes but −49% at batch size 1, because a weight conversion to FP32 is not undone for matrix-vector work, so decode streams 32-bit weights. Inductor exposes 607 flags, 198 of them added in the past year, and they interact: aggressive_fusion alone costs 6 TPS, but together with three other flags it gains 3. A space this large and this non-separable is a search problem.
Inductor 的 freezing 开关在大 batch 时带来 +10–26%, 在 batch 1 时却是 −49%: 权重被转成 FP32 后, 矩阵-向量运算没有把它转回来, 于是 decode 读的是 32 位权重。 Inductor 有 607 个开关, 其中 198 个是过去一年新增的, 而且它们相互影响: 单开 aggressive_fusion 损失 6 TPS, 和另外三个开关一起开却提升 3 TPS。 这么大、 又不可分解的空间, 是一个搜索问题。
Rule 2 · Measure inside the real forward pass, on real data规律 2 · 在真实 forward pass 里、 用真实数据测量
Inductor flushes L2 before benchmarking, so isolated timings run 39–58% slower than in the live forward pass, where kernels reuse cached data. Zero-filled token IDs make an embedding 2.1× faster than random ones. The harness reports 2.5 µs for an operation that does no GPU work. These errors produce wrong choices: a Triton GEMM at 7.4 µs picked over cuBLAS at 6.4 µs (15% slower), and MoE grouped-GEMM timings that are 4–21% off on GLM 5.3 with synthetic inputs.
Inductor 在基准测试前会清空 L2, 所以单独测出的时间比真实 forward pass 慢 39–58%, 因为真实运行中 kernel 会复用缓存数据。 token ID 全填 0 时, embedding 比随机 ID 快 2.1 倍。 测试框架对一个不做任何 GPU 工作的操作报出 2.5 µs。 这些误差会导致错误的选择: 选了 7.4 µs 的 Triton GEMM, 而不是 6.4 µs 的 cuBLAS(慢 15%); 在 GLM 5.3 上用合成输入测 MoE grouped GEMM, 误差达 4–21%。
Rule 3 · Fuse for utilization, not only for memory规律 3 · 为利用率融合, 而不只为访存融合
Inductor's greedy pairwise fusion scores memory savings, so it keeps apart an elementwise kernel that launches 6 CTAs on a 132-SM GPU and the indexing kernel after it, because they share no memory. Merging them would put idle SMs to work. The criterion was wrong, not the legality check.
Inductor 的贪心两两融合按节省的访存打分, 所以它没有融合两个 kernel: 一个是在 132 个 SM 的 GPU 上只启动 6 个 CTA 的逐元素 kernel, 另一个是紧跟其后的索引 kernel, 理由是它们没有共享内存访问。 把它们合并, 就能让空闲的 SM 干活。 错的是判断标准, 而不是合法性检查。
Why this matters beyond Inductor
为什么不只是 Inductor 的问题
These are the limits of any heuristic compiler: local rules, synthetic measurements, one objective. They apply to our stack too. In FlyDSL, 43 of the 60 kernel test files build their inputs with torch.randn, torch.rand or torch.randint (at e2a2b1f). That is fine for correctness smoke tests and risky for any kernel whose work depends on the data.
这些是所有启发式编译器的局限: 局部规则、 合成测量、 单一目标。 它们同样适用于我们的工具链。 在 FlyDSL 里, 60 个 kernel 测试文件中有 43 个用 torch.randn、 torch.rand 或 torch.randint 生成输入(e2a2b1f)。 这对正确性冒烟测试没问题, 但对工作量依赖数据的 kernel 有风险。
04Deleting megakernels: where the speed came from删掉 megakernel: 速度到底从哪来
Megakernels attacked three inefficiencies of kernel-by-kernel execution: launch overhead, limited overlap between operations, and load imbalance across SMs. The hand-written Llama 1B megakernel ran the whole forward pass in one persistent kernel with specialized warps and paged shared memory, and reached 990 TPS, 48% over Inductor. In production, after months of work, it supported one model, one batch size (1), one precision (BF16) and one customer.
megakernel 针对的是逐个 kernel 执行的三种低效: 启动开销、 操作之间缺少重叠、 以及 SM 之间负载不均。 手写的 Llama 1B megakernel 用一个常驻 kernel 跑完整个 forward pass, 配合专用 warp 和分页的 shared memory, 达到 990 TPS, 比 Inductor 高 48%。 而在生产环境里, 花了几个月之后, 它只支持一个模型、 一个 batch 大小(1)、 一种精度(BF16) 和一个客户。
The authors then asked the decisive question: was it fast because everything ran in one kernel, or because one kernel enabled a few specific optimizations? They answered it with an ablation ladder, starting from Inductor and adding one primitive at a time.
作者接着问了一个关键问题: 它快, 是因为所有东西都在一个 kernel 里, 还是因为这一个 kernel 顺带实现了几项具体优化? 他们用一组逐级消融来回答: 从 Inductor 出发, 每次只加一种原语。
Two driver-level primitives on stock Inductor kernels recover 98% of the hand-written megakernel; removing its memory paging costs only 990 → 961. The TKCC bar is drawn open-ended because the blog reports "over 1,100". On B200, TKCC reaches 2,118 TPS against the megakernel's 1,649.
在默认 Inductor kernel 上只加两个驱动层原语, 就追回了手写 megakernel 98% 的性能; 去掉它的内存分页, 只从 990 降到 961。 TKCC 的柱子画成开口, 因为博客只写了 「超过 1,100」。 在 B200 上, TKCC 达到 2,118 TPS, megakernel 是 1,649。
Launch overhead. PyTorch's ATen dispatch costs 37 µs for a down-projection whose GPU work takes 15 µs; a bare C++ launch still costs about 2 µs. CUDA Graphs bring it to about 1 µs: 864 TPS. Programmatic Dependent Launch (PDL) lets the next kernel's blocks start as SMs free up; the authors inserted griddepcontrol.launch_dependents and griddepcontrol.wait into Inductor's PTX: 953 TPS. Moving the wait to just before the first read of the predecessor's output lets the consumer preload its weights while the producer finishes: 975 TPS, with no new kernel written.
启动开销。 PyTorch 的 ATen 分发, 对一个 GPU 工作只需 15 µs 的 down-projection 要花 37 µs; 裸 C++ 启动仍要约 2 µs。 CUDA Graphs 把它降到约 1 µs: 864 TPS。 PDL(Programmatic Dependent Launch) 让下一个 kernel 的 block 在 SM 空出来时就开始执行; 作者在 Inductor 生成的 PTX 里插入了 griddepcontrol.launch_dependents 和 griddepcontrol.wait: 953 TPS。 再把 wait 挪到第一次读取上游输出之前, 下游就能在上游收尾时预取自己的权重: 975 TPS, 一行新 kernel 都没写。
A grid barrier inside a persistent kernel costs about as much as a fresh launch with CUDA Graphs and PDL, so a megakernel trades launch overhead for synchronization rather than removing it. Cost is measured from the end of kernel one to after the synchronization in kernel two. No AMD row exists yet.
常驻 kernel 内部的一次 grid 屏障, 代价和用 CUDA Graphs + PDL 重新启动一个 kernel 差不多。 所以 megakernel 是用同步换掉了启动开销, 而不是把它消除了。 计时范围从第一个 kernel 结束, 到第二个 kernel 里同步完成之后。 目前还没有 AMD 的数据。
Overlap is smaller than advertised. In the H100 megakernel, three of the five producer–consumer edges in a layer need a full barrier and a fourth is effectively full (one CTA waits on 128). Only attention benefits from compute overlap. Memory preloading through paged shared memory is worth about 3.3%: without it, the megakernel drops from 990 to 961 TPS. Waiting loader warps even cost time: at attention → o_proj, spinning adds 1.3 µs over plain PDL; at down_proj → QKV, bandwidth is already saturated, so early loads slow one kernel by 2.2 µs and speed the next by the same amount.
重叠没有宣传的那么大。 在 H100 megakernel 里, 一层中五条生产者-消费者边有三条需要完整屏障, 第四条实际上也是完整的(一个 CTA 要等 128 个)。 只有 attention 能真正受益于计算重叠。 通过分页 shared memory 做的内存预取只值约 3.3%: 去掉它, megakernel 只从 990 降到 961 TPS。 等待中的 loader warp 甚至会耗时: 在 attention → o_proj 处, 自旋比普通 PDL 多花 1.3 µs; 在 down_proj → QKV 处, 带宽已经饱和, 提前加载会让前一个 kernel 慢 2.2 µs, 后一个快同样多。
One launch envelope for every operation. All work inside a persistent kernel shares one warp count, register budget and cluster shape. Short decode operations wanted 20 warps, but Hopper's wgmma accumulates in registers, so heavy GEMMs run best at 12; forcing 20 makes them 1.2–1.5× slower. The paper adds that "alternative hardwares like AMD run into the same constraints". A whole-model binary also overflows the instruction cache. Modern models make it worse: Kimi K3's KDA and MLA layers want different cta_group modes that PTX forbids mixing in one kernel; tensor-parallel MoE GEMMs and data-parallel projections want different cluster sizes (5–19% slower when forced together).
所有操作共用一个启动形状。 常驻 kernel 里的所有工作, 共用同一个 warp 数、 寄存器预算和 cluster 形状。 短小的 decode 操作想要 20 个 warp, 但 Hopper 的 wgmma 把累加器放在寄存器里, 所以重的 GEMM 在 12 个 warp 时最快; 强行用 20 个会慢 1.2–1.5 倍。 论文还指出, 「AMD 等其他硬件也会遇到同样的限制」。 把整个模型塞进一个二进制, 还会撑爆指令缓存。 新模型让问题更严重: Kimi K3 的 KDA 层和 MLA 层需要不同的 cta_group 模式, 而 PTX 不允许在一个 kernel 里混用; 张量并行的 MoE GEMM 和数据并行的投影需要不同的 cluster 大小(强行合在一起会慢 5–19%)。
Sometimes splitting is faster. Under imbalanced routing, moving Kimi K3's expert dispatch onto the copy engine beat a MoE megakernel by 6.9%, and FlashInfer's MegaMoE ran 17% faster with dispatch factored into its own small kernel.
有时拆开反而更快。 在路由不均衡时, 把 Kimi K3 的专家分发交给 copy engine, 比一个 MoE megakernel 快 6.9%; FlashInfer 的 MegaMoE 把分发拆成一个单独的小 kernel 后, 快了 17%。
The transferable idea
可以迁移的思想
A fused kernel is a bundle of optimizations plus a set of constraints. Unbundle the optimizations, keep each one that survives on its own, and pay for the constraints only where they buy something. In the authors' words, the task is to "identify the right group of operations to couple and individually tune". TKCC's agents later reached up to 1.7× the megakernel on Llama 1B.
一个融合 kernel, 是一组优化加上一组约束。 把这些优化拆开, 保留每一个能单独成立的, 只在约束能换来收益的地方才付出它。 用作者的话说, 要做的是 「找出该耦合在一起的那组操作, 并分别调优」。 TKCC 的 agent 后来在 Llama 1B 上做到了 megakernel 的最高 1.7 倍。
05The Tiered Persistent Engine分层常驻引擎
Problem first. Starting MiniMax-M3.1-Flash on TensorRT-LLM takes 761 seconds before the first request is served: 265 s of model loading, 73 s of KV-cache sizing, 192 s of autotuning, and 34 s plus 192 s of CUDA-graph capture for decode and prefill (Table 1a). If every experiment pays that, an agent gets a few measurements per hour. Offline benchmarks avoid the cost but measure the wrong thing (Section 03).
先看问题。 在 TensorRT-LLM 上启动 MiniMax-M3.1-Flash, 要 761 秒才能服务第一个请求: 加载模型 265 秒、 估算 KV cache 73 秒、 autotuning 192 秒, 再加上 decode 和 prefill 的 CUDA graph 捕获 34 秒和 192 秒(表 1a)。 如果每次实验都付这个代价, 一个 agent 每小时只能拿到几次测量。 离线基准能避开这个代价, 但测的不是真实情况(第 03 节)。
The engine loads the model once; agents only swap the forward pass. The fast tier filters and absorbs crashes, the slow tier confirms on more layers, and a verification suite gates what reaches production. When traffic drifts, the loop runs again.
引擎只加载一次模型, agent 只替换 forward pass。 快档负责筛选并吸收崩溃, 慢档在更多层上确认, 验证套件决定什么能进入生产。 流量漂移时, 循环再跑一遍。
The key observation is that engine startup and forward-pass computation are separable. TKCC starts the production engine once and adds one RPC endpoint. An agent writes its candidate forward pass to a file and submits it; each rank writes the file, executes it, replaces model.forward with the candidate and re-captures CUDA or HIP graphs; teardown restores the baseline and unloads the candidate's modules (Figure 3). Two smaller changes add throughput: requests are reused so their prompts stay in the prefix cache (2.6× lower measurement latency on Kimi K3), and kernel binaries are cached across submissions.
关键观察是: 引擎启动和 forward pass 计算可以分开。 TKCC 只启动一次生产引擎, 并加一个 RPC 接口。 agent 把候选 forward pass 写进一个文件并提交; 每个 rank 写下文件、 执行它、 用候选替换 model.forward, 然后重新捕获 CUDA 或 HIP graph; 结束时恢复基线, 并卸载候选的模块(图 3)。 另有两处小改动进一步提高吞吐: 复用同一批请求, 让 prompt 一直留在 prefix cache 里(Kimi K3 上测量延迟降低 2.6 倍); 以及在多次提交之间缓存 kernel 二进制。
Almost all of the cold start is work unrelated to the forward pass under test. Hot reload keeps it out of the loop; what remains is mostly graph re-capture.
冷启动的几乎全部时间, 都花在与被测 forward pass 无关的工作上。 热加载把这些工作挡在循环之外, 剩下的主要是重新捕获 graph。
Two tiers split the job of measurement:
两档测量各司其职:
| Metric指标 | Fast tier快档 | Slow tier慢档 |
|---|---|---|
| Layers served加载的层数 | 12 | 60 |
| Startup to first job启动到第一个任务 | 3 min3 分钟 | 11 min11 分钟 |
| Hot reload热加载 | 17 s17 秒 | 45 s45 秒 |
| Median job任务耗时中位数 | 28 s28 秒 | 64 s64 秒 |
| Measurement variance测量方差 | 0.05% | 0.14% |
| Crashes per 1,000 jobs每 1,000 个任务的崩溃数 | 3.9 | 0 |
The fast tier is both a sieve and a crash shield: it absorbs illegal memory accesses and hangs that would otherwise force expensive restarts, and it traces kernels for per-kernel reports. The slow tier serves more layers, so it shows whether a win survives data-dependent behavior. On GLM 5.3 on B200, two tiers evaluated 1,354 candidates against 168 for a slow tier alone, and found a solution 7.2% faster (Figure 2).
快档既是筛子, 也是防崩溃的挡板: 它吸收那些原本会逼着引擎重启的非法内存访问和挂起, 并追踪 kernel, 生成逐 kernel 的报告。 慢档加载的层更多, 能看出一个收益在依赖数据的行为下是否还成立。 在 B200 的 GLM 5.3 上, 两档方案评估了 1,354 个候选, 只用慢档时是 168 个, 最终方案快 7.2%(图 2)。
Fidelity also means low noise. Back-to-back runs of the same forward pass vary by 4–6%, while a real optimization can be worth 1%. Splitting prefill and decode measurements cuts back-to-back variance from 6.6% to 2.7%, and the number of measured layers is tuned per workload before the search starts.
保真也意味着噪声低。 同一个 forward pass 连续跑两次, 结果会差 4–6%, 而一个真实的优化可能只值 1%。 把 prefill 和 decode 分开测量, 连续两次的方差从 6.6% 降到 2.7%; 搜索开始前, 还会按工作负载调好需要测量的层数。
The result is 252× more agent experiments and 11× less idle time per agent than relaunching the engine for each measurement. Throughput is still the binding constraint: agents spend more than half their time waiting for measurement gates (Table 6).
结果是: 和每次测量都重启引擎相比, agent 实验次数多 252 倍, 每个 agent 的空等时间少 11 倍。 但吞吐仍然是瓶颈: agent 有一半以上的时间在等测量结果(表 6)。
| Model (platform)模型(平台) | Waiting for gate等待测量 | Thinking and coding思考和写代码 | Other其他 |
|---|---|---|---|
| GLM-5.3 (AMD MI350X) | 57.0% | 36.9% | 6.1% |
| GLM-5.3 (NVIDIA B200) | 55.0% | 35.7% | 9.3% |
| MiniMax M3.1 Flash (NVIDIA B200) | 52.7% | 40.4% | 6.9% |
Why not just make startup faster?
为什么不直接把启动变快?
Most of the 761 seconds is work that has nothing to do with the forward pass under test: loading weights, sizing caches, autotuning, capturing graphs. Shaving it helps every experiment a little; removing it from the loop helps every experiment completely. The companion blog shows the same split for another engine: 467 s of cold start against 9.0 s per hot reload, 7.3 s of which is graph capture.
761 秒里的大部分工作, 和被测的 forward pass 无关: 加载权重、 估算 cache、 autotuning、 捕获 graph。 把它压缩一点, 每次实验都快一点; 把它移出循环, 每次实验就彻底省掉它。 配套博客给出了另一个引擎的同类拆分: 冷启动 467 秒, 而每次热加载只要 9.0 秒, 其中 7.3 秒是捕获 graph。
06Where to start: a cost model that separates hardware from software从哪里起步: 区分硬件与软件的成本模型
Parallelism is the first decision and the most expensive one to search by measurement: every TP, EP, DP or CP layout needs its own engine, and today's software may underperform the hardware for some layouts. TKCC therefore ranks the top-k layouts with a model before any agent runs.
并行配置是第一个决定, 也是最难靠实测去搜索的: 每一种 TP、 EP、 DP 或 CP 布局都需要单独起一个引擎, 而且现有软件在某些布局上可能发挥不出硬件的能力。 所以 TKCC 在任何 agent 开始之前, 先用模型排出前 k 个布局。
It enumerates admissible layouts (the weights fit, every sharded dimension divides evenly) and prunes those that miss a 1.5 s TTFT or a 40 tokens-per-second decode SLA. For each surviving layout, each layer costs the larger of its compute and memory time plus its communication; concurrency is limited by both HBM capacity and the latency target; prefill and decode are costed separately and combined into tokens per minute per chip (§4.3, Appendix D):
它先列出可行的布局(权重放得下、 每个被切分的维度都能整除), 再去掉达不到 1.5 秒 TTFT 或 decode 40 tokens/s SLA 的布局。 对剩下的每个布局, 每层的耗时取计算时间和访存时间中较大的那个, 再加上通信时间; 并发同时受显存容量和延迟目标限制; prefill 和 decode 分开计算, 最后合成每张卡每分钟的 token 数(§4.3、 附录 D):
T_pass(decode) = Σ_L [ max(T_c^L, D^L / BW_HBM) + Σ_i T_comm^(L,i) ] T_pass(prefill) = Σ_L [ T_c^L + Σ_i T_comm^(L,i) ] C = min(C_memory, C_speed) chip_s(decode) = N · T_pass(decode) · OSL / C chip_s(prefill) = N · T_pass(prefill) / C TPM = 60 · (ISL + OSL) / (chip_s(decode) + chip_s(prefill))
The interesting part is where the inputs come from. Each chip is described at four levels: the vendor spec sheet, the team's own micro-benchmarks, vendor tools (BabelStream, perftest) and vendor libraries (cuBLASLt, hipBLASLt, nccl-tests). Comparing the levels tells whether a layout is slow because of the hardware or because of immature software, so a layout is not discarded just because its current implementation is poor. Data-dependent effects come from production: MTP acceptance, uneven prompt lengths and expert routing. Expert imbalance enters as the expected maximum load over ranks, because a layer waits for its slowest rank.
真正有意思的是输入从哪来。 每种芯片都有四个层级的描述: 厂商规格表、 团队自己的 micro-benchmark、 厂商工具(BabelStream、 perftest) 和厂商库(cuBLASLt、 hipBLASLt、 nccl-tests)。 对比这几层, 就能分清一个布局慢是因为硬件, 还是因为软件不成熟, 从而不会只因为当前实现差就丢掉一个布局。 依赖数据的效应来自生产环境: MTP 接受长度、 不均匀的 prompt 长度和专家路由。 专家不均衡用 「各 rank 负载的期望最大值」 来表示, 因为一层要等最慢的 rank。
Two results show the payoff. For MiniMax M3.1 Flash at batch 1, decode is memory-bound, so TP8 halves each GPU's weight traffic compared with the leading TP4 image; with it TKCC reached 1,111 TPS, 1.8× the best published 633 (§5.2). In production, the model found a Kimi K3 layout that raised TPS by up to 24% and tokens per minute per chip by up to 18% (§4.3).
两个结果说明了它的价值。 MiniMax M3.1 Flash 在 batch 1 时 decode 受访存限制, 所以 TP8 比领先镜像用的 TP4 少一半的单卡权重流量; 用 TP8, TKCC 达到 1,111 TPS, 是已发表最好成绩 633 的 1.8 倍(§5.2)。 在生产环境里, 这个模型为 Kimi K3 找到的布局让 TPS 最多提高 24%, 每卡每分钟 token 数最多提高 18%(§4.3)。
The AMD detail
与 AMD 相关的细节
For collectives the model has two shapes. With a switch, a collective is one hop at full bandwidth and the switch does the reduction. With direct links, it costs per-hop latency times hops plus the bytes on the busiest link. The paper notes that MI350-class GPUs "connect to each other directly, without such a switch" (§C.3), so an MI355X node needs the direct-link model and a fitted latency per collective for RCCL and AITER, not switch-style assumptions.
对于集合通信, 模型有两种形态。 有交换机时, 一次集合通信是满带宽的一跳, 由交换机完成归约。 直连时, 代价是每跳延迟乘以跳数, 再加上最忙那条链路上的字节数。 论文指出 MI350 系列 GPU 「彼此直接相连, 没有这样的交换机」(§C.3), 所以 MI355X 节点要用直连模型, 并为 RCCL 和 AITER 的每种集合通信单独拟合延迟, 而不能套用交换机式的假设。
07The bitter lessons, and where to be careful苦涩的教训, 以及要小心的地方
TKCC went through three production designs before the current one: megakernels; an augmented Inductor that lowered every kernel to PTX, inserted PDL and swapped in faster kernels, recovering kernels launched from C++ with CUPTI tracing on NVIDIA and rocProf on AMD; and agents steered by expert-curated context. As coding agents improved, the team ablated each piece and deleted most of it (§4.4, Appendix C.2):
TKCC 在现在的设计之前, 有过三个上线的版本: megakernel; 增强版 Inductor(把每个 kernel 降到 PTX, 插入 PDL, 换上更快的 kernel; 对于从 C++ 启动的 kernel, 在 NVIDIA 上用 CUPTI、 在 AMD 上用 rocProf 追踪补回来); 以及由专家整理的上下文来引导 agent。 随着 coding agent 变强, 团队对每一部分做了消融, 然后删掉了大部分(§4.4、 附录 C.2):
| Scaffold脚手架 | What the ablation showed消融的结果 |
|---|---|
| Custom IR (BlockIR from driver-level capture)自定义 IR(来自驱动层捕获的 BlockIR) | It could not express host-side changes: rewriting Kimi K3's MLA metadata planning to split long sequences across blocks gave 1.7–2.5× on the MLA kernel. Pointer tracking was brittle: on GLM 5.3 on AMD, tracer and allocator clocks drifted by up to 325 µs and mislabeled buffers.它无法表达 host 端的改动: 改写 Kimi K3 的 MLA 元数据规划, 把长序列切到多个 block 上, 让 MLA kernel 快 1.7–2.5 倍。 指针追踪很脆弱: 在 AMD 的 GLM 5.3 上, 追踪器和分配器的时钟漂移最多 325 µs, 把缓冲区标错了。 |
| Knowledge hub知识库 | 25–31% lower speedup after 12 hours; agents anchored on known patterns. The blog's 10-trial example: 5.85× fell to 4.75×.12 小时后加速比低 25–31%; agent 被已知模式框住了。 博客里 10 次试验的例子: 从 5.85 倍降到 4.75 倍。 |
| Expert strategies专家策略 | A naive ensemble ("make this forward pass as fast as possible") reached 6.2× against 4.9× for six expert strategies; the megakernel strategy on AMD GLM 5.3 spent 24 hours for 0.22%.朴素的 agent 组合(只说 「让这个 forward pass 尽可能快」) 达到 6.2 倍, 六种专家策略组合只有 4.9 倍; 在 AMD 的 GLM 5.3 上, megakernel 策略花了 24 小时只换来 0.22%。 |
| Research graph and CLI研究图谱和 CLI | Up to 43% of tool calls went to bookkeeping; on GLM 5.3 runs, 8% of time against under 0.5% with a plain Markdown file.最多 43% 的工具调用花在记账上; 在 GLM 5.3 的运行中占 8% 的时间, 换成普通 Markdown 文件后不到 0.5%。 |
| Infrequent communication低频通信 | Final speedup 4.82× with none, 6.20× infrequent, 7.72× with a frequently used message board.最终加速比: 不通信 4.82 倍, 低频通信 6.20 倍, 频繁使用消息板 7.72 倍。 |
Their conclusion: give agents the engine's source code, real measurements and fast feedback, and keep structured representations for verifying correctness rather than for steering optimization.
他们的结论是: 给 agent 引擎源码、 真实测量和快速反馈; 结构化表示留给正确性验证, 而不是用来引导优化。
Where to be careful
要小心的地方
Scope. The context ablations come from one layer (MiniMax-M3 layer 3, B200, TP4, batch 1) with 10 trials, and the paper and blog quote different sizes for the same effects: 19%, 26% and 25–31% for the knowledge hub; 2.3× and 4.7× faster optimization for communication. The direction is plausible; the magnitude is not established for AMD.
范围。 上下文消融只来自一层(MiniMax-M3 第 3 层、 B200、 TP4、 batch 1)、 10 次试验, 而且论文和博客对同一效应给出了不同的数值: 知识库是 19%、 26% 和 25–31%; 通信是优化速度快 2.3 倍和 4.7 倍。 方向可信, 但幅度在 AMD 上没有被证实。
CAKE disagrees, and both can be right. CAKE argues for a typed, hardware-explicit IR with verifiers. Its evidence supports an IR as a verifier and diagnostic layer; TKCC's evidence is against an IR as the optimization surface. Both need structure for correctness. Our FlyDSL reading (Source Reading 012) reached the same split from the compiler side.
CAKE 持相反立场, 而两者可以同时成立。 CAKE 主张带验证器的、 类型化、 硬件显式的 IR。 它的证据支持把 IR 当作验证和诊断层; TKCC 的证据反对把 IR 当作优化的操作面。 两者都需要结构来保证正确性。 我们对 FlyDSL 的阅读(Source Reading 012) 从编译器一侧得出了同样的划分。
"No scaffolding" is still a lot of infrastructure. The persistent engine, the tiers, the cost model and the verification suite are exactly the parts they kept.
「不要脚手架」 仍然意味着大量基础设施。 常驻引擎、 测量分档、 成本模型和验证套件, 恰恰是他们保留下来的部分。
08What the agents found on MI355Xagent 在 MI355X 上找到了什么
The AMD run optimized GLM-5.3 at TP8 with FP8 weights, starting from a vLLM ROCm nightly image (vllm/vllm-openai-rocm:nightly-rocm100-29468dd…), at concurrencies 1–16 on the AgentX workload (Table 4, §C.3). The paper says TKCC beat the best InferenceX configuration on all six model–chip pairs, this one included; the per-pair numbers appear only in Figure 7, so we do not quote one here.
AMD 上的实验优化的是 TP8、 FP8 权重的 GLM-5.3, 起点是 vLLM 的 ROCm nightly 镜像(vllm/vllm-openai-rocm:nightly-rocm100-29468dd…), 在 AgentX 工作负载上跑并发 1–16(表 4、 §C.3)。 论文说 TKCC 在全部 6 组 「模型 × 芯片」 上都超过了 InferenceX 的最好配置, 这一组也在其中; 但每组的具体数字只画在图 7 里, 所以这里不引用具体倍数。
The agents' AMD wins came from treating the all-reduce as part of the computation around it, not as a separate step to overlap. The segment is simplified from the paper's description; exact kernel boundaries in the vLLM image may differ.
agent 在 AMD 上的收益, 来自把 all-reduce 当作前后计算的一部分, 而不是当作一个要去重叠的独立步骤。 这个片段是根据论文描述简化的, vLLM 镜像里实际的 kernel 边界可能不同。
What worked有效的做法
- Fusing communication into compute. One kernel performs the all-reduce, residual add, RMSNorm and FP8 quantization; the GEMM before it writes straight into the all-reduce's shared buffer. The MoE down-projection is fused with the next all-reduce, and the attention output projection with its all-reduce and part of the expert router.
- 把通信融进计算。 一个 kernel 完成 all-reduce、 残差相加、 RMSNorm 和 FP8 量化; 它前面的 GEMM 直接把结果写进 all-reduce 的共享缓冲区。 MoE down-projection 和下一个 all-reduce 融合, attention 输出投影和它的 all-reduce 以及部分专家 router 融合。
- Reusing AITER's all-reduce buffers. AITER performs multi-GPU sums through shared GPU-to-GPU buffers that bypass the cache; writing the GEMM output there removes a copy and a launch.
- 复用 AITER 的 all-reduce 缓冲区。 AITER 通过绕过 cache 的 GPU 间共享缓冲区做多卡求和; 让 GEMM 直接把输出写进去, 省掉一次拷贝和一次启动。
- Filling tuning-table gaps. Several GLM-5.3 GEMM shapes had no tuned Composable Kernel settings and fell back to slow defaults; the agents added split-K variants for them.
- 填补调优表缺口。 GLM-5.3 的几个 GEMM 形状在 Composable Kernel 里没有调好的参数, 于是退回到很慢的默认值; agent 为这些形状补上了 split-K 变体。
- ROCm graph scheduling. When a captured HIP graph splits into parallel streams, ROCm decides which branch stays on the main stream; recording the main computation first keeps the critical path there.
- ROCm graph 调度。 捕获的 HIP graph 分成并行 stream 时, 由 ROCm 决定哪个分支留在主 stream 上; 先录主计算, 关键路径就会留在主 stream 上。
- Deleting dead work. Three copy or memset operations in the captured graph did nothing.
- 删掉无用的工作。 捕获的 graph 里有三个拷贝或 memset 操作, 实际什么也没做。
What did not无效的做法
- Megakernel formation: 0.22% over the best version after 24 hours. Dependent steps still need grid-wide barriers; the paper puts those at 1.5–3.5 µs inside a kernel against 0.5–1 µs at a kernel boundary with PDL.
- 做成 megakernel: 24 小时后只比最好版本快 0.22%。 有依赖的步骤仍然需要 grid 级屏障; 论文给出的数字是 kernel 内部 1.5–3.5 µs, 而用 PDL 的 kernel 边界是 0.5–1 µs。
- Overlapping RCCL all-reduces with GEMMs: lost at every concurrency.
- 让 RCCL all-reduce 和 GEMM 重叠: 在所有并发下都更慢。
- Reserving compute units for communication with CU masks: ignored on AMD.
- 用 CU mask 为通信预留计算单元: 在 AMD 上被忽略。
- Die-aware scheduling: MI350X and MI355X are built from eight compute dies (XCDs), each with its own clock, so in-kernel timer readings are meaningless per operation; "XCD remapping" came out as ties.
- 按 die 调度: MI350X 和 MI355X 由 8 个计算 die(XCD) 组成, 每个都有自己的时钟, 所以 kernel 内读到的计时对单个操作没有意义; 「XCD 重映射」 的结果都是平手。
- Rewriting attention: agents on both vendors spent much effort fusing neighbors into attention or changing split-KV, with little to show.
- 改写 attention: 两家硬件上的 agent 都花了大量精力把相邻操作融进 attention 或修改 split-KV, 收效甚微。
The cautionary kernel反面教材
An agent wrote an exact top-k (k = 2,048) for GLM-5.3's sparse-attention indexer as a HIP kernel (topk5.hip, layers 1–2, MI350X). It buckets scores into 2,048 histogram bins, keeps every bin above the threshold bin, and ranks candidates inside the threshold bin pairwise, which is quadratic in that bin's size. On random scores the bins are even: 20 µs. Real scores contain many exact zeros from ReLU, which all land in one bin: up to 62 ms at 70K context, and a 1.3× end-to-end slowdown in the engine (§3, Figure 12).
一个 agent 为 GLM-5.3 稀疏注意力的 indexer 写了一个精确 top-k(k = 2,048) 的 HIP kernel(topk5.hip, 第 1–2 层, MI350X)。 它把分数分进 2,048 个直方图桶, 保留阈值桶以上的所有桶, 在阈值桶内部两两比较排名, 耗时和这个桶的大小成平方关系。 随机分数在各桶里分布均匀: 20 µs。 真实分数里有大量来自 ReLU 的精确 0, 全部落进同一个桶: 在 70K 上下文时最多要 62 ms, 在引擎里端到端慢 1.3 倍(§3、 图 12)。
The AMD lesson in one line
AMD 上的教训, 一句话
On MI355X, the agents found their gains in fusing communication into compute and in filling tuning gaps, not in persistent kernels or overlap, and per-die timers could not be trusted.
在 MI355X 上, agent 的收益来自 「通信融进计算」 和 「填补调优缺口」, 而不是常驻 kernel 或重叠; 而且单个 die 的计时器不可信。
09Applying it to MI355X, MI455X and FlyDSL怎样用到 MI355X、 MI455X 和 FlyDSL
Our setting differs from Together's. We tune for InferenceX AgentX and ship FlyDSL kernels into SGLang and vLLM on shared GPU nodes, and gfx1250 kernels are newer than gfx950 ones (FlyDSL has no gfx1250 CI runner). So the order of work matters more than the destination. Each item names what to do, which evidence in the paper supports it, and how we would know it worked.
我们的处境和 Together 不同。 我们面向 InferenceX AgentX 调优, 在共享 GPU 节点上把 FlyDSL kernel 交付进 SGLang 和 vLLM; gfx1250 的 kernel 也比 gfx950 的新(FlyDSL 没有 gfx1250 的 CI runner)。 所以做事的顺序比终点更重要。 下面每一项都写明: 做什么、 论文里哪条证据支持它、 以及怎样判断它成功了。
MI355X · build the loop before the agentsMI355X · 先建循环, 再上 agent
- Measure what a kernel boundary costs on MI355X. Plate III has no AMD row. Measure a normal HIP launch, HIP-graph replay, a cooperative grid sync and a persistent-kernel barrier, with the paper's protocol (end of kernel one to after the sync in kernel two). This one table bounds what any monokernel can gain from "one launch" alone. It matters to us directly: in our GLM-5.3 PD study, AMD's monokernel lifted concurrency-1 decode from 213 to 474 tok/s per user, but it only covers steps with two requests or fewer, 35% of steps at concurrency 10 (post). That is the paper's "fast but rigid" pattern. Before investing further, split that 2.2× into launch savings and better fused kernels, the way the authors split theirs. Done when Plate III has a measured AMD row and the monokernel's gain is attributed.
- 测出 MI355X 上一次 kernel 边界的代价。 图版 III 里没有 AMD 的数据。 按论文的方法(从第一个 kernel 结束, 到第二个 kernel 里同步完成之后), 测普通 HIP 启动、 HIP graph 重放、 协作式 grid 同步和常驻 kernel 内屏障。 这一张表决定了任何 monokernel 单靠 「一次启动」 最多能赚多少。 它和我们直接相关: 在我们的 GLM-5.3 PD 实验里, AMD 的 monokernel 把并发 1 的 decode 从每用户 213 提到 474 tok/s, 但它只覆盖每步不超过两个请求的情况, 到并发 10 时只占 35% 的步(文章)。 这正是论文说的 「快但僵硬」。 继续投入之前, 先像作者那样, 把这 2.2 倍拆成启动开销的节省和更好的融合 kernel 两部分。 完成标准: 图版 III 有了 AMD 的实测行, 并且 monokernel 的收益完成了归因。
- Build a persistent engine for SGLang and vLLM on ROCm. Hot-swap
model.forward, re-capture HIP graphs, reuse prefix-cached requests and cache kernel binaries; add a fast tier with a few layers and a slow tier with more. Done when a reload takes seconds instead of minutes of cold start and back-to-back variance is near the paper's 2.7% after splitting prefill and decode. GLM-5.3 at TP8 fills an 8-GPU node, so two tiers need two nodes, which is also the paper's budget. - 为 ROCm 上的 SGLang 和 vLLM 建常驻引擎。 热替换
model.forward, 重新捕获 HIP graph, 复用已在 prefix cache 里的请求, 并缓存 kernel 二进制; 加一个只加载少数几层的快档和一个加载更多层的慢档。 完成标准: 一次热加载只要几秒, 而不是几分钟的冷启动; 把 prefill 和 decode 分开测之后, 连续两次的方差接近论文的 2.7%。 TP8 的 GLM-5.3 会占满一个 8 卡节点, 所以两档需要两个节点, 这也正是论文的预算。 - Port the wins the agents already found on AMD: all-reduce + residual + RMSNorm + FP8-quant fusion, GEMM epilogues writing into AITER's all-reduce buffer, MoE down-projection + all-reduce, o_proj + all-reduce + router, split-K variants where CK has no tuned entry, main path first at HIP-graph stream splits, and dead copies removed. Done when each shows up as a measured decode-step win on AgentX.
- 把 agent 已经在 AMD 上找到的收益移植过来: all-reduce + 残差 + RMSNorm + FP8 量化融合、 GEMM epilogue 直接写进 AITER 的 all-reduce 缓冲区、 MoE down-projection + all-reduce、 o_proj + all-reduce + router、 在 CK 没有调优条目的地方补 split-K 变体、 HIP graph 分流时先录主路径, 以及删掉无用的拷贝。 完成标准: 每一项都在 AgentX 上表现为实测的 decode 单步收益。
- Deprioritize what failed on AMD until our own measurements say otherwise: megakernels for GLM-5.3 TP8, RCCL–GEMM overlap, CU masks, and die-aware scheduling driven by in-kernel timers.
- 在我们自己的测量推翻之前, 把在 AMD 上失败的方向往后放: GLM-5.3 TP8 的 megakernel、 RCCL 与 GEMM 的重叠、 CU mask, 以及依赖 kernel 内计时的按 die 调度。
- Feed the cost model AMD numbers: hipBLASLt and RCCL or AITER collectives as the vendor-library tier, the direct-link model for the xGMI mesh, and routing imbalance and MTP acceptance measured on AgentX traces.
- 给成本模型喂 AMD 的数据: 把 hipBLASLt 和 RCCL 或 AITER 的集合通信作为厂商库这一层, xGMI 互连用直连模型, 再从 AgentX 流量中实测路由不均衡和 MTP 接受长度。
MI455X · the same loop, different constraintsMI455X · 同样的循环, 不同的约束
- The argument against one launch envelope gets stronger. gfx1250 is wave32, has no AGPRs, 1,024 addressable VGPRs and 320 KB of LDS (
arch-gfx1250.md:53). WMMA accumulates in VGPRs, so the paper's point that GEMMs want fewer warps when accumulators live in registers applies to any persistent kernel on gfx1250: one launch envelope forces one register budget on every operation. - 反对 「统一启动形状」 的理由更强了。 gfx1250 是 wave32, 没有 AGPR, 有 1,024 个可寻址 VGPR 和 320 KB LDS(
arch-gfx1250.md:53)。 WMMA 的累加器在 VGPR 里, 所以论文的论点(累加器放在寄存器时, GEMM 想要更少的 warp) 适用于 gfx1250 上的任何常驻 kernel: 统一的启动形状, 会把同一个寄存器预算强加给每个操作。 - Clusters are a candidate set. On NVIDIA, switching to an existing cluster-based attention kernel was the largest single gain in one GLM 5.3 run. gfx1250 has thread-block clusters, and FlyDSL already lowers cluster attributes in its pipeline (
backends/rocm.py:355), so cluster-capable kernels are a natural first target. - cluster 是一组候选。 在 NVIDIA 上, 换用现成的基于 cluster 的 attention kernel, 是某次 GLM 5.3 优化中最大的单项收益。 gfx1250 有 thread-block cluster, FlyDSL 的 pipeline 也已经会降低 cluster 属性(
backends/rocm.py:355), 所以能用 cluster 的 kernel 是自然的第一批目标。 - On newer hardware, fidelity is a correctness problem first. Random-input tests passed while models failed during the gfx1250 bring-up (Green Test, Red Model). A persistent engine running real traffic is also the right correctness harness.
- 在较新的硬件上, 保真首先是正确性问题。 在 gfx1250 上线期间, 随机输入的测试都通过了, 模型却出错了(单测通过, 模型出错)。 用真实流量运行的常驻引擎, 也是合适的正确性测试框架。
- No anchor numbers. The paper did not evaluate gfx1250, so every gain estimate there stays unknown until we measure it.
- 没有可参照的数字。 论文没有评测 gfx1250, 所以在我们实测之前, 任何收益估计都是未知的。
FlyDSL · a language agents edit, verifiers they don'tFlyDSL · agent 改的是语言, 不改的是验证器
- Source is the surface. FlyDSL kernels are Python source, which is the representation TKCC found to have the highest ceiling. What FlyDSL should add is verification and diagnostics, such as the structured compile report and errors for dead knobs from Source Reading 012, not strategy guides.
- 源码就是操作面。 FlyDSL 的 kernel 就是 Python 源码, 正是 TKCC 发现上限最高的那种表示。 FlyDSL 应该补的是验证和诊断, 比如 Source Reading 012 里提到的结构化编译报告和无效开关报错, 而不是策略指南。
- Replay real inputs. 43 of 60 kernel test files use random inputs. FlyDSL's GLM monokernel indexer also bins scores into a radix histogram (
INDEX_RADIX_BINS = 256; the reference top-k is 2,048,reference.py:159). The TKCC failure was a histogram whose threshold bin filled with ties, so this kernel should also be timed on captured, ReLU-heavy indexer scores, not only ontorch.randn. - 回放真实输入。 60 个 kernel 测试文件中有 43 个用随机输入。 FlyDSL 的 GLM monokernel indexer 也把分数分进基数直方图(
INDEX_RADIX_BINS = 256; 参考实现的 top-k 是 2,048,reference.py:159)。 TKCC 的失败案例, 正是阈值桶被大量并列值填满的直方图, 所以这个 kernel 也应该用抓取的、 含大量 ReLU 零值的真实 indexer 分数来计时, 而不只是用torch.randn。 - Key variants by load. TKCC's persistent MoE down-projection wins at concurrency 22–78 and loses at 8. FlyDSL's monokernels are resident decoder-layer kernels by design (
monokernel/README.md); expose them as one variant among several, selected by the active batch size, rather than as the only path. - 按负载选择变体。 TKCC 的常驻式 MoE down-projection 在并发 22–78 时更快, 在并发 8 时更慢。 FlyDSL 的 monokernel 按设计就是常驻的 decoder 层 kernel(
monokernel/README.md); 应该把它作为多个变体之一, 按当前 batch 大小来选择, 而不是作为唯一的路径。 - Compile time is loop time. Every hot reload that touches a kernel pays its JIT compile unless the binary is reused. FlyDSL's disk cache is on by default (
utils/env.py:302) and it links in process since #987; measure FlyDSL compile time per kernel as part of the loop budget. - 编译时间就是循环时间。 每次碰到 kernel 的热加载, 除非复用二进制, 都要付一次 JIT 编译的代价。 FlyDSL 的磁盘缓存默认开启(
utils/env.py:302), 并且从 #987 起在进程内链接; 应该把每个 kernel 的 FlyDSL 编译时间当作循环预算的一部分来测量。
| TKCC ideaTKCC 的思想 | MI355X | MI455X | FlyDSL |
|---|---|---|---|
| Persistent engine, hot reload常驻引擎、 热加载 | SGLang / vLLM on ROCm, HIP-graph recapture, two nodes for GLM-5.3 TP8ROCm 上的 SGLang / vLLM, 重新捕获 HIP graph, GLM-5.3 TP8 需要两个节点 | same harness, correctness first同一套框架, 正确性优先 | kernels swapped as source; JIT cache for reuse以源码形式替换 kernel; 用 JIT 缓存复用 |
| Real-data measurement用真实数据测量 | AgentX traces; no per-XCD timersAgentX 流量; 不用单个 XCD 的计时器 | real traffic as the correctness harness真实流量作为正确性测试框架 | replay captured routing and indexer scores回放抓取的路由和 indexer 分数 |
| Unbundle fused kernels拆开融合 kernel | HIP launch vs grid-barrier cost; attribute the monokernel's gain对比 HIP 启动与 grid 屏障的代价; 归因 monokernel 的收益 | register budget limits persistent kernels寄存器预算限制常驻 kernel | monokernel as a load-selected variantmonokernel 作为按负载选择的变体 |
| Fuse for utilization为利用率融合 | AR + norm + quant; GEMM into AITER buffer; CK split-KAR + norm + 量化; GEMM 写进 AITER 缓冲区; CK split-K | cluster-capable kernels能用 cluster 的 kernel | fusion choices as variants keyed by batch regime把融合选择做成按 batch 状态选择的变体 |
| Tiered cost model分层成本模型 | hipBLASLt, fitted RCCL / AITER latencies, direct-link modelhipBLASLt、 拟合的 RCCL / AITER 延迟、 直连模型 | spec sheet only, until measured实测之前只有规格表 | — |
| IR as verifierIR 作为验证器 | — | — | compile report; errors for dead knobs编译报告; 无效开关报错 |
10Critical reading批判性阅读
What is strong强的地方
- The megakernel ablation ladder is the most reusable result in the paper: it prices each claimed source of speed separately, with numbers, on the authors' own system.
- megakernel 的逐级消融是论文里最可复用的结果: 它在作者自己的系统上, 用数字分别给每一个声称的提速来源定了价。
- The engine design is simple and general: hot reload plus graph re-capture works for any engine that exposes its forward function, including HIP graphs on ROCm.
- 引擎设计简单而通用: 热加载加上重新捕获 graph, 适用于任何暴露 forward 函数的引擎, 包括 ROCm 上的 HIP graph。
- The appendix is candid about failures, with numbers, on AMD as well as NVIDIA.
- 附录坦率地列出了失败, 并给出数字, AMD 和 NVIDIA 都有。
What is not established尚未证实的地方
- The headline per-platform gains are plotted, not tabulated; the text gives no MI355X number.
- 各平台的主要收益只画在图里, 没有列成表; 正文没有给出 MI355X 的数字。
- The context ablations rest on one layer, one GPU and 10 trials, and the quoted magnitudes differ between paper and blog.
- 上下文消融只基于一层、 一种 GPU 和 10 次试验, 而且论文和博客引用的幅度不一致。
- Cost is under-reported: each result used 24 hours on two replicas' worth of GPUs, and the agent comparisons in Appendix A.1 used Claude Code with Opus 5.5 at high reasoning; token cost is not given.
- 成本披露不足: 每个结果都用了两份副本规模的 GPU 跑 24 小时, 附录 A.1 的 agent 对比使用的是 Claude Code 加 Opus 5.5(高推理强度); 但没有给出 token 成本。
- For LLM serving, correctness is checked at the end by KV-contamination and quality tests, not by bit-exactness, which is required only for the non-LLM models in §5.3. How quality is protected across traffic regimes is not quantified.
- 对 LLM 服务来说, 正确性是在最后用 KV 污染和质量测试来检查的, 而不是要求逐位一致; 逐位一致只要求于 §5.3 里的非 LLM 模型。 不同流量状态下质量如何得到保障, 没有量化。
- Agent code is an operational risk: on NVIDIA, illegal memory accesses forced 9 full GPU resets (Xid 154) during GLM 5.3, and two machines left the cluster. On shared clusters, the fast tier's crash shielding is a requirement, not a convenience.
- agent 写的代码是运维风险: 在 NVIDIA 上, 非法内存访问在 GLM 5.3 优化期间导致了 9 次 GPU 完全重置(Xid 154), 两台机器被移出集群。 在共享集群上, 快档的防崩溃作用是必需品, 不是锦上添花。
- The case against megakernels on GPUs leans on a PDL boundary as the comparison point, and PDL is NVIDIA-only. The paper gives no AMD equivalent, which is why it is our first experiment.
- 反对在 GPU 上做 megakernel 的论证, 用 PDL 边界作为对比点, 而 PDL 只在 NVIDIA 上有。 论文没有给出 AMD 上的对应数据, 这也是它成为我们第一个实验的原因。
Open questions for us留给我们的问题
- How much of the AMD monokernel's concurrency-1 gain survives as a few fused kernels under HIP graphs?
- AMD monokernel 在并发 1 时的收益, 改成 HIP graph 下的几个融合 kernel 之后还能剩多少?
- How few layers can a fast tier serve for GLM-5.3 TP8 and still predict the slow tier's ranking of candidates?
- 对于 GLM-5.3 TP8, 快档最少加载几层, 还能预测出慢档对候选的排序?
- Can a persistent engine coexist with shared-node rules: one serving engine per node, locked GPUs, and cleanup by recorded PID after a crash?
- 常驻引擎能否和共享节点的规则共存: 每个节点只跑一个服务引擎、 锁定 GPU、 崩溃后按记录的 PID 清理?
11Sources来源
Section numbers (§) refer to the arXiv paper. FlyDSL links are pinned to commit e2a2b1f (17 November 2026).
文中的章节号(§) 指 arXiv 论文。 FlyDSL 的链接都固定在 commit e2a2b1f(2026 年 11 月 17 日)。
- Together Compiler, arXiv 2611.14681
- The road to Together Compiler (blog, 11-16)
- Together Compiler (blog, 11-04)
- From Static to Polymorphic Inference
- SemiAnalysis InferenceX
- RSI-Inference Bench
- HazyResearch Megakernels
- Mirage Persistent Kernel
- Mixture-of-Kittens
- CAKE, arXiv 2608.12629
- Kerncap, arXiv 2605.03208
- GEAK, arXiv 2507.23194
- FlyDSL tests/kernels
- FlyDSL monokernel/README.md
- Source Reading 012 · 270 Fences
- Green Test, Red Model
- Disaggregation Is Not a Kernel