Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →

Mamba's creators sped up its H100 GPU kernels by up to 4.1x and beat FlashAttention-4

Mamba is pitched as a transformer replacement that is cheap on long texts, but its GPU code was rougher than that of standard attention. Gu and Dao rewrote the Mamba-2 and Mamba-3 kernels so that data stays in the chip's fast memory instead of shuttling back and forth to video memory. On Nvidia H100, the Mamba-2 forward pass is up to 4.1x faster than the official Triton kernel and outpaces FlashAttention-4 from 1–2 thousand tokens. But this is a comparison of kernels, not of the entire layer, and the gain on a full layer is smaller.

AI-processed from TG: @gonzo_ML (gonzo-обзоры ML статей); edited by Hamidun News
Mamba's creators sped up its H100 GPU kernels by up to 4.1x and beat FlashAttention-4
Source: TG: @gonzo_ML (gonzo-обзоры ML статей). Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceTG: @gonzo_ML (gonzo-обзоры ML статей) ↗
Editor-in-Chief
Key metric #1The kernels are written in CuTe-DSL for Nvidia Hopper and Blackwell GPUs
Key metric #2The authors did not show decoding or the backward pass on Blackwell
The code is openthe state-spaces/mamba repository, with the paper accepted to NeurIPS 2026

Mamba is marketed as an alternative to transformers: the cost of processing grows linearly with text length rather than quadratically, so long documents should be cheaper to handle. But on paper, the advantage was often eaten up by the implementation. Standard attention has GPU programs (called kernels) polished over years, such as FlashAttention, while Mamba ran on less optimized code.

Albert Gu and Tri Dao, the authors of Mamba itself, together with a team that includes J. Zico Kolter, rewrote the kernels for Mamba-2 and Mamba-3. On the Nvidia H100 GPU, the Mamba-2 forward pass (that is, the layer computation during training and when reading a prompt) became up to 4.

1x faster than the official Triton kernel. It also outpaces causal FlashAttention-4, a recent fast attention implementation, starting at 1–2 thousand tokens. The paper has been accepted to NeurIPS 2026, and the code is in the state-spaces/mamba repository.

What was actually rewritten

The new kernels are built on CuTe-DSL. The idea is easier to grasp if you think of the GPU as a workshop. The fast memory inside the chip, the registers, is the workbench: everything is within reach, but there is little space. Video memory is the warehouse: there is plenty of room, but you have to walk over for every part. Older implementations made trips to the warehouse and back too often. Kernel fusion keeps intermediate states and decay masks on the workbench and does not offload them between steps.

There are two specific techniques. The first, Split Sequence, distributes long segments of the sequence across thread blocks and processes small chunks with a thread directly on the chip. The second, hierarchy-aware segsum, lays out the causal mask in registers according to the GPU's hierarchy: threads, warps, and blocks. A causal mask ensures that each token sees only the tokens before it, and segsum is the way to compute the accumulated decay between positions.

What the numbers show

On H100, the Mamba-2 forward-pass kernel is up to 4.1x faster than the official Triton kernel. Kernel fusion shrinks Mamba's forward-pass gap behind attention at 2–4 thousand tokens, and from 1–2 thousand tokens the Mamba-2 kernel surpasses causal FlashAttention-4.

Numerical stability is a separate point. A fast way to compute the masks is to subtract prefix sums, but that risks number overflow. The authors show that their stable summation is not slower than this trick and avoids overflows. For low-precision training this matters: a single overflow can ruin an entire run.

The practical outcome: on Hopper and Blackwell GPUs there are now fast Mamba-2 kernels for prefill (the initial processing of a long prompt) and for training.

Where the gains end

The work's limitations are notable, and you should account for them before rewriting a pipeline.

  • Attention was compared with kernels of different widths and without the full layer. Comparing kernel against kernel is not the same as comparing a whole model block, which includes projections, normalizations, and the rest of the scaffolding.
  • When the full layer and the backward pass (gradient computation during training) are counted, the gain shrinks.
  • Decoding, meaning token-by-token generation, and the backward pass on Blackwell are not shown in the work. Decoding in particular determines the serving cost of chat models.

What to do with this

If you are training or fine-tuning hybrid models with Mamba layers, or running long prompts through state-space models on H100, take the fresh code from the repository and measure your own layer and your own batch size. The "up to 4.1x" figure refers to the best case on the forward-pass kernel, and in a real pipeline it may turn out to be noticeably more modest.

For those choosing between attention and Mamba, the conclusion is cautious. The argument that "Mamba only wins on very long contexts" is weaker now: the threshold at which it beats FlashAttention-4 on the forward pass has dropped to 1–2 thousand tokens. The caveats about the full layer still stand, so the decision should rest on measurements on your own model, not on headlines. For engineers who write their own kernels, the work will serve as a textbook: it shows how accounting for the GPU's hierarchy and careful register management turn structured matrices into real speed.

Story

Key Questions Answered

What was actually rewritten?

The new kernels are built on CuTe-DSL. The idea is easier to grasp if you think of the GPU as a workshop. The fast memory inside the chip, the registers, is the workbench: everything is within reach, but there is little space. Video memory is the warehouse: there is plenty of room, but you have to walk over for every part. Older implementations made trips to the warehouse and back too often. Kernel fusion keeps intermediate states and decay masks on the workbench and does not offload them between steps.

What the numbers show?

On H100, the Mamba-2 forward-pass kernel is up to 4.1x faster than the official Triton kernel. Kernel fusion shrinks Mamba's forward-pass gap behind attention at 2–4 thousand tokens, and from 1–2 thousand tokens the Mamba-2 kernel surpasses causal FlashAttention-4. Numerical stability is a separate point. A fast way to compute the masks is to subtract prefix sums, but that risks number overflow. The authors show that their stable summation is not slower than this trick and avoids overflows.

Where the gains end?

The work's limitations are notable, and you should account for them before rewriting a pipeline. Attention was compared with kernels of different widths and without the full layer. Comparing kernel against kernel is not the same as comparing a whole model block, which includes projections, normalizations, and the rest of the scaffolding. When the full layer and the backward pass (gradient computation during training) are counted, the gain shrinks.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — Mamba's creators sped up its H100 GPU kernels by up to 4.1x and beat FlashAttention-4 https://news.hamidun.com/en/news/18588/mamba-s-creators-sped-up-its-h100-gpu-kernels-by-up-to-4-1x

What do you think?
Loading comments…