flashinfer

flashinfer-aiApache-2.0活跃维护

面向 LLM 推理服务的高性能 CUDA 内核库,提供注意力、MoE 等算子的 JIT 实现,用来加速 GPU 上的大模型推理。

FlashInfer: Kernel Library for LLM Serving

v0.7.3发布于 2026-11-04 05:57 UTC6,890star +19 / 7 天1,732fork同步于 2026-11-10 17:34 UTC

怎么上手

由 README 提炼,执行前请确认
pip install flashinfer-python
flashinfer show-config
硬件要求按 README 说明

需 NVIDIA GPU,支持 SM75(Turing)及以后架构,含 Ampere、Ada、Hopper、Blackwell 及 Jetson Thor、RTX 50 系列;README 未说明显存要求,也未提及 CPU 运行。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

面向 LLM 推理服务的高性能 GPU 内核库,统一提供 attention、GEMM 与 MoE 算子

面向 LLM 推理服务的高性能 CUDA 内核库,提供注意力、MoE 等算子的 JIT 实现,用来加速 GPU 上的大模型推理。

核心能力

  • 统一 attention/GEMM/MoE API,自动选择最优后端
  • 支持 Paged 与 Ragged KV-Cache 的动态批处理
  • 原生支持 MLA、Cascade、稀疏与 POD-Attention
  • FP8/FP4 量化覆盖 attention、GEMM 与 MoE
  • 无排序 Top-K/Top-P/Min-P 采样与投机解码

容易踩的坑

flashinfer-python 首次使用会编译或下载内核,想加快初始化或离线使用需另装 flashinfer-cubin 与 flashinfer-jit-cache;Blackwell SM100+ 的 CuTe DSL 内核需装 flashinfer-python[cu13];从源码可编辑安装时需 setuptools>=77,否则报 build_meta 缺 prepare_metadata_for_build_editable。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.7.3
  1. v0.7.4rc1Release v0.7.4rc1pre-release2026-11-06 · 2026-11-06 01:42 UTC
    查看更新说明

    What's Changed

  2. v0.7.3Release v0.7.3最新正式版2026-11-04 · 2026-11-04 05:57 UTC

    These highlights are also published at flashinfer.ai/releases.

    v0.7.3 Highlights

    FlashInfer v0.7.3 brings MTP and NVFP4 MLA decode to Rubin, and speeds up expert-parallel MoE decode steps on Blackwell while Hopper gains MXFP4 and NVFP4 experts. Hybrid Gated DeltaNet models gain paged recurrent state for prefix caching, DeepSeek Sparse Attention models get token-sparse decode, MoELayer adds a low-latency small-batch path from Ampere to Blackwell, and a first set of training kernels covers GLM-5.3-Flash and Qwen hybrid models.

    DeepSeek-class MTP decode, Qwen3.5 deterministic MoE and Mamba2 prefill run on Rubin

    BatchMLAPagedAttentionWrapper adds a cute-dsl-rubin-mtp backend for FP8 absorbed-MLA multi-token-prediction decode on SM107, and an experimental CAKE backend decodes dense MLA from an NVFP4 paged latent cache in the Kimi K3 and DeepSeek-V3 geometry. The deterministic unfused finalize of the CuTe DSL fused MoE works on Rubin for Qwen3.5 NVFP4 on Vera Rubin NVL72, and knobs="auto" tunes Rubin MegaMoE through autotune_v2(). Rubin also gets an SM107-native blockwise FP8 GEMM behind gemm_fp8_nt_groupwise(backend="auto"), Mamba2 prefill through SSDCombined(backend="cake"), and CAKE programs for DeepSeek routing, BGMV LoRA MoE, GDN and packed KDA decode.

    Expert-parallel MoE decode steps run faster on Blackwell, and Hopper adds MXFP4 and NVFP4 experts

    NVLinkOneSidedAlltoAll adds a Lamport transport for decode-sized steps on B200, B300, GB200 and GB300 (NVLinkOneSidedConfig(lamport=...)), which lowers dispatch and combine time for DeepSeek-V3, Kimi K3 and Qwen3 MoE decode steps, measured end to end on Kimi K3 in vLLM; the backend now shares its kernels with TensorRT-LLM and scales to 256 ranks. Blackwell MegaMoE adds an opt-in GenPhase decode pipeline, and knobs="auto" tunes the Blackwell backends through autotune_v2(). On Hopper, MoEEpLayer runs FP8-activation experts with MXFP4 or NVFP4 weights, and the new flashinfer.megamoe package adds fused NVFP4 and MXFP4 expert-parallel MoE on H100 and H200 for DeepSeek-V4-Flash-class models such as DeepSeek-V4-Flash-NVFP4.

  3. v0.7.3rc1Release v0.7.3rc1pre-release2026-10-30 · 2026-10-30 05:42 UTC
    查看更新说明

    What's Changed

  4. v0.7.2.post1Release v0.7.2.post12026-10-23 · 2026-10-23 18:38 UTC
    查看更新说明

    What's Changed

    v0.7.2.post1 brings FP8 and Prims-TS MoE to Rubin, and lets MoE and linear-attention (GDN) decode keep each of Rubin's two dies on its own memory. It also adds fused normalization and MoE communication kernels for Muse-Spark-Open, plus an FP8-output multi-node NVLink all-reduce reachable through the unified all-reduce API. On Blackwell GPUs, MoE gains StepFun's clamped SwiGLU activation and Kimi K3 MLA prefill gets a one-pass FP8 K/V pack, alongside launch and backend-selection tuning across GEMM, attention, norm, quantization and RoPE.

    Full Changelog: https://github.com/flashinfer-ai/flashinfer/compare/v0.7.2...v0.7.2.post1

  5. v0.7.2rc6Release v0.7.2rc6pre-release2026-10-22 · 2026-10-22 07:58 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Build Status Documentation

    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)
    • Normalization: RMSNorm, LayerNorm, Gemma-style fused operations
    • Activations: SiLU, GELU with fused gating

    GPU Support

    ArchitectureCompute CapabilityExample GPUs
    TuringSM 7.5T4, RTX 20 series
    AmpereSM 8.0, 8.6A100, A10, RTX 30 series
    Ada LovelaceSM 8.9L4, L40, RTX 40 series
    HopperSM 9.0H100, H200
    BlackwellSM 10.0, 10.3B200, B300
    BlackwellSM 11.0Jetson Thor
    BlackwellSM 12.0, 12.1RTX 50 series, DGX Spark

    Note: Not all features are supported across all compute capabilities.

    News

    Latest: GitHub Release

    Notable updates:

    • [2025-10-08] Blackwell support added in v0.4.0
    • [2025-03-10] Blog Post Sorting-Free GPU Kernels for LLM Sampling, which explains the design of sampling kernels in FlashInfer.

    Getting Started

    Installation

    Quickstart:

    pip install flashinfer-python
    

    Package Options:

    • flashinfer-python: Core package that compiles/downloads kernels on first use
    • flashinfer-cubin: Pre-compiled kernel binaries for all supported GPU architectures
    • flashinfer-jit-cache: CUDA-specific shim that installs architecture-specific pre-built kernel providers

    For faster initialization and offline usage, install the optional packages to have most kernels pre-compiled:

    pip install flashinfer-python
    flashinfer install-cubin-wheel
    flashinfer install-jit-cache-wheel
    

    For Blackwell (SM100+) CuTe DSL kernels, install with the CUDA 13 extra to enable Blackwell-optimized kernels:

    pip install flashinfer-python[cu13]
    

    Verify Installation

    flashinfer show-config
    

    Basic Usage

    import torch
    import flashinfer
    
    # Single decode attention
    q = torch.randn(32, 128, device="cuda", dtype=torch.float16)  # [num_qo_heads, head_dim]
    k = torch.randn(2048, 32, 128, device="cuda", dtype=torch.float16)  # [kv_len, num_kv_heads, head_dim]
    v = torch.randn(2048, 32, 128, device="cuda", dtype=torch.float16)
    
    output = flashinfer.single_decode_with_kv_cache(q, k, v)
    

    See documentation for comprehensive API reference and tutorials.

    Install from Source

    git clone https://github.com/flashinfer-ai/flashinfer.git --recursive
    cd flashinfer
    python -m pip install -v .
    

    For development, install in editable mode:

    python -m pip install --no-build-isolation -e . -v
    

    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:

    python -m pip install --upgrade pip setuptools
    

    Build optional packages:

    # flashinfer-cubin
    python -m build --no-isolation --wheel flashinfer-cubin
    python -m pip install flashinfer-cubin/dist/*.whl
    

    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.

    export FLASHINFER_JIT_CACHE_PROVIDER_ARCH=9.0a
    python -m build --no-isolation --wheel flashinfer-jit-cache-provider
    
    export FLASHINFER_JIT_CACHE_PROVIDER_ARCHS="9.0a"
    python -m build --no-isolation --wheel flashinfer-jit-cache
    
    python -m pip install \
      flashinfer-jit-cache-provider/dist/*.whl \
      flashinfer-jit-cache/dist/*.whl
    

    For more details, see the Install from Source documentation.

    Nightly Builds

    pip install -U --pre flashinfer-python --index-url https://flashinfer.ai/whl/nightly/ --no-deps
    pip install flashinfer-python  # Install dependencies from PyPI
    flashinfer install-cubin-wheel --nightly
    flashinfer install-jit-cache-wheel --nightly
    

    CLI Tools

    FlashInfer provides several CLI commands for configuration, module management, and development:

    # Verify installation and view configuration
    flashinfer show-config
    
    # List and inspect modules
    flashinfer list-modules
    flashinfer module-status
    
    # Manage artifacts and cache
    flashinfer download-cubin
    flashinfer install-cubin-wheel
    flashinfer install-jit-cache-wheel
    flashinfer download-kernels
    flashinfer clear-cache
    
    # For developers: generate compile_commands.json for IDE integration
    flashinfer export-compile-commands [output_path]
    

    For complete documentation, see the CLI reference.

    API Logging

    FlashInfer provides comprehensive API logging for debugging. Enable it using environment variables:

    # Enable logging (levels: 0=off (default), 1=basic, 3=detailed, 5=statistics)
    export FLASHINFER_LOGLEVEL=3
    
    # Set log destination (stdout (default), stderr, or file path)
    export FLASHINFER_LOGDEST=stdout
    

    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.

    Adoption

    FlashInfer powers inference in:

    Contributing

    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 CLAUDE.md / AGENTS.md; the review guidance is in docs/code_review_guidance_human.md.

    Acknowledgement

    FlashInfer is inspired by FlashAttention, vLLM, stream-K, CUTLASS, and AITemplate.

    Citation

    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}
    }