提出 "Three Taxes" 框架(Kernel Launch / Bulk Synchronous / Inter-Kernel Data Locality)解构 BSP 模型在多 GPU LLM 推理中的性能开销;基于 AMD Iris 库将 collective communication 融合进 Triton compute kernel,以 tile-level producer-consumer pipeline 替代全局 barrier,在 AG+GEMM 和 Flash Decode 上实现 10–20% 端到端延迟加速。
分布式 LLM 执行普遍采用 Bulk Synchronous Parallel (BSP) 模型:每一步先本地计算,然后进入全局 collective 通信 + 同步,形成 "Compute → Wait → Collective → Wait → Compute" 的刚性五阶段模式。这一模型引入三类性能税:
三类税并非硬件固有限制,而是 BSP 编程模型的 artifact。
将 collective communication 逻辑直接融合进 compute kernel,用 tile-level 的 producer-consumer pipeline 替代全局 barrier。核心工具是 Iris(AMD 的 Triton 通信库),提供与 Triton 原生 tl.load() / tl.store() 签名一致的 iris.load() / iris.store() 远程内存访问原语。
两种融合模式:
iris.load() 远程 tile,隐式等待数据到达再继续计算。无需额外 kernel launch、无需显式同步 flag。一次性消除全部三类税。iris.store() 将本地 shard 推送到所有远程 GPU 的 inbox,用 RemoteAtomicInc 设置 per-tile flag;compute kernel 对每个 tile spin-wait flag 后从本地 inbox 加载。消除 Bulk Synchronous Tax 和 Inter-Kernel Tax,但保留一个额外 kernel launch。Flash Decode 采用渐进式优化路径:BSP baseline → Iris-based Independent AG Kernel(同构替换 RCCL)→ Fine-Grained Waits(consumer 端 per-tile spin-wait)→ Fully Fused Kernels(producer 直接 push + consumer spin-wait,消除独立 AG kernel)。
Tile-level producer-consumer pipeline with GPU-initiated remote memory access. 将通信粒度从 collective-level(整个 All-Gather 完成才开始计算)降到 tile-level(一个 tile 到达即可开始对应计算),要求三个条件同时满足:(1) 硬件支持 GPU-initiated RMA(AMD Infinity Fabric XGMI 的 remote load/store);(2) 编程模型在 kernel 内暴露 RMA 原语且与 compute 原语同构(Iris on Triton);(3) kernel 算法可按 tile 分解使得 partial 数据即可推进计算(GEMM 的 K-split tiling、Flash Decode 的 online softmax partial reduction)。三者缺一不可——缺硬件 RMA 则必须经由 host 调度 collective;缺同构 API 则开发成本过高(如 Triton Distributed 的 C-style 嵌入);缺 tile-decomposable 算法则无法形成 pipeline。
BSP 的五阶段模式在每次 collective 前后各产生一次 barrier idle,加上 kernel launch 开销和 HBM round-trip,三类税叠加构成 10–25% 的性能损失。
Pull Model 在 GEMM inner loop 中将 tl.load(A) 替换为 iris.load(A),kernel 线程在远程数据到达前 stall,到达后直接从寄存器继续计算。无额外 kernel、无 flag、无 HBM round-trip。
Push Model 需要额外 push kernel,但 iris.store() 的数据传输效率高于 iris.load()(Infinity Fabric 上 store 路径比 load 路径更优),因此在大矩阵下性能更好。
V1→V2 验证 Iris 的 raw bandwidth 与 RCCL 持平;V2→V3 通过 consumer-side per-tile wait 消除 Bulk Sync Tax(主要收益来源);V3→V4 将 AG 逻辑融入 producer kernel,额外消除 Kernel Launch Tax。
| 符号 | 定义 |
|---|---|
| $A \in \mathbb{R}^{M \times K}$ | 输入矩阵,按 $K$ 维分片到 $W$ 个 GPU |
| $A_i \in \mathbb{R}^{M \times K/W}$ | GPU $i$ 持有的 $A$ 分片 |
| $B \in \mathbb{R}^{K \times N}$ | 本地权重矩阵(每个 GPU 持有完整副本) |
| $C \in \mathbb{R}^{M \times N}$ | 输出矩阵,$C = A \cdot B$ |
| $W$ | World size(GPU 数) |
| $r$ | 当前 GPU rank |
| $Q$ | Flash Decode 查询张量 |
| $K_r, V_r$ | Rank $r$ 的本地 KV cache 分片 |
| $O_r^{\text{partial}}$ | Rank $r$ 计算的 partial attention 输出 |
| $\text{Inbox}_d(s, k)$ | GPU $d$ 上为来自 GPU $s$ 第 $k$ 块预留的接收缓冲区 |
| $\text{Flags}_d(s, k)$ | 对应 inbox slot 的 ready 信号(atomic counter) |
AG + GEMM 核心等式:
$$C = A \cdot B = \left[\,A_0 \;\|\; A_1 \;\|\; \cdots \;\|\; A_{W-1}\,\right] \cdot B$$
All-Gather 沿 $K$ 维拼接所有分片后做完整 GEMM。等价地,可按 shard 分解:
$$C = \sum_{s=0}^{W-1} A_s \cdot B_{[sK/W : (s+1)K/W, :]}$$
这就是 Pull/Push 模型的数学基础:外层循环遍历 $s = 0 \ldots W-1$,内层对每个 shard 的 tile 做 partial GEMM 并累加。每个 partial product 只需一个远程 shard,因此可以 tile 粒度 pipeline。
Flash Decode 全局 reduction:
$$O_{\text{final}} = \text{OnlineSoftmaxCombine}(O_0^{\text{partial}}, O_1^{\text{partial}}, \ldots, O_{W-1}^{\text{partial}})$$
Online softmax 的 associativity 保证 partial results 可以按任意顺序 combine,这是 fine-grained waits 正确性的关键——consumer 不必等所有 partial 到齐,到达一个就 combine 一个。
| # | 检查项 | 结论 |
|---|---|---|
| 1 | GEMM 维度一致性 — $A$ 为 $(M, K)$,$B$ 为 $(K, N)$,$C$ 为 $(M, N)$;各 shard $A_i$ 为 $(M, K/W)$ | ✓ 正确 |
| 2 | All-Gather 完整性 — $W$ 个 shard 拼接后恢复完整 $A$;Pull 模型循环 $s = 0 \ldots W-1$ 覆盖所有 shard | ✓ 正确 |
| 3 | Pull 模型正确性 — 每个 GEMM tile 的 $K$ 维遍历所有 $W$ 个 shard,等价于对完整 $A$ 做 GEMM | ✓ 等价于标准 tiled GEMM |
| 4 | Push 模型 flag 顺序 — iris.store() 先于 RemoteAtomicInc(flag),保证 consumer spin-wait 看到 flag > 0 时数据已在 inbox | ✓ 依赖 Infinity Fabric 的 store ordering(XGMI 保证 same-direction store visibility) |
| 5 | Flash Decode online softmax 可交换性 — partial results 的 combine 顺序不影响最终结果 | ✓ 由 Milakov & Gimelshein (2018) 证明 |
| 6 | Benchmark 统计 — 500 iterations + 100 warmup,host-side timing with stream sync | ✓ 标准方法,但未报告 variance / CI |
| # | 检查项 | 分析 |
|---|---|---|
| C1 | 带宽预算(AG+GEMM, M=4096) | 每 GPU 接收 $7/8 \times 4096 \times 8192 \times 2 \approx 56$ MB。7 条 XGMI link 并行,per-link ≈ 128 GB/s,传输时间 ≈ 8 MB / 128 GB/s ≈ 0.06 ms。GEMM compute($2 \times 4096 \times 8192 \times 28672 \approx 1.93$ TFLOPS,MI300X FP16 peak ~1.3 PFLOPS)≈ 1.5 ms。通信仅占 ~4%,与论文报告的 moderate speedup(10–20%)一致——三类税主要来自 launch overhead + sync idle + locality loss 而非 raw BW 不足 |
| C2 | 带宽预算(AG+GEMM, M=1) | 接收数据仅 ~14 KB,通信时间 < 0.1 μs。但 BSP 模式 3 次 kernel launch 各 5–10 μs,总 launch overhead 15–30 μs 可能与 GEMM compute 同量级——Pull 模型消除所有 launch 后 speedup 最大,与 Fig 9 中小 M 的高 speedup 一致 |
| C3 | Scaling formula | Pull 模型:每 GPU 发起 $W-1$ 次 remote load,数据量 $M \times K \times (W-1)/W \times 2$ bytes,在 fully-connected topology 下各 link 并行,时间 $O(M \times K / BW_{\text{link}})$,与 $W$ 近似无关。Push 模型:每 GPU 发出 $W-1$ 次 remote store,同样各 link 并行,时间类似。但 inbox 内存开销 $O(W)$ per GPU |
| C4 | Store vs Load 不对称 | 论文声称 Push 的 iris.store() 比 Pull 的 iris.load() 更高效。Infinity Fabric 上 store 是 fire-and-forget(发起方不阻塞等 ack),load 需等 data round-trip。这一不对称在 RDMA 文献中已知,论文未量化但方向正确 |
无形式化定理或数学证明——仅实证验证。"Three Taxes" 是定性分析框架而非定量模型;论文未推导三类税各自的量化占比或给出 closed-form performance model。实验设计合理但缺少 confidence interval 和绝对延迟数值。
| 项目 | AG+GEMM | Flash Decode |
|---|---|---|
| GPU | 8× AMD MI325X | 8× AMD MI300X |
| 显存 | 未明确(MI325X: 256 GB HBM3e) | 192 GB HBM3 per GPU |
| 互连 | Infinity Fabric, 896 GB/s aggregate/GPU | 同左 |
| 软件 | Ubuntu 24.04, PyTorch 2.6.0, ROCm 6.4.3 | 同左 |
| Baseline | RCCL 2.22.3 + torch.matmul | RCCL 2.22.3 + Triton Distributed 版 Flash Decode |
| 精度 | FP16 | FP16 |
| 度量 | E2E latency (ms), 500 iter + 100 warmup | 同左 |
两个实验使用不同 GPU 型号是一个实验设计缺陷——无法直接交叉比较 AG+GEMM 和 Flash Decode 的绝对数值。
固定 $N = 28672$,$K = 8192$,$W = 8$,变化 $M = 1 \ldots 4096$。
关键观察:
torch.matmul 后端有高度优化的 GEMM kernel(可能调用 rocBLAS 专用 routine),而论文的 Triton GEMM kernel 缺乏对应的 tile-size tuning。这是 compute kernel 本身的成熟度问题,非融合策略的缺陷。iris.store() 比 Pull 的 iris.load() 在 Infinity Fabric 上更高效(store fire-and-forget vs load round-trip)。额外 push kernel 的 launch cost 被 amortize。固定 batch = 1,96 query heads,head dim = 128,$W = 8$,变化 Global KV Length = 32K … 2M。
渐进式消融:
| 版本 | 消除的税 | vs RCCL baseline |
|---|---|---|
| Iris Independent AG Kernel | 无(仍为 BSP) | ~1.0× — 验证 Iris raw BW 与 RCCL 持平 |
| Fine-Grained Waits | consumer-side Bulk Sync Tax | ~1.10–1.15× — 主要收益来源 |
| Fully Fused Kernels | 全部三类税 | ~1.10–1.48× — 最终方案 |
Fine-Grained Waits 提供大部分 speedup(~60–70% of total gain),说明 consumer-side barrier idle 是最大的单一开销。Fully Fused 额外消除 Kernel Launch Tax 贡献剩余 gain。
最优 speedup 出现在中等 KV Length(~512K),达到 ~1.48×。极长 KV Length(2M)时 speedup 降至 ~1.20×,因为 compute 占比增大,通信+同步税的相对占比缩小。
Flash Decode 1→2→4→8 GPU scaling:
| Step | 论点 | 依据 | 逻辑关系 |
|---|---|---|---|
| 1 | BSP 模型强制 "Compute-Wait-Collective-Wait-Compute" 模式,产生三类可量化的性能税 | §2.3: Kernel Launch Tax = 每次 dispatch 固定延迟;Bulk Sync Tax = barrier 前后 GPU idle;Inter-Kernel Tax = HBM round-trip | 问题定义 → 分析框架 |
| 2 | 三类税是编程模型的 artifact 而非硬件固有限制 | §2.3: 如果能在单个 kernel 内完成 compute + communication,三类税均可消除 | 框架 → 可行性论证 |
| 3 | Iris 提供 Triton-native 的 GPU-initiated RMA 原语,使 in-kernel communication 成为可能 | §3.3: iris.load() / iris.store() 与 tl.load() / tl.store() 签名一致;vs Triton Distributed 的 C-style API 更简洁 | 可行性 → 工具选择 |
| 4 | Pull Model 将 remote load 嵌入 GEMM inner loop,一次性消除全部三类税(small M 场景最优) | §4.1.3 + Algorithm 1: 单一 kernel、无 barrier、数据从 remote 直达寄存器 | 工具 → 方案 A |
| 5 | Push Model 将 remote store 解耦到独立 kernel + per-tile flag sync,消除两类税(large M 场景更优) | §4.1.4 + Algorithm 2-3: store fire-and-forget 效率 > load round-trip,但多一个 kernel launch | 工具 → 方案 B |
| 6 | Flash Decode 渐进式优化从 BSP 到 Fully Fused,逐步消除各税并验证每步贡献 | §4.2 + §5.3: V1→V2(~1.0×,控制实验)→V3(~1.1×,主要收益)→V4(~1.2–1.48×,累积收益) | 方案 A/B → 复杂 workload 应用 |
| 7 | Fused Kernels 在 AG+GEMM 和 Flash Decode 上均优于 BSP baseline,验证 Three Taxes 框架的预测力 | §5.2 Fig 9 + §5.3 Fig 10: 除 AG+GEMM M∈[8,64] 外一致优于 baseline | 应用 → 实证验证 |
源码:github.com/ROCm/iris(论文 §1 footnote 1)。
论文未给出具体 file:line 引用,但 Iris 是 AMD 开源项目,fused kernel 的实现基于 Iris 提供的以下核心 API:
| API | 用途 | 对应论文段落 |
|---|---|---|
iris.load(ptr, rank, ...) | Pull 模型:在 GEMM inner loop 中远程加载 tile | §4.1.3, Algorithm 1 |
iris.store(val, ptr, rank, ...) | Push 模型 / Flash Decode Fused:将 tile 推送到远程 inbox | §4.1.4 Algorithm 2, §4.2.5 Algorithm 4 |
iris.atomic_inc(ptr, rank, ...) | Push 模型:设置 per-tile ready flag | §4.1.4 Algorithm 2 |
| symmetric heap allocation | 分配跨 GPU 可见的 inbox 和 flag 缓冲区 | §3.3 |
iris.store() → RemoteAtomicInc(flag) 的顺序保证。Infinity Fabric XGMI 在同一方向上保证 store visibility ordering,因此 consumer 在观测到 flag increment 时数据必已到达 inbox。如果迁移到 RoCE/IB 网络,需要显式 fence 或 RDMA completion ordering 来保证同等语义。Tile-level pipeline 的实现要求 Iris 的 remote load/store 延迟足够低(与 HBM load 同量级),否则 stall 时间抵消融合收益。论文通过 V1→V2 实验(Iris AG ~= RCCL throughput)间接验证了 Iris 原语的 BW 效率,但未给出 single remote load/store 的微基准延迟数据。
Scope 极窄:仅 intra-node 通信。现实部署的主要瓶颈往往在 inter-node(跨 NIC/网络),尤其 MoE 的 all-to-all 或 pipeline parallelism 的 p2p,本文完全未触及。
| 参数 | 数值 |
|---|---|
| GPU/node | 8 |
| GPU 型号 | MI300X (Flash Decode) / MI325X (AG+GEMM) |
| 显存 | 192 GB HBM3 (MI300X) / 256 GB HBM3e (MI325X) |
| GPU 互连 | Infinity Fabric (XGMI) |
| 每 GPU 聚合带宽 | 896 GB/s |
| XGMI link 数 | 7 (fully-connected mesh within 8 GPUs) |
| 每 link 带宽 | ~128 GB/s |
| NIC | 未明确(单节点实验不涉及) |
MI300X 内部采用 chiplet(XCD)架构。8 GPU 通过 XGMI 全连接,每 GPU 7 条 link、每条 ~128 GB/s,聚合 896 GB/s。这意味着 All-Gather 可以 7 路并行传输,每条 link 独立承载一个 peer 的 shard 数据。
论文未讨论 NUMA / PCIe topology 对 kernel 性能的影响。MI300X 的多 XCD 架构下,跨 XCD 的 L2 cache coherence 可能影响 spin-wait flag 的可见延迟,但论文未分析。
| 维度 | 本文内容 |
|---|---|
| 涉及的 collective | All-Gather(AG+GEMM、Flash Decode 中间步骤) |
| 未涉及的 collective | All-Reduce、Reduce-Scatter、All-to-All、Broadcast |
| Baseline 算法 | RCCL 2.22.3 的 opaque All-Gather(ring 或 tree,用户不可见) |
| 替代方案 | Iris 的 GPU-initiated RMA(非 collective 语义,point-to-point remote load/store) |
| Pull 路径 | iris.load() → XGMI remote read → 数据到寄存器 |
| Push 路径 | iris.store() → XGMI remote write → 数据到远程 inbox (HBM);iris.atomic_inc() → flag update |
| GPU-direct | 是 — XGMI 直接 GPU-to-GPU,不经由 CPU 或 PCIe |
| 层次化 | 无(单节点 flat topology) |
| 通信库 | Iris (Triton-native, AMD);对比 RCCL (vendor opaque) 和 Triton Distributed (rocSHMEM wrapper) |
| 源码 | github.com/ROCm/iris |
Iris 的通信模型严格来说不是 "collective"——它是 point-to-point RMA,由 kernel 代码显式编排来实现 All-Gather 语义。这提供了最大灵活性但将正确性负担转移到 kernel 开发者。
本文未深入讨论拥塞管理。
潜在问题:
不适用。所有数据假设已在 GPU HBM 中。KV cache 预加载,不涉及 checkpoint、文件系统或持久化存储。
本文不涉及 fault tolerance。
这是 fine-grained in-kernel communication 的通用问题——将 communication 逻辑从 opaque library 移入 user kernel 后,robustness 层的责任也转移到 kernel 开发者。
论文未讨论成本。 可推断:
| 维度 | 分析 |
|---|---|
| 开发成本 | Pull 模型改动极小(tl.load → iris.load);Push 模型需要额外 push kernel + flag 管理,开发量中等 |
| 运行时内存开销 | Push 模型需要 inbox buffer($W \times$ shard size per GPU)和 flag array($W \times$ tile count × 4 bytes)。对 AG+GEMM(M=4096, K=8192, W=8):inbox ≈ 56 MB/GPU,flag ≈ negligible |
| Compute cycle 浪费 | Spin-wait 占用 CU,但如果 data 快速到达(~μs 级),overhead 可忽略。大 world size 或 stragglers 下可能显著 |
| 移植成本 | Iris 目前 AMD-only;迁移到 NVIDIA 需等价的 Triton-native RMA 库(NVSHMEM + Triton Distributed,但编程模型更复杂) |
| 硬件趋势 | 对本文方法的影响 |
|---|---|
| MI350X (CDNA 4) — 更高 Infinity Fabric BW | 通信延迟进一步降低,三类税相对占比缩小,fused 方案的 speedup margin 可能收窄 |
| NVLink 6 (1.8 TB/s per GPU) | 同上;且 NVIDIA 生态有自己的 fusion 路径(CUTLASS overlap, Flux) |
| CXL / UCIe interconnect | 可能改变 memory visibility model,影响 flag ordering 语义 |
| 800G Ethernet / XDR InfiniBand | 跨节点 latency 仍比 XGMI 高一个数量级,Pull Model 在跨节点场景不可行 |
本文的 fused kernel 方案隐式要求或受益于以下硬件特性:
| 硬件特性 | 需求程度 | 说明 |
|---|---|---|
| GPU-initiated remote load/store | 必需 | Pull/Push 模型的核心——kernel 线程直接发起 RMA,不经由 host。XGMI 提供此能力;RoCE/IB 需 GPU-direct RDMA |
| Low-latency remote access(<1 μs) | 强需求 | Tile-level pipeline 要求 remote access 延迟与 HBM access 同量级(~百 ns),否则 stall 时间过长。XGMI 满足,跨节点网络不满足 |
| Store ordering guarantee | 必需 | Push Model 依赖 store-before-flag-increment 的可见性顺序。XGMI 提供 same-direction ordering。RoCE 需显式 fence |
| Atomic operations on remote memory | 必需 | RemoteAtomicInc(flag) 用于 per-tile 信号。XGMI 支持 remote atomic;IB/RoCE 的 atomic 支持有限且延迟更高 |
| Per-flow BW isolation | 有益 | 8 GPU 全连接下 7 条 link 独立,天然隔离。如果 topology 非全连接(如 ring),多流共享 link 需硬件级 QoS |
| Programmable congestion signal | 未使用但有益 | 当前 spin-wait 无 backoff;若硬件提供 remote-access congestion hint(类似 ECN),可实现 adaptive wait |
| In-network reduction (SHARP-like) | 不需要 | 本文的 approach 是 end-point fusion,通信在 endpoint GPU 上完成,不依赖交换机计算能力 |
核心洞察:本文的方法本质上将 NIC/fabric 的角色从 "collective executor"(RCCL/NCCL 通过 NIC 硬件或 fabric SHARP 执行 collective)降级为 "raw transport"(仅提供 RMA 原语),所有编排逻辑上移到 GPU kernel。这要求 fabric 提供极低延迟、高 BW 的 RMA,而 XGMI 恰好满足。迁移到跨节点 RoCE/IB 时,RMA 延迟跃升 2–3 个数量级(~百 ns → ~μs),tile-level pipeline 的 stall 将成为性能瓶颈,Pull Model 几乎不可行,Push Model 可能需要更大 tile granularity 来 amortize 通信延迟。