AI guides

Peking University Open-Sources PipeLink to Make GPU Kernel Optimizations Reusable

By 机器之心0 viewsSource: 机器之心
Peking University Open-Sources PipeLink to Make GPU Kernel Optimizations Reusable

Peking University's PipeLink declares interfaces, synchronization and resource needs for GPU stages, checks contracts and links stages into fused kernels. Examples span toolchains, attention variants and communication-compute fusion; gains depend on components, workloads and hardware.

Editor's fact check (2026-11-24): Performance figures must be understood in terms of version, workload and hardware. The project's current public README states that, on sm103 locked at 1155MHz with a 1024-token reduced-KV setup, the separately packaged and linked version achieves 0.9996 times the throughput of a monolithic build from the same source. With a 4096-token context, a hybrid version replacing only the attention implementation achieves 2.16 times the throughput of pure ThunderKittens, while differing from the hybrid version's own monolithic build by no more than 0.02%. The 2.16-fold figure includes a change in component implementation; it is not acceleration from the linking step alone. Contract checks handle declared interface, resource and synchronization constraints; they do not mean that arbitrary GPU code can be fused or that algorithmic semantics are automatically proved correct. Official PipeLink code repository and current case-study data; (opens in a new tab)PipeLink paper abstract (opens in a new tab)

In ordinary software development, assembling components written by different teams according to interfaces is familiar practice. In high-performance GPU programming, however, this seemingly natural requirement is not easy to meet.

Today's large-model software ecosystem has accumulated many high-performance GPU kernels. Inference systems such as vLLM and SGLang already integrate kernel libraries and compute backends including CUTLASS, FlashInfer, FlashAttention, FlashMLA, DeepGEMM and Marlin, alongside many custom kernels written in CUDA and Triton, covering key operations such as matrix multiplication, attention and low-precision inference. On top of this, developers use CUDA Graph to reduce launch overhead, or kernel fusion and MegaKernels to further reduce data movement and execution-switching costs.

Yet fusing compute implementations from different sources into one kernel often comes at a high development cost. Developers must understand implementation details deeply and manually rework data layouts, thread assignments, synchronization and hardware resources. This cost affects both code reuse and optimization iteration: replacing one part may disturb the entire program, while switching toolchains may require adapting the original implementation all over again.

Article illustration

Figure 1: Manual assembly vs. PipeLink's contract-guided linking

Can high-performance GPU code be developed and replaced independently like software components while retaining execution efficiency close to monolithic compilation?

Motivated by this question, Assistant Professor Xupeng Miao's team at Peking University's Data and Intelligence Research Lab (PKU-DAIR) released PipeLink. PipeLink aims to provide a set of foundational mechanisms: divide GPU computation into independently developable stages with explicit interfaces, then use a linker to check contracts, coordinate resources and generate connecting code, combining the stages into a fused kernel.

Article illustration

  • Paper title: PipeLink: Contract-Guided Linking of GPU Kernel Components
  • Paper: https://arxiv.org/abs/2610.37200
  • Project code: https://github.com/PKU-DAIR/PipeLink

Why Might the Whole Model Be Slow Even When Every Kernel Is Fast?

One execution of a model can be understood as a production line: the input passes through a series of operations such as matrix multiplication, attention and activation, gradually becoming the output. On a GPU, a kernel is a computational program executed in a single launch and can perform one or more of these operations.

A common implementation calls separate kernels for each operation. This facilitates development and reuse, but there are costs between operations too: launching and scheduling take time, and intermediate results from one operation may need to be written back to GPU memory and then read by the next.

It is like every workstation processing goods quickly while the goods still have to move back and forth between stations and wait for handoffs. Optimizing each workstation does not automatically eliminate these costs.

Kernel fusion puts operations suited to execution together into the same kernel, reducing launches, data movement and waiting where conditions allow. A MegaKernel brings a wider range of computation and scheduling into a single kernel, sometimes covering multiple model layers or even the entire decoding process.

This also creates a new engineering challenge: as more operations share one execution space, resource and synchronization issues previously separated by independent kernel boundaries must be coordinated again internally.

The benefits of fusion depend on the specific workload and execution approach. Building a high-performance fused kernel requires coordinating data handoffs, execution order and resource use across all stages.

The Biggest Headache Used to Be Connecting the Parts

Consider low-precision inference: one developer handles quantization or dequantization, while another handles matrix computation. Logically, the relationship is clear, but a GPU implementation needs to align many more details.

First, where is the data, and who holds it? The quantization component must specify data packing, scale-factor granularity and arrangement, while the compute component has its own loading method and thread layout. Dequantized data may also be scattered across registers belonging to different threads. Matching tensor shapes does not mean the underlying storage layouts match.

Second, who starts work, and when? A GPU executes tasks in parallel through many threads. When one stage writes part of the data, can another stage already read it? When can a buffer be reused? The waiting and notification mechanisms must match each other.

Third, how are limited hardware resources divided? Two pieces of code that perform well independently share registers, shared memory and thread resources when combined. Their individual resource arrangements need to be reconsidered as part of the whole.

This presents developers with a practical tension: independent implementations support division of labor and reuse, while deep fusion demands close cooperation between parts. Without explicit component boundaries, a large kernel often has to be maintained centrally by a developer familiar with all the details, and local optimizations are difficult to deliver independently. PipeLink makes these connection conditions explicit and delegates the mechanically manageable work to the linker.

Optimize Independently, Then Combine According to Contracts

PipeLink calls its basic unit of composition a stage: a phase within a kernel. A stage can be an operator, or something finer-grained: data loading, the matrix-multiplication main loop, output processing (a GEMM epilogue), or a piece of communication logic.

Besides an implementation, each stage includes an "interface description": what it provides, what it needs, which threads and resources it uses, and how it exchanges data and synchronizes with preceding and subsequent stages. This information forms the stage's contract.

Article illustration

Figure 2: PipeLink overview

Once stages are independently packaged, users can compose them through packages without inspecting their implementation source. Based on the declarations, the linker takes on three jobs:

  • Check compatibility. Provide explicit diagnostics when call interfaces, data handoffs or synchronization protocols are incompatible at the declaration level.
  • Coordinate resources. Arrange thread roles, shared memory, synchronization resources and register budgets within the supported constraints.
  • Generate connecting code. Generate adaptation code for supported tensor handoffs, together with a combined scheduling entry point.

For users, this means moving from "understand every component's internals, then wire them together manually" toward "describe components according to agreed conventions and let the tool perform the connections that can be derived."

PipeLink builds on NVIDIA nvJitLink's device-code linking and optimization capabilities, adding mechanisms for inter-stage contract checking, resource coordination and data handoffs to combine independently developed computational stages into a fused kernel.

PipeLink currently supports multiple GPU architectures, including Hopper and Blackwell, and can combine handwritten CUDA, CUTLASS/CuTe, TileLang and ThunderKittens. Different developers can keep the tools that suit them and deliver their work as stage packages with common interface conventions.

From Local Fusion to MegaKernels

Composition Can Happen at Different Scales

Case 1: Local MegaKernel Optimization. The team split a ThunderKittens-based, 16-layer Llama-1B decoding MegaKernel into nine packages—one instruction interpreter and eight operator packages—then relinked them into a persistent kernel. The project reports that the linked version achieves 0.9996× the throughput of a monolithically compiled version from the same source, making performance essentially identical.

Article illustration

Figure 3: PipeLink enables local MegaKernel optimization

The team replaced only the attention package with a CUTLASS/CuTe implementation, leaving the other eight packages, instruction scheduling and host code unchanged. With a 4096-token context, the hybrid version's decoding speed reaches 2.16× that of pure ThunderKittens; the hybrid's linked build differs in performance by no more than 0.02% from its monolithic build using the same source.

Case 2: One Attention Core Supports Multiple Variants. The team reused the same Hopper-targeted attention core package derived from FlashAttention-3, replacing surrounding data-loading, masking, score-transformation or output-processing stages to build seven implementations: dense attention, sliding-window attention, softcap attention, combined sliding-window and softcap attention, Phi-3 block-sparse attention, MiniMax-M3 sparse attention, and context-parallel attention. Sliding-window attention requires only a new 28-line mask, while softcap needs only a new 29-line score-transformation function; the complex core computation remains unchanged.

Article illustration

Figure 4: PipeLink enables attention-kernel variants with a shared core

Case 3: Rapidly Implementing Communication-Compute Fusion. In context-parallel attention, communication stages push KV shards through NVLink, while the compute side waits for the relevant data blocks to become ready when needed, coordinating communication and computation within a single kernel on each GPU. In a 32K-length prefill test, speedups relative to one GPU were 1.95× with two GPUs and 3.66× with four.

The Future: Taking AI's Local Optimizations

Toward Complete MegaKernels

Under specified computational tasks, input sizes and hardware conditions, existing agents can already search for high-performance implementations through a loop of "generate code—verify correctness—measure performance—keep improving." For example, in the MLSys 2026 FlashInfer kernel-optimization competition the team previously entered, an efficient harness they designed earned a top-three finish in the Full-Agent track. Beyond generating conventional operators such as DSA, having agents directly generate more complex, large kernels remains challenging. PipeLink can narrow an agent's generation target to a smaller code scope under given contracts and resource constraints, let it generate or deeply optimize local implementations based on clearer stage interfaces, and then combine and validate them with existing components through linking, thereby improving iteration efficiency for the overall implementation.

We hope PipeLink will let each developer or agent focus on a clearly bounded part, so that every carefully refined GPU-kernel optimization can become an independently deliverable, replaceable and reusable component that continues to provide value in new models and systems.

Open-source repository: https://github.com/PKU-DAIR/PipeLink

You are welcome to try it, give it a star, contribute code or offer valuable feedback from your trials!

This article comes from "Synced," written by "Synced."

Related topics

After reading

Join the AINRK community

Read how to join the community and connect with people working in AI.

Community information (opens in a new tab)