FlashInfer is a library and kernel generator for inference that delivers state-of-the-art performance across diverse GPU architectures. It provides unified APIs for attention, GEMM, and MoE operations with multiple backend implementations including FlashAttention-2/3, cuDNN, CUTLASS, and TensorRT-LLM.
Why FlashInfer?
State-of-the-art Performance: Optimized kernels for prefill, decode, and mixed batching scenarios
Multiple Backends: Automatically selects the best backend for your hardware and workload
Modern Architecture Support: Support for SM75 (Turing) and later (through Blackwell)
Low-Precision Compute: FP8 and FP4 quantization for attention, GEMM, and MoE operations
Production-Ready: CUDAGraph and torch.compile compatible for low-latency serving
Core Features
Attention Kernels
Paged and Ragged KV-Cache: Efficient memory management for dynamic batch serving
Decode, Prefill, and Append: Optimized kernels for all attention phases
MLA Attention: Native support for DeepSeek's Multi-Latent Attention
Cascade Attention: Memory-efficient hierarchical KV-Cache for shared prefixes
Sparse Attention: Block-sparse and variable block-sparse patterns
POD-Attention: Fused prefill+decode for mixed batching
GEMM & Linear Operations
BF16 GEMM: BF16 matrix multiplication for SM10.0+ GPUs.
FP8 GEMM: Per-tensor and groupwise scaling
FP4 GEMM: NVFP4 and MXFP4 matrix multiplication for Blackwell GPUs
Grouped GEMM: Efficient batched matrix operations for LoRA and multi-expert routing
Mixture of Experts (MoE)
Fused MoE Kernels
Multiple Routing Methods: DeepSeek-V3, Llama-4, and standard top-k routing
Quantized MoE: FP8 and FP4 expert weights with block-wise scaling
Sampling & Decoding
Sorting-Free Sampling: Efficient Top-K, Top-P, and Min-P without sorting
Speculative Decoding: Chain speculative sampling support
Communication
AllReduce: Custom implementations
Multi-Node NVLink: MNNVL support for multi-node inference
NVSHMEM Integration: For distributed memory operations
Other Operators
RoPE: LLaMA-style rotary position embeddings (including LLaMA 3.1)
flashinfer download-kernels installs the flashinfer-cubin and flashinfer-jit-cache wheels that match the installed flashinfer-python and CUDA versions. By default it installs pre-built kernels for every supported GPU architecture (several GB); pass --mode minimal to install the jit-cache provider only for the visible GPUs, or --sm (e.g. --sm sm90a, repeatable) to choose architectures explicitly.
Upgrading: the kernel wheels must match flashinfer-python exactly and are not upgraded with it. Run flashinfer download-kernels again after every pip install -U flashinfer-python; until then FlashInfer warns at import and ignores the old wheels (falling back to on-demand downloads and JIT compilation). Also note that flashinfer-cubin is no longer published to PyPI (0.6.13 was the last release there): a plain pip install -U flashinfer-cubin installs that stale wheel, so install it through flashinfer download-kernels or from --index-url https://flashinfer.ai/whl. See Upgrading.
For Blackwell (SM100+) CuTe DSL kernels, install with the CUDA 13 extra to enable Blackwell-optimized kernels:
Note: When using --no-build-isolation, pip does not automatically install build dependencies. FlashInfer requires setuptools>=77. If you encounter an error like AttributeError: module 'setuptools.build_meta' has no attribute 'prepare_metadata_for_build_editable', upgrade pip and setuptools first:
Build one JIT-cache provider for the target GPU, then build a shim that depends
on that provider. The example below builds an SM90a provider; both wheels must
use the same version settings.
For detailed information about logging levels, configuration, and advanced features, see Logging in our documentation.
Custom Attention Variants
Users can customize their own attention variants with additional parameters. For more details, refer to our JIT examples.
CUDA Support
Supported CUDA Versions: 12.9, 13.0, and 13.4 (PyTorch nightly)
Note: FlashInfer strives to follow PyTorch's supported CUDA versions plus the latest CUDA release.
CUDA 13.4 wheels are built with the preview toolkit and PyTorch nightly; runtime CI currently covers CUDA 12.9 and 13.0.
See CONTRIBUTING.md for the development setup, pull request guidelines
(PR template, performance numbers for optimizations), and how CI is triggered. Coding
agents pick up the same guidance from AGENTS.md;
the review guidance is in docs/code_review_guidance_human.md.
If you find FlashInfer helpful in your project or research, please consider citing our paper:
@article{ye2025flashinfer,
title = {FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving},
author = {
Ye, Zihao and
Chen, Lequn and
Lai, Ruihang and
Lin, Wuwei and
Zhang, Yineng and
Wang, Stephanie and
Chen, Tianqi and
Kasikci, Baris and
Grover, Vinod and
Krishnamurthy, Arvind and
Ceze, Luis
},
journal = {arXiv preprint arXiv:2501.01005},
year = {2025},
url = {https://arxiv.org/abs/2501.01005}
}
Alternatives
Use instead of flashinfer-python: tools that do the same job, closest first.