高效离线推理框架 Flood:吞吐量显著领先,支持多模态与量化
inclusionAI/flood
Flood 是一款面向离线应用的高效大语言模型推理框架。它采用流水线并行降低通信开销,并通过分段式KV缓存管理提升连续性。框架支持连续批处理、分块预填充、FP8/INT8量化及多模态模型推理。性能测试表明,其在多种模型和硬件上的吞吐量最高可达 vLLM 的 2.4 倍。其专用内核 SegmentAttention 在处理长序列时,解码速度较 FlashAttention 最高提升 3.16 倍。该项目于 2025 年 3 月开源并快速迭代,已支持前瞻解码等新特性。
蚂蚁的 FLOOD 框架用流水线并行替代张量并行来压通信开销,实测吞吐比 vLLM 高 1.4 到 2.4 倍,做离线推理部署的团队值得花半小时跑一下 benchmark 看看自家场景能不能吃这个红利。
FLOOD,一个面向吞吐量的框架,具备流水线并行和可分段缓存。
新闻或更新 🔥
- [2025/10] 我们为混合线性模型支持了 Lookahead,包括 Ring-mini-linear-2.0 和 Ring-flash-linear-2.0。
- [2025/09] 我们发布了分段线性注意力,以获得更好的性能。
- [2025/05] 我们将 Lookahead 集成到了 FLOOD 中。
- [2025/03] 我们发布了推理框架的代码
FLOOD。
简介
Flood 是一个专为离线应用设计的高效推理框架。它采用流水线并行(PP)方法来最小化与张量并行(TP)相关的通信开销。该框架融合了针对离线推理流程量身定制的高级调度策略,以最大限度地优化 GPU 利用率。
此外,Flood 使用可分段块而非分页块来进行 kvcache 管理,从而增强请求 kvcache 的连续性。

另外,我们开发了一个名为 SegmentAttention 的注意力 kernel,以配合可分段 kvcache 运行。Flood 目前支持一系列功能,包括:
- 零开销连续批处理
- 分块预填充
- 量化(FP8/INT8)模型推理
- 多模态模型推理
- 流式推理
- PPL(困惑度)评估
- 采样方法
- 多节点推理(实验性)
我们的框架正在快速迭代,因此部分功能可能存在 bug。如果你遇到任何问题,欢迎随时反馈。
我们支持的模型
- Ling MoE Linear V1、V2
- Ling MoE V1、V2
- Ling
- Llama
- Qwen
- Qwen3
- Deepseek V1、V2、V3
路线图
通过前缀缓存提升 prefill 性能。
通过 CUDA-Graph 提升性能。
使用
CUTE实现分段注意力以获得更好的性能,尤其是在使用 FP8 kvcache 时。减少
multiprocessing.queue中的 pickle/unpickle 开销。
性能对比
吞吐量
性能以生成 token 的 token/s(每秒 token 数)衡量。vLLM 版本为 0.6.6.post2,我们启用了 chunk prefill,chunk size 为 2048,其他参数与默认值相同。Ling 的模型架构可在 Ling 技术报告 中查看。
| 模型 | 数据集 | GPU | vLLM | flood | 加速比 |
|---|---|---|---|---|---|
| Llama3-8B | shareGPT | 1*A100 | 3201 | 4529 | 1.41 |
| Ling-Lite | shareGPT | 1 * H20 | 4355 | 5869 | 1.35 |
| Ling-Lite | shareGPT | 1 * A100 | 3576 | 5451 | 1.52 |
| Ling-Plus(FP8) | shareGPT | 8 * H20 | 2742 | 6569 | 2.40 |
| Ring-Mini-Linear-V2 | shareGPT | 1 * A100 | 4992.03 | 6777.64 | 1.36 |
| Ring-Mini-Linear-V2 | shareGPT | 1 * H20 | 6016.04 | 9117.56 | 1.52 |
Kernels
Seg-attn
Seg-attn 的性能以 TFLOPS(TFLOPs/秒)衡量。注意力头数为 64,kv 头数为 8,kv 头维度为 128。我们在 A100 上使用 flash-attn-2 的 flash_attn_2_cuda.varlen_fwd,在 H20 上使用 flash-attn-3 的 flash_attn_3_cuda.fwd。更多细节可参见 benchmark/ops/bench_seg_attn.py。
| 设备 | BatchSize | Q_len | K_len | flash-attn | seg-attn | 加速比 |
|---|---|---|---|---|---|---|
| A100 | 1 | 1024 | 1024 | 99.19 | 107.35 | 1.08 |
| A100 | 128 | 1 | 1024 | 10.65 | 13.56 | 1.27 |
| H20 | 1 | 1024 | 1024 | 90.28 | 96.05 | 1.06 |
| H20 | 128 | 1 | 1024 | 7.16 | 22.63 | 3.16 |
Seg-linear-attn
Seg-linear-attn 的性能以微秒(µs)为单位测量。注意力头数为 16,kv 头数为 16,kv 头维度为 128。我们在预填充阶段使用 flash-linear-attention 的 fla.ops.simple_gla.chunk_simple_gla,在解码阶段使用 flash-linear-attention 的 fla.ops.simple_gla.fused_recurrent.fused_recurrent_simple_gla。测试设备为 H20。更多细节可在 benchmark/ops/bench_seg_la.py 中查看。
| BatchSize | Seq_len | flash-linear-attention(µs) | seg-linear-attn(µs) | 加速比 |
|---|---|---|---|---|
| 1 | 1024 | 245.5 | 180.1 | 1.36 |
| 2 | 1024 | 227.4 | 132.5 | 1.72 |
| 64 | 1 | 129.5 | 51.8 | 2.50 |
| 256 | 1 | 190.4 | 132.0 | 1.44 |
安装
- 克隆此仓库并进入 PainlessInferenceAcceleration
git clone https://github.com/alipay/PainlessInferenceAcceleration.git
cd PainlessInferenceAcceleration/flood
- 安装包
python setup.py install
依赖项
我们主要在以下环境中进行开发和基准测试,较低版本可能也可以正常运行。
- cuda >= 12.4(越高越好)
- torch >= 2.5.0(越高越好)
- triton >= 3.1.0(越高越好)
- accelerate >= 1.4.0
- transformers >= 4.54.0
- 如果使用
fa2kernel,则需要 flash-attn >= 2.6.3 - 如果使用
fa3kernel,则需要 flash-attn-3 >= 3.0.0 - 如果使用 INT8 量化,则需要 vLLM >= 0.6.2
快速开始
可以在 example/simple_example.py 中找到一个简单的示例。
要复现所报告的性能,请运行 benchmark/bench_flood.py。
致谢
Flood 的灵感来自 FlashAttention 2&3、FasterTransformer、vLLM、flashinfer 等项目。
引用
[待定]
@misc{zhao2025flood,
title={Flood: A throughput-oriented Inference Framework for Large Language Model with pipeline parallelism and segmentable cache},
author={Yao Zhao and Chen Liang and Jingyu Hu and Zixuan Cheng and Zhen Wang and Longfei Li}
}
联系我们
如有技术问题和功能需求,请使用 Github issues 或 discussions。
来源:蚂蚁 inclusionAI:GitHub 新仓库 · github.com