PipeLink: Contract-Guided Linking of GPU Kernel Components
Jize Guo, Xupeng Miao
cs.DC
2026-10-27
PipeLink contract-links GPU kernel components. On 51 configs, linked kernels stay within 0.2% of one compilation unit; a CuTe attention swap speeds decode 2.16× at 4096 tokens.
The fastest ML kernels already run several roles at once. A loader, a matrix-multiply mainloop, softmax, an epilogue and sometimes a communication stage share one SM (streaming multiprocessor, the unit that executes a thread block) and pass tiles through on-chip memory. The source pins every resource: shared memory starts at offset 0, barriers at 1, warps at 0. Two components compiled apart both claim those slots, so combining them unchanged collides.
The practical choices are fork or split. A fork merges the sources and rewrites the layout by hand. Dropping a CuTe attention operator into the ThunderKittens Llama-1B decode megakernel, one persistent kernel for a full decode step, means porting it onto that megakernel's pages and semaphores. A split leaves each piece in its own kernel and joins them through global memory. Production context-parallel attention takes that path: one unmodified FlashAttention launch per key/value block, with transfers and partial-output fixes outside. CUDA device LTO (link-time optimization that merges separately compiled device code) only resolves symbols. It does not record warps, on-chip memory or the tile sizes neighbors compiled against. In a four-owner MoE megakernel, changing one geometry constant and repacking that owner alone produced five combinations the symbol linker accepted. Three hang. Two finish with part of the output unwritten.
PipeLink, from Peking University, compiles each component to an LTO object plus a contract. The contract states how many warps, how much shared memory and how many mbarriers (arrival barriers between async copies and compute) it needs, how long each claim lives, which tiles it imports or exports, and which facts, such as a tile size, other components schedule against. The object reads its placement through undefined device functions such as smembase(). The linker defines each function to return a constant, and the vendor backend folds that constant into an immediate. Template parameters would also fold, but the component would be recompiled for every composition. Kernel arguments keep the object fixed and turn every offset into a run-time load.
Linking pairs endpoints by name. Memory space, protocol and arrival counts must agree; a mismatch is one of 44 named diagnostics. Placement is a single SMT problem solved with Z3. A thread block gets at most 227 KiB of shared memory, 32 warps and 16 named barriers, and buffers may overlap only when their lifetimes are disjoint, so a greedy pack's order changes the footprint. On the MoE megakernel, first-fit in lexical or decreasing-size order misses the smallest layout. The solver leaves 1,440 of 232,448 bytes free, prefers deeper rings and larger register budgets, and is deterministic. It does not reschedule a component. The vendor backend still allocates registers and, if the groups do not fit, placement is solved once more.
Transfers are generated from the two contracts. The producer publishes where each accumulator element lives, in tensor memory, shared memory or a thread's registers. The consumer states which element each thread wants. The linker tries a tensor-memory read, a register copy, a warp shuffle, then a scratch shared-memory stage, and keeps the first route that delivers every element exactly and without races. TileLang lowers it to CUDA. Values are moved, not converted. Cross-GPU protocols stay in component code; the linker only binds domains, peer views and readiness counters. The implementation is about 24,000 lines of Python plus a 5,400-line TileLang frontend, device-linked with nvJitLink from CUDA 13.3. Objects are opaque and can ship without source.
Runs use locked clocks: H200 at 1230 MHz, B300 at 1155 MHz, RTX 5090 at 1770 MHz. Each control compiles the same sources, the same generated glue and the same placement as one translation unit. Across 51 timed configurations, linked throughput stays within 0.2% of that control. Results match bitwise, or within run noise for the megakernels, and memcheck, racecheck and synccheck are clean. Normalized machine code matches on all seven attention compositions, the mixed-library megakernel, and GEMM+SwiGLU on H200 and the 5090.
| Setting | Baseline | Result |
| Llama-1B decode, 4096 tokens, B300 | ThunderKittens only | 2.16×, 1.630 vs 3.516 ms/token |
| Same kernel, 16 / 1024 tokens | ThunderKittens only | 0.95× / 1.22× |
| Four-owner MoE, 4× B300 | Mixture-of-Kittens | 0.989-1.014× |
| Context-parallel attention, H200 | Transformer Engine | 1.20-1.31× |
| Qwen3-32B GEMM+SwiGLU, B300 | cuBLAS + torch.compile | 1.20× at M=16384 |
The upstream ThunderKittens decode megakernel failed its split-KV path, deadlocking or dropping partial outputs. Five defects were fixed in every image, including the monolith. The all-ThunderKittens linked kernel then runs at 1.01-1.10× that repaired monolith. Replacing only the attention package with CuTe, eight other packages and the instruction stream unchanged, is 2.16× at 4096 tokens and 1.22× at 1024 tokens with split-KV reduction. At 16 tokens the mix is about 5% slower: one of four warps has work, and the fixed copy plus merge dominate. The mixed kernel is 0.9994-0.9998× its own single-unit control.
The frozen Hopper core is derived from FlashAttention-3, BF16, head dimension 128. Against FA3 it is 0.96-0.99× on causal Qwen3-8B, 0.84-0.94× on sliding window, and 1.01-1.02× on chunked attention. Replacing the loader and keeping that core, Phi-3 block-sparse is 2.26-2.73× the best public expert kernel. MiniMax sparse attention is about 1.6-4.5× vLLM's dedicated kernel and up to 38× FlexAttention. FA4 is 5-6% faster when selected blocks form a prefix, and 9-38× slower when they are scattered. For 32K causal prefill, context-parallel attention is 1.95× a single H200 on two GPUs (97.6% of ideal scaling) and 3.67× on four (91.7%). Against Transformer Engine, using its faster transport and a CUDA graph around the forward pass, the speedups at 8K/32K and 2/4 GPUs are 1.24×, 1.31×, 1.21× and 1.20× (for example 0.604 vs 0.750 ms at 8K on two GPUs).
The Qwen3-32B up-projection is linked to SwiGLU with the FP32 accumulator left unrounded through the activation. B300 leaves that accumulator in tensor memory; H200 and RTX 5090 leave it in registers. CUDA and TileLang consumers link without the producer source. On B300 the composition is 1.20-1.21× cuBLAS plus a torch.compile SwiGLU, and 1.34-1.37× cuBLAS plus Liger; at M=16384 the measured points are 1.20× and 1.34×. On H200 the direct register route is 5% faster than a 16 KiB shared-memory stage, 14.35 ms versus 15.10 ms. Against the same pieces fused by hand into one native kernel, linked throughput is 0.94-1.01×.
Mixture-of-Kittens is split across framework, NVLink communication, grouped GEMM and SwiGLU. Six packages link into 24 kernels. Twelve timed kernels on four B300s, at 2048 and 8192 tokens per rank, run at 0.999-1.001× their single-unit controls and 0.989-1.014× the original monolith. A GPT-OSS activation built in a tree with none of the other owners' sources links into all 24 and passes 48 checks per rank. The five constant edits that break symbol linking relink, with the new fact pushed to every consumer. Seven incompatible combinations are rejected by name.
Fused-kernel parts can be compiled, shipped and swapped, then placed into whatever shared-memory offsets and warp ranges this composition has free. Run time stays within 0.2% of a single translation unit, and on the attention set, the mixed megakernel, and GEMM+SwiGLU on H200 and the 5090 the machine code matches. A CuTe attention body does not have to be rewritten onto ThunderKittens conventions. Communication can live in the same kernel as compute; each query tile sees its key/value blocks inside one launch, so the usual out-of-kernel correction is gone.
The linker does not make an operator faster than the code it links. Dense attention trails FlashAttention-3 because of this core. What changes is the cost of a new composition: window, softcap, block-sparse and context parallel are mostly one or two packages around a frozen core. The contracts are not free. Four MoE owners wrote 327 statements against 3,482 lines of component and host-provider source. A TileLang frontend cuts the SwiGLU consumer from 163 CUDA lines to 56.
Contracts are checked against each other, not against the instructions behind them. A component that touches shared memory outside its claim can still produce a wrong kernel. Numerical tests and sanitizers remain mandatory. Generated code only moves data, and only inside one thread block. Arithmetic, precision conversion and cross-GPU communication stay in component code. A tensor export carries one generation, so a producer that hands off its accumulator this way cannot be persistent. Multi-slot rings are written in the components.
Packages target one GPU architecture and one CUDA major version; LTO IR does not cross major versions. Existing kernels have to be ported onto declared interfaces before they can be linked. The timings use the highest sustained SM clock under full BF16 and FP8 matmul, on the shapes in the paper, with no end-to-end serving latency. The 2.16× figure is against the repaired ThunderKittens decode kernel, and at 16 tokens the mix is slower. It is not a comparison with vLLM. The symbol-linker failure is specific, and it is five constant edits of one MoE kernel.