cuDNN Linear Attention: Optimized Mamba-2, GDN, GDP, KDA, and GDN-2 Kernels for NVIDIA GPUs
Joshua Park, Jingze Cui, Sherry Jiang, Mengyu Guo, Anerudhan Gopal, Vedaanta Agarwalla, Timmy Liu, Yu-Jung Chen, Yang Xu
Abstract
Linear attention replaces the softmax attention of Transformers with a fixed-size recurrent state, so that the runtime of prefill grows linearly rather than quadratically with the sequence length and the runtime of every decode step is constant in it. Many recent models have adopted a hybrid architecture where some layers swap dense attention for linear attention variants. cuDNN now ships optimized fused kernels for five linear attention variants, Mamba-2, Gated DeltaNet (GDN), Gated DeltaProduct (GDP), Kimi Delta Attention (KDA), and Gated DeltaNet-2 (GDN-2), on Blackwell (SM100, SM103), covering the training forward and backward passes. All of the kernels are open source and ship in cuDNN at https://github.com/NVIDIA/cudnn-frontend. In this paper, we walk through the optimizations that produce speedups over the state-of-the-art baselines. We start the kernel design from a single persistent kernel per pass. Then, in low settings, where a grid of one CTA per (batch, head) pair does not cover the SMs, we use intra-card context parallelism (intra-card CP) or a split of the value dimension (split-), both introduced by prior work in FlashQLA. We also fuse the other components that surround the linear attention operation in the block, the L2 normalization of the queries and keys and the gate and write-strength transforms, in both the forward and the backward pass. On GB200, the fused kernels for the four delta-rule variants run up to faster than the reference Triton implementations in the forward pass and up to in the backward pass, up to faster than FlashQLA, and up to faster than FlashKDA. The Mamba-2 kernels run up to faster than FLA and up to faster than mamba_ssm in the forward pass, and up to and in the backward pass.
Create a lesson
Metadata
- Comments
- 35 pages, 22 figures, 12 tables
Related papers
Are All Models Multimodal? Linear Bridges Connect Frozen Models Within, Not Outside, Their Training Subspaces
Shared title terminologycs.CLGregory Kielian, Shenil Dodhia, Phan Douangphachanh et al.
Simplicity is Enough: ReAct Agents for Prompt Optimization
Shared title terminologycs.CLAndrei Dumitrescu, Andrei C. Rusu, Adrian Catalin Badea et al.
Mitigating Hallucinations in Medical Question Answering on ESC Cardiology Guidelines: Evaluation and Retrieval Optimization
Shared title terminologycs.CLIlkin Masimov, Rufana Baghirli, Muhammad Rashid
DiCALM: Converting Autoregressive Convolution-Attention Language Models into Discrete Diffusion Language Models
Shared title terminologycs.CLPhong Le, Ngoc-Quan Pham, Dat Quoc Nguyen
Rethinking Sequential Locate-Then-Edit: Optimality and Stability
Shared title terminologycs.CLBingqing Liu, Wei Liu, Zhiying Deng et al.