Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

PipeLink: Contract-Guided Linking for Reusable GPU Kernel Optimizations

PipeLink: Contract-Guided Linking for Reusable GPU Kernel Optimizations

Peking University's open-source PipeLink tool introduces contract-guided linking to compose independently developed GPU kernel stages into fused kernels, enabling reusable local optimizations without rewriting entire kernels, with near-zero overhead demonstrated on MegaKernel and attention variants.

Background: The Kernel Fusion Challenge

Modern large-model inference systems integrate many high-performance GPU operators from libraries such as CUTLASS, FlashInfer, FlashAttention, FlashMLA, DeepGEMM, and Marlin, as well as custom CUDA and Triton kernels. Developers further reduce launch overhead and data movement via CUDA Graphs, kernel fusion, and MegaKernels that encompass multiple layers or entire decoding passes. However, fusing implementations from different sources requires deep knowledge of each component's data layout, thread mapping, synchronization, and resource usage, making reuse and iteration costly. Replacing a single optimization often forces a rewrite of the whole fused kernel.

PipeLink: Contract-Guided Linking

PipeLink, developed by Assistant Professor Miao Xupeng's team at PKU-DAIR, provides a foundational mechanism to decompose GPU computation into independent stages with explicit contracts. A stage can be an operator, a data-loading step, a GEMM main loop, an epilogue, or a communication segment. Each stage declares its interface: what it provides, what it requires, its thread and resource usage, and its data-exchange and synchronization protocols. The linker then performs three tasks:

Contract checking – detects declared incompatibilities in call interfaces, data handoff, and synchronization protocols.

Resource coordination – assigns thread roles, shared memory, synchronization resources, and register budgets within supported constraints.

Connection code generation – emits adapter code for supported tensor handoffs and produces the combined scheduling entry point.

Built on NVIDIA nvJitLink's device-code linking and optimization capabilities, PipeLink adds cross-stage contract verification, resource coordination, and data-handoff mechanisms to assemble independently developed stages into a single fused kernel.

Supported Architectures and Toolchains

PipeLink currently supports Hopper and Blackwell GPUs and can combine handwritten CUDA, CUTLASS/CuTe, TileLang, and ThunderKittens components. Different developers retain their preferred toolchains and deliver results as stage packages adhering to a common interface convention.

Case Studies

Case 1: MegaKernel Local Optimization

The team split a 16-layer Llama-1B decoding MegaKernel (originally written in ThunderKittens) into nine packages — one instruction interpreter and eight operator packages — and relinked them into a persistent kernel. The linked version achieved 1.0001× the throughput of the monolithic compilation from the same source, showing near-zero overhead. Swapping only the attention package for a CUTLASS/CuTe implementation while keeping the other eight packages, instruction scheduling, and host code unchanged yielded a 2.19× speedup at 4096-token context. The linked hybrid build differed from its same-source monolithic build by less than 0.02% in performance.

Case 2: Attention Kernel Variants from a Shared Core

Reusing a single Hopper-targeted attention core package derived from FlashAttention-3, the team produced seven variants by replacing peripheral stages: dense attention, sliding-window attention, softcap attention, sliding-window + softcap, Phi-3 block-sparse attention, MiniMax-M3 sparse attention, and context-parallel attention. Sliding-window required only a 28-line mask stage; softcap needed only a 29-line score-transformation stage. The complex core computation logic remained unchanged across all variants.

Case 3: Communication-Computation Fusion for Context Parallelism

In context-parallel attention, a communication stage pushes KV shards over NVLink while the compute stage waits for the required blocks, enabling communication and computation to cooperate inside a single kernel per GPU. In a 32K prefill test, dual-GPU speedup reached 1.95× and quad-GPU speedup reached 3.66× relative to a single GPU.

Future Direction: AI Agent Integration

The team envisions PipeLink enabling AI agents to focus on well-bounded local optimizations within given contracts and resource constraints. Agents can generate or refine smaller stage implementations, then link and validate them with existing components, improving overall iteration efficiency. This approach was validated in the MLSys 2026 FlashInfer operator optimization competition, where their harness achieved a top-three finish in the Full-Agent track.

Paper: https://arxiv.org/abs/2610.37200 Code:

https://github.com/PKU-DAIR/PipeLink
PipeLink overview diagram
PipeLink overview diagram
Manual stitching vs PipeLink contract-based linking
Manual stitching vs PipeLink contract-based linking
PipeLink stage contract overview
PipeLink stage contract overview
MegaKernel local optimization with PipeLink
MegaKernel local optimization with PipeLink
Shared attention core with variant peripheral stages
Shared attention core with variant peripheral stages
About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

AI inferencekernel fusionMegaKernelGPU kernel optimizationattention variantscompiler linkingcontract-based design

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion