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。
FLOOD, a throughput-oriented framework with pipeline parallism and segmentable cache.
News or Update 🔥
- [2025/10] We support for Lookahead in hybrid linear models, including Ring-mini-linear-2.0 and Ring-flash-linear-2.0.
- [2025/09] We release segment linear attention for better performance.
- [2025/05] We integrade Lookahead into FLOOD.
- [2025/03] We release the code of our inference framework
FLOOD.
Introduction
Flood is a highly effective inference framework designed for offline applications. It employs a pipeline parallelism (PP) approach to minimize communication costs associated with tensor parallelism (TP). This framework incorporates advanced scheduling strategies tailored for offline inference processes to optimize GPU utilization to its fullest potential.
Furthermore, Flood utilizes segmentable blocks instead of paged blocks for kvcache management, thereby enhancing the continuity of the kvcache for requests.
Additionally, we have developed an attention kernel, termed SegmentAttention, to function with the segmentable kvcache. Flood currently supports a range of features, including:
- Zero-overhead continuous batching
- Chunked prefill
- Inference of Quantization(FP8/INT8) models
- Inference of multi-modal models
- Streaming inference
- PPL (Perplexity) evaluation
- Sampling methods
- Multi-node inference(experimental)
Our framework is undergoing rapid iteration, which may result in some features having bugs. If you encounter any issues, please feel free to report them.
Models we support
- Ling MoE Linear V1, V2
- Ling MoE V1, V2
- Ling
- Llama
- Qwen
- Qwen3
- Deepseek V1, V2, V3
Roadmap
Improve prefill performance with Prefix caching.
Improve performance with CUDA-Graph.
Implement segment attention with
CUTEfor better performance, especially with FP8 kvcache.Reduce pickle/unpickle overhead in
multiprocessing.queue.
Performance Comparison
Throughput
Performance is measured by token/s(tokens per second) of generated tokens. The version of vLLM is 0.6.6.post2, we enable the chunk prefill with chunk size 2048, other parameters are the same as default. The model archetechure of Ling can be found in the Ling technical report.
| model | dataset | GPU | vLLM | flood | speedup |
|---|---|---|---|---|---|
| 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
Performance of Seg-attn is measured by TFLOPS (TFLOPs/second). Attention head number is 64, kv head number is 8, and kv head dimension is 128. We use flash_attn_2_cuda.varlen_fwd of flash-attn-2 in A100 and flash_attn_3_cuda.fwd of flash-attn-3 in H20. More detail can be found in benchmark/ops/bench_seg_attn.py.
| Device | BatchSize | Q_len | K_len | flash-attn | seg-attn | speedup |
|---|---|---|---|---|---|---|
| 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
Performance of Seg-linear-attn is measured by microseconds(µs). Attention head number is 16, kv head number is 16, and kv head dimension is 128. We use fla.ops.simple_gla.chunk_simple_gla of flash-linear-attention in prefilling and fla.ops.simple_gla.fused_recurrent.fused_recurrent_simple_gla of flash-linear-attention in decoding. The test device is H20. More detail can be found in benchmark/ops/bench_seg_la.py.
| BatchSize | Seq_len | flash-linear-attention (µs) | seg-linear-attn (µs) | speedup |
|---|---|---|---|---|
| 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 |
Installation
- Clone this repository and navigate to PainlessInferenceAcceleration
git clone https://github.com/alipay/PainlessInferenceAcceleration.git
cd PainlessInferenceAcceleration/flood
- Install Package
python setup.py install
requirements
We mainly develop and benchmark on the environment below, lower version may also be OK.
- cuda >= 12.4 (higher is better)
- torch >= 2.5.0 (higher is better)
- triton >= 3.1.0 (higher is better)
- accelerate >= 1.4.0
- transformers >= 4.54.0
- flash-attn >= 2.6.3 is required if use
fa2kernel - flash-attn-3 >= 3.0.0 is required if use
fa3kernel - vLLM >= 0.6.2 is required if use INT8 quantization
Quick Start
A simple example can be found in example/simple_example.py.
To reproduce the reported performance, run the benchmark/bench_flood.py.
ACKNOWLEDGE
Flood is inspired by FlashAttention 2&3, FasterTransformer, vLLM, flashinfer projects.
Citations
[TBD]
@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}
}
Contact Us
For technical questions and feature requests, please use Github issues or discussions.