flashinfer
flashinfer/ 1947 files | Python 用户入口层,暴露统一 API(attention/GEMM/MoE/sampling/comm/diffusion 等),承载 AOT、autotune cache、API logging、CLI、Cake 系列封装、实验性 API 入口:flashinfer.__init__, flashinfer.__main__:cli, flashinfer.aot, flashinfer.autotuner, flashinfer.cake_fmha, flashinfer.cake_dcp, flashinfer.deep_gemm, flashinfer.dsv3_ops, flashinfer.diffusion_ops, flashinfer.comm, flashinfer.experimental 依赖:csrc (via tvm_ffi), 3rdparty/cutlass, 3rdparty/cccl 包内按算子类型切分子目录:attention/, comm/, cute_dsl/, cutile/, cudnn/, autotuner/, experimental/, diffusion_ops/, mamba/ 等;Cake 系列(cake_fmha/cake_dcp/cake_rmsnorm_train/cake_sampling/cake_vsa 等)是 Blackwell 主战场 |
csrc
csrc/ 3211 files | C++ 调度与 PyTorch op 绑定层,做后端选择、workspace 分配、plan/run 拆分、JIT kernel 打包,并把调用分发到 FlashAttention/cuDNN/CUTLASS/Cake/DeepGEMM/BGMV MoE 等后端 入口:csrc/batch_attention.cu, csrc/batch_decode.cu, csrc/batch_prefill.cu, csrc/batch_mla_*.cu, csrc/batch_pod.cu, csrc/fused_moe/*.cu, csrc/cake_fmha/*.cu, csrc/deep_gemm/*.cu, csrc/bgmv_moe/*.cu, csrc/dcp/*.cu, csrc/blackwell_bf16_fp4/*.cu 依赖:include/, 3rdparty/cutlass, 3rdparty/cccl, 3rdparty/nixl, tvm_ffi 提交热点集中在 cake_fmha(129)、fused_moe(60)、cake_rmsnorm_train(43)、cake_all_gather_matmul(31)、cake_grouped_fp8_gemm(31)、cake_mamba_ssd_combined(14)、cake_bgmv_moe(10),说明 Blackwell + 训练 + MoE 是当前主战场 |
jit
flashinfer/jit/ 需验证 | JIT 编译层,用 TVM FFI + Jinja 模板按 HEAD_MASK_TYPE/PAGE_SIZE/MASK_MODE/QK_LAYOUT 等超参即时编译出特化 kernel,是 FlashInfer 默认交付形态 入口:flashinfer/jit/*.py (需验证具体文件名,目录下有 7 次提交) 依赖:csrc/, include/, 3rdparty/cutlass, tvm_ffi CLAUDE.md 明确「JIT by default」,开发者改 kernel 源码无需重装包;flashinfer-jit-cache 与 flashinfer-jit-cache-provider 是它的生产化配套 |
cake
csrc/cake_fmha/, flashinfer/cake_fmha.py, flashinfer/cake_fmha_request_ordered.py, flashinfer/cake_dcp.py, flashinfer/cake_rmsnorm_train.py, flashinfer/cake_sampling.py, flashinfer/cake_vsa.py, flashinfer/cake_minimax_h3.py cake_fmha 单目录 129 次提交,cake_rmsnorm_train 43 次 | Blackwell (SM100+) 专用高性能后端,覆盖 attention、DCP、RMSNorm 训练、采样、VSA、Minimax H3 等,是提交最密集的模块 入口:csrc/cake_fmha/*.cu (129 次提交), flashinfer/cake_fmha.py, flashinfer/cake_dcp.py, flashinfer/cake_rmsnorm_train.py, flashinfer/cake_vsa.py, flashinfer/cake_minimax_h3.py 依赖:3rdparty/cutlass (CuTe DSL), 3rdparty/cccl, csrc/blackwell_bf16_fp4/ Cake 系列是 v0.4.0 引入 Blackwell 支持后的主战场,最近提交包括 cake_fmha 重构、cake_dcp 单 program per split-KV、cake_rmsnorm_train 训练前向/反向、cake_bgmv_moe 第 5 轮调优、cake_grouped_fp8_gemm UE8M0、cake_all_gather_matmul 等 |
experimental
flashinfer/experimental/ 79 次提交 | 实验性 API 与后端容器,用于快速演进的工作(SM12x 内核、新模型算子、特化 kernel),受 @flashinfer_experimental_api 与 @experimental_backend 管控 入口:flashinfer/experimental/*.py (79 次提交) 依赖:csrc/, include/, 3rdparty/cutlass, 3rdparty/cccl CONTRIBUTING.md 明确实验性功能必须放在 flashinfer/experimental/,不注册到 aot.py,无兼容性保证,默认 4 周内毕业;FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1 才允许 auto 路由到实验后端 |
comm
flashinfer/comm/, csrc/dcp/, csrc/comm/ flashinfer/comm 2 次提交, csrc/dcp 3 次提交, tests/comm 3 次提交 | 通信层,提供 AllReduce、MNNVL 多节点 NVLink、NVSHMEM 分布式内存、DCP alltoall、Ulysses A2A 等 入口:flashinfer/comm/*.py, csrc/dcp/*.cu, csrc/comm/*.cu 依赖:3rdparty/nixl, 3rdparty_patches/nixl, NCCL/NVSHMEM NIXL 有 3rdparty_patches/nixl 补丁目录,说明对上游做了定制;最近提交有 cake_dcp 重构、cake_moe_finalize_allreduce、ulysses_head_chunk 等 |
cute_dsl
flashinfer/cute_dsl/ 需验证 | CuTe DSL 层,为 Blackwell 提供 Pythonic 的 kernel 编写方式(替代传统 C++ template),是 Cake 系列的基础 入口:flashinfer/cute_dsl/*.py 依赖:3rdparty/cutlass (nvidia-cutlass-dsl), CUDA 13.x pyproject.toml 中 cu13 extra 依赖 nvidia-cutlass-dsl>=4.7.0a0,sm107 extra 需要 >=4.8.0.dev0;benchmarks 下有多份 cute_dsl 相关 bench |
diffusion_ops
flashinfer/diffusion_ops/ 2 次提交, tests/diffusion_ops 1 次提交 | 扩散模型算子层,支持 DiT / 视频生成推理加速(fused layernorm、quant 等) 入口:flashinfer/diffusion_ops/*.py 依赖:csrc/, include/ 与候选人扩散模型推理加速背景匹配;benchmarks 有 bench_fused_dit_layernorm.py |
mamba
flashinfer/mamba/, csrc/cake_mamba_ssd_combined/ flashinfer/mamba 2 次提交, tests/mamba 2 次提交 | Mamba/SSD 层,支持状态空间模型推理(Mamba SSD combined scan) 入口:flashinfer/mamba/*.py, csrc/cake_mamba_ssd_combined/*.cu (14 次提交) 依赖:csrc/, include/, 3rdparty/cutlass 最近提交 cake_ssd_combined 是 SM100/SM103 的 exact-scan family,FP16 delta + FP32 state |
autotuner
flashinfer/autotuner/ 需验证 | 自动调优层,为 attention/GEMM/MoE 等选择最优后端与分块参数 入口:flashinfer/autotuner/*.py, flashinfer/autotune_cache.py 依赖:csrc/, jit/ benchmarks/bench_autotuner_accuracy.py 验证精度;FLASHINFER_DIST_AWARE_AUTOTUNE=1 启用实验性分布感知 autotune |
cubin
flashinfer-cubin/ 4 files | 预编译 cubin 包,用于生产冷启动与离线部署,避免首次调用 JIT 编译延迟 入口:flashinfer-cubin/build_backend.py, flashinfer_cubin/*.py 依赖:csrc/, include/ README 推荐 flashinfer install-cubin-wheel 加速初始化 |
jit_cache
flashinfer-jit-cache/, flashinfer-jit-cache-provider/ flashinfer-jit-cache 4 files, flashinfer-jit-cache-provider 6 files | 架构特化的预构建 kernel provider,是 JIT 的生产化配套 入口:flashinfer-jit-cache/build_backend.py, flashinfer-jit-cache-provider/build_backend.py, flashinfer_jit_cache_provider/*.py 依赖:csrc/, jit/ FLASHINFER_JIT_CACHE_PROVIDER_ARCH=9.0a 控制目标架构 |
3rdparty
3rdparty/cutlass, 3rdparty/cccl, 3rdparty/nixl, 3rdparty/spdlog, 3rdparty_patches/nixl 需验证 | 第三方依赖层,提供 CUTLASS/CuTe DSL、CCCUDA 原语、NIXL 通信、spdlog 日志 入口:3rdparty/cutlass/include/cute, 3rdparty/cutlass/include/cutlass, 3rdparty/cccl/, 3rdparty/nixl/, 3rdparty_patches/nixl/ 依赖:CUDA Toolkit NIXL 有 3rdparty_patches/nixl 补丁目录,说明对上游做了定制;cu13 extra 依赖 nvidia-cutlass-dsl>=4.7.0a0 |
build
build_backend.py, build_utils.py, ci/ ci/ 9 files | 构建与 CI 层,驱动 editable install、cubin 编译、jit-cache provider 构建、多 CUDA 版本 CI 入口:build_backend.py, build_utils.py, ci/scripts/, ci/validate_cuda_versions.py 依赖:csrc/, include/, flashinfer/ pyproject.toml 指定 build-backend = build_backend;支持 CUDA 12.9/13.0/13.4;FLASHINFER_NVCC_THREADS/MAX_JOB 控制并行度 |
tests
tests/ tests/attention 4 次提交, tests/comm 3 次提交, tests/mamba 2 次提交, tests/diffusion_ops 1 次提交 | 测试层,覆盖 attention/comm/mamba/diffusion_ops/experimental 等,含 full 参数矩阵模式 入口:tests/attention/, tests/comm/, tests/mamba/, tests/diffusion_ops/, tests/experimental/ 依赖:flashinfer/, csrc/ CLAUDE.md 推荐 pytest tests/ 与 pytest tests/ --full;多 GPU 测试用 mpirun -np 4 |
benchmarks
benchmarks/ 208 files | 基准测试层,含 208 个文件,覆盖 attention/GEMM/MoE/comm/sampling/sparse_attention/mamba/diffusion 等,含 cake 系列大量 bench 入口:benchmarks/flashinfer_benchmark.py, benchmarks/bench_*.py, benchmarks/routines/*.py, benchmarks/moe_ep/ 依赖:flashinfer/, csrc/ benchmarks/routines/ 提供 attention/gemm/moe/norm/quantization/rope/sampling/sparse_attention/topk_varlen/mamba/unified_moe 等可复用 routine;benchmarks/moe_ep/ 是 MoE EP 专用 bench |