Lightning Context Parallel
Aryan V S, Guande He, Tianpei Gu, Nan Liu, Chris Rockwell, Yanke Song, Xun Huang
Abstract
Context parallelism (CP) scales attention to long sequences by sharding the sequence across GPUs and exchanging queries, keys, values, or partial outputs between them. Existing implementations keep the attention kernel unchanged and exchange data through separate collectives and layout copies, which leaves the kernel waiting on transfers or competing with collectives for streaming multiprocessors when overlapped on another stream. We present Lightning Context Parallel (LCP), which fuses this communication into a single FlashAttention-4 kernel supporting Ulysses, K/V all-gather, pass-Q, and unified CP algorithms. In each thread block, a warp unused by FlashAttention-4 copies Q, K, and V over NVLink into peer GPUs in the layout attention expects, while the compute warps attend to blocks as they arrive. In algorithms where a GPU computes attention for another GPU's tokens, the kernel writes finished output tiles back to that peer's memory and merges partial outputs in-kernel. This eliminates separate collectives and intermediate layout copies while keeping all streaming multiprocessors dedicated to attention. Across bidirectional, streaming, causal prefill, and chunked prefill workloads on 2, 4, and 8 NVIDIA B200 GPUs, LCP achieves 1.12x, 1.23x, and 1.39x geometric-mean kernel speedups over the fastest of 13 open-source CP libraries. In vLLM-Omni, SGLang, and FastFrames, LCP reduces transformer forward-pass latency by up to 15% on bidirectional video, 28% on streaming video, 35% on image diffusion, and 4-17% on LLM prefill. Project Page: https://a-r-r-o-w.github.io/lightning-context-parallel/
Create a lesson
Metadata
- Comments
- Project Page: https://a-r-r-o-w.github.io/lightning-context-parallel/
Related papers
xInfer: Elastic Parallelism and Load Balancing for Long-Tail Offline LLM Inference
Shared title terminologycs.DCAo Sun, Yinghao Chen, Shiju Wang et al.
Effective Parallel Discrete Event Simulation on NUMA Machines through Ubiquitous Simulation-Object State
Shared title terminologycs.DCFrancesco Quaglia
ASHE: Asynchronous Stage-owned Heterogeneous Elastic-averaging for Pipeline-Parallel Training
Shared title terminologycs.DCHamin Jung, Sookwang Lee, Shinyoung Ahn et al.
Dependency-Aware Task Decomposition and Parallel Multi-LLM Execution on Serverless Workflows
Shared title terminologycs.DCJackson Beem, Amine Barrak
KVSeal: Serving Long-Context LLMs with Losslessly Compressed KV Caches
Shared title terminologycs.DCHangyu Liang, Zeyu Mi
SplitVerify: CPU-GPU Speculative Verification for Exact Long-Context Decoding
Shared title terminologycs.DCAswin Raj R