DeepSeek's optimized Multi-head Latent Attention kernels for LLM inference on NVIDIA GPUs and Ascend NPUs
open sourceMITfree
FlashMLA is DeepSeek's MIT library of optimized attention kernels, powering inference of the DeepSeek-V4.1 model on NVIDIA GPUs and Huawei Ascend NPUs. It contains token-level sparse attention kernels for prefill and for decoding with an FP8 or FP4 KV cache (the kernels behind DeepSeek Sparse Attention), a fused kernel that combines Q-norm, Q-RoPE, attention, O-RoPE and the cast to FP8, and dense attention kernels for prefill and backward. You build it as a Python package with pip against an installed PyTorch and call it from your inference code; it sits beside FlashAttention for attention kernels.
Problems it solves
- speed up Multi-head Latent Attention inference for DeepSeek models on Blackwell GPUs
- run sparse attention decoding with an FP8 KV cache
- get fast attention kernels for DeepSeek models on Huawei Ascend NPUs
Features
- token-level sparse attention kernels for prefill and decoding
- FP8 and FP4 KV cache decoding
- fused Q-norm, RoPE, attention and FP8-cast kernel
- dense attention kernels for prefill and backward
- NVIDIA SM100/SM103 and Huawei Ascend 950 support
Limitations
- needs an NVIDIA SM100 or SM103 GPU with CUDA 13.1+, or a Huawei Ascend 950 NPU with CANN 9.2.0+, and PyTorch 2.10+1
- the 2026.09.30 release dropped Hopper GPUs and DeepSeek V3, V3.2 and V4.0, and changed the KV cache format; older use needs a pinned commit1
- built from source with pip; no published package1
Alternatives
The same job
These do what FlashMLA does.
- FlashAttention Fast, memory-efficient exact attention kernels for training and running transformers on GPUs
