Back to blog

FlowBlock: Wavefront-Parallel Decoding for Self-Correcting Diffusion Language Models

Training-free parallel decoding framework for block-wise diffusion LLMs using gated wavefront execution and heterogeneous wavefront packing

FlowBlock: Wavefront-Parallel Decoding for Self-Correcting Diffusion Language Models

一、论文概述

项目内容
标题FlowBlock: Wavefront-Parallel Decoding for Self-Correcting Diffusion Language Models
作者Bing Tian, Haikun Liu, Xiaocheng Zhong, Zhuohui Duan, Zhaokai Luo, Huayi Jin, Zhiyong Wang, Xiaofei Liao
机构(标记: † = 主要贡献者, § = 其他贡献者)
论文arXiv:2607.17652
代码github.com/Red-EAD/FlowBlock
发布20 Jul 2026 (v1), 575 KB
许可arXiv.org perpetual non-exclusive license
** Subjects**Artificial Intelligence (cs.AI)

二、核心思想

问题定义

块扩散语言模型(Block-wise dLLMs)按块级别顺序解码,虽然实现了跨块的 KV cache 复用,但导致块间解码严格串行化。下游块 Bg+1B_{g+1} 必须等待上游块 BgB_g 完全 finalize 后才能开始。前期工作试图通过后训练方法解锁块间并行性,但加速有限且经常降低准确率。

关键瓶颈在于:BgB_g 的后期去噪步骤通常只修正少量不确定位置,而此时所有下游块都处于空闲状态——这是未被利用的并行窗口。

解决方案概述

FlowBlock 是一个免训练的并行解码框架,基于一个关键洞察:自校正 dLLMs 中的 Token-to-Token (T2T) 编辑机制使得早期草稿是可变的而非不可撤销的。下游块在稍早的上游草稿上生成的 token 可以在后续去噪步骤中被 T2T 编辑修正。因此,块的”最终性”可以从硬性依赖转变为调度资源。

FlowBlock 包含两个核心机制:

  1. 门控波前解码(Gated Wavefront Decoding, GWD):仅当前沿块的就绪度超过阈值 θspawn\theta_{\text{spawn}} 时才将新块纳入有界波前窗口,通过联合 T2T 编辑同时细化多个活动块,并使用窗口块因果掩码(W-shaped block-causal mask)按序提交块,保留精确的冻结前缀 KV cache 复用。

  2. 异构波前打包(Heterogeneous Wavefront Packing, HWP):为每个请求分配独立波前状态,将异步窗口打包成密集的形状稳定 batched 前向传播,使用绝对位置 RoPE 和行级块对角掩码。

在 LLaDA-2.1 和 LLaDA-2.0 上的评估显示:FlowBlock 将 TPS 最高提升 2.95×–4.01×,延迟降低最高 53.6%–77.1%,平均准确率提升 1.3 分。相比后训练的 D2F 基线,FlowBlock 准确率更高且 batched serving 吞吐量最高高 16×。

三、技术架构

整体框架图

Gated Wavefront Decoding

Heterogeneous Wavefront Packing

数据流架构图解

┌─────────────────────────────────────────────────────────────────┐
│                    FlowBlock Execution Framework                 │
│                                                                  │
│  Gated Wavefront Decoding (GWD):                                │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  Committed Prefix (Frozen KV)                            │   │
│  │  [B0] [B1] [B2] ... [B(L-1)]                             │   │
│  │       ↕ Active Window [L, R) — up to W blocks            │   │
│  │  ┌─────┬─────┐                                             │   │
│  │  │ BL  │ BL+1 │ ... │ B(R-1) │ ← Mutable (T2T editable)  │   │
│  │  └─────┴─────┘                                             │   │
│  │       ↕                                                  │   │
│  │  Gate: ρ(BR-1) ≥ θspawn → admit BR                        │   │
│  │  W-shaped Mask: query in g attends to prefix + blocks L..g │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                  │
│  Heterogeneous Wavefront Packing (HWP):                          │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  Per-sequence independent wavefronts:                     │   │
│  │  Seq 0: [L0=0, R0=2)  offset o0=0                         │   │
│  │  Seq 1: [L1=2, R1=4)  offset o1=64                        │   │
│  │  Seq 2: [L2=1, R2=3)  offset o2=32                        │   │
│  │                                                            │   │
│  │  Per-row gather → dense [B, q] tensor (q = W·bl)          │   │
│  │  Per-row block-diagonal attention mask                     │   │
│  │  KV scatter-back: present[b, t+δ] → data[b, ob+δ]         │   │
│  └──────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘

核心公式

M2T/T2T 联合更新规则

Token update sets (Eq. 1):

Γt={i:xt[i]=[M]∧pi>τmask}(1)\Gamma_t = \{ i : x_t[i] = [\text{M}] \land p_i > \tau_{\text{mask}} \} \tag{1} Δt={i:xt[i]≠x^0,i∧pi>τedit∧i∉P}(2)\Delta_t = \{ i : x_t[i] \neq \hat{x}^{0,i} \land p_i > \tau_{\text{edit}} \land i \notin \mathcal{P} \} \tag{2}

其中 Γt\Gamma_t 是 mask-to-token (M2T) 草稿集合——尚未揭示的可信 masked 位置;Δt\Delta_t 是 token-to-token (T2T) 编辑集合——已揭示但被更置信预测替换的非 prompt 位置。下一状态设为 xt+1[i]=x^0,ix_{t+1}[i] = \hat{x}^{0,i} 对所有 i∈Γt∪Δti \in \Gamma_t \cup \Delta_t,其余位置保持不变。

前沿块就绪度度量

Readiness fraction (Eq. 2 in paper):

ρ(B)=∣{i∈MB:pi≥τmask}∣∣MB∣(3)\rho(B) = \frac{|\{ i \in \mathcal{M}_B : p_i \geq \tau_{\text{mask}} \}|}{|\mathcal{M}_B|} \tag{3}

其中 MB\mathcal{M}_B 是块 BB 中仍被 masked 的位置集合。ρ=1\rho = 1 当 MB=∅\mathcal{M}_B = \emptyset(块已完成)。

Gated admission condition (Eq. 3 in paper):

ρ(BR−1)≥θspawn∧(R−L<W)(4)\rho(B_{R-1}) \geq \theta_{\text{spawn}} \land (R - L < W) \tag{4}

W-shaped 块因果注意力掩码

KV-cache correctness: 窗口内块 gg 的查询可 attends 到 committed prefix [0,oL)[0, o_L) 和块 L,…,gL, \ldots, g,但从不访问未来块。在同一块内保持双向注意力。

异构波前打包

Per-row gather (Eq. 4 in paper):

qtok[b]=x[b,ob+[0..q)],pos[b]=ob+[0..q)(5)\text{qtok}[b] = x[b, o_b + [0..q)], \quad \text{pos}[b] = o_b + [0..q) \tag{5}

其中 q=W⋅blq = W \cdot bl 是窗口固定容量,ob=start(BLb)o_b = \text{start}(B_{L_b}) 是每行的绝对偏移。

Per-row block-diagonal mask (Eq. 5 in paper):

M[b,i,j]=1[j<ob]⏟own frozen prefix∨1[t≤j<t+(s+1)bl]⏟own window tail, block-causal(6)M[b, i, j] = \underbrace{\mathbb{1}[j < o_b]}_{\text{own frozen prefix}} \lor \underbrace{\mathbb{1}[t \leq j < t + (s+1)bl]}_{\text{own window tail, block-causal}} \tag{6}

其中 t=C−qt = C - q 是共享物理尾部起始位置,s=⌊i/bl⌋s = \lfloor i/bl \rfloor 是查询 ii 的窗口 slot。

KV write-back scatter (Eq. 6 in paper):

dataℓ[b,ob+δ]←presentℓ[b,t+δ],δ∈[0,q),∀ℓ(7)\text{data}^\ell[b, o_b + \delta] \leftarrow \text{present}^\ell[b, t + \delta], \quad \delta \in [0, q), \forall \ell \tag{7}

Algorithm 1: Gated Wavefront Decoding

Algorithm 1 Gated Wavefront Decoding (one sequence)
0: prompt c, blocks B_0, ..., B_{n-1}, width W, gate θ_spawn
1: prefill c; L ← 0; R ← 1   {B_0 admitted unconditionally}
2: while L < n and no EOS committed do
3:   Z ← f_θ(x[o_L, o_R−1+bl); pos; mask; KV)   {one W-shaped forward}
4:   for g = L to R−1 do
5:     apply M2T ∪ T2T update (Eq. 1) to B_g from Z_g
6:   end for
7:   while L < R and B_L locally finished do
8:     freeze KV of B_L into prefix; L ← L + 1   {retire in order}
9:   end while
10:  while R − L < W and R < n and ρ(B_{R−1}) ≥ θ_spawn do
11:    R ← R + 1   {gated admission, Eq. 4}
12:  end while
13: end while

模型组件

组件说明关键参数
Wavefront Window滑动窗口 [L,R)[L, R) 持有最多 WW 个相邻块并发去噪W=2W=2 (默认)
Readiness Gate控制新块何时加入波前θspawn≈0.6\theta_{\text{spawn}} \approx 0.6
W-shaped Mask保证 frozen-prefix KV 复用的精确性块因果 + 窗口内双向
Per-row Gather将异步窗口打包为 [B,q][B, q] 张量q=W⋅bl=64q = W \cdot bl = 64
Block-Diagonal Attention行级独立掩码,跨序列隔离Eq. (6)
KV Scatter-back前向后将窗口 KV 写回绝对位置Eq. (7)

训练流程

FlowBlock 不需要任何训练或后训练。它直接在未修改的自校正 dLLM checkpoint(LLaDA-2.1-mini)上运行,仅修改推理调度策略:

  • Inference-time only: 利用模型固有的 T2T 自校正能力
  • No kernel modifications: 不修改任何 CUDA/kernel 实现
  • Speed-accuracy knob: θspawn\theta_{\text{spawn}} 提供直接的速度-准确率权衡

四、核心创新

创新点说明理论/实验依据
发现 T2T 放松块间依赖首次观察到自校正 dLLMs 的 T2T 编辑使早期草稿可变,将块最终性从硬依赖转为调度资源Section 3.2: 下游块只需信息充分的草稿而非已确定的前驱
门控波前解码 (GWD)结合就绪度门控 admission、联合 T2T 细化、W-shaped 块因果掩码,在保留精确 frozen-prefix KV 复用的前提下重叠块Figure 1 + Algorithm 1: 窗口内 KV 可变,窗口外冻结
异构波前打包 (HWP)为每个请求维护独立波前状态,通过 per-row gather、绝对位置 KV 索引、块对角 packed attention 将异步窗口打包为密集 batched forwardFigure 2 + Section 5.4: HWP 在 B=16 时比同步变体高 2.15× TPS
免训练替代后训练相比 D2F 需要 distill 专用 checkpoint,FlowBlock 在推理时利用已有自校正能力,准确率更高且扩展性更好Section 5.2: FlowBlock 比 D2F 高 16.5 分准确率 + 2.37× TPS

五、代码实现分析

实现框架

FlowBlock 实现于 dInfer——一个基于 SGLang 的 dLLM 推理框架。关键配置:

  • 模型: LLaDA-2.1-mini (open-weight MoE block-diffusion LLM with T2T self-correction)
  • 默认参数: W=2W = 2, θspawn≈0.6\theta_{\text{spawn}} \approx 0.6, 保留模型默认的 (τmask,τedit)(\tau_{\text{mask}}, \tau_{\text{edit}}) 阈值
  • 硬件: 8× GPU (80 GB) 节点,数据并行
  • 最大生成长度: 2048 tokens,块长度 32

关键设计决策

  1. KV cache 预分配: 按最大序列长度预分配,每行在绝对位置存储 KV
  2. 无数据移动的检索: 每行读取相同的物理前缀 slice,attention mask 决定可见位置
  3. 免费 retire: 一旦块 commit,其 KV 已在正确位置,后续写入仅推进到新窗口偏移
  4. Per-row EOS: 每行独立的 EOS 检测立即停用对应序列

六、实验结果

实验设置

  • 模型: LLaDA-2.1-mini (MoE block-diffusion), LLaDA-2.0-mini
  • 基线: LLaDA-2.0 (no self-correction), LLaDA-2.1 (native serial), D2F (training-based inter-block parallel)
  • Benchmark: 4 math (GSM8K, MATH500, Minerva-Algebra, ASDiv) + 4 code (HumanEval, MBPP, HumanEval+, MBPP+)
  • 指标: Accuracy/pass@1 (%), TPF (tokens per forward), TPS (tokens per second), Latency (s)

主结果 (Batch Size = 1)

表1: 各方法在 8 个 benchmark 上的对比 (block length = 32)

ModelGSM8K Acc/TPSMATH500 Acc/TPSMinerva-A Acc/TPSASDiv Acc/TPSHumanEval Acc/TPSHumanEval+ Acc/TPSMBPP Acc/TPSMBPP+ Acc/TPSAvg TPS
LLaDA-2.092.49 / 82.673.40 / 104.691.24 / 120.992.36 / 81.984.76 / 159.679.27 / 162.579.16 / 105.184.39 / 108.7115.7
LLaDA-2.192.49 / 176.677.00 / 211.793.60 / 247.692.89 / 174.582.93 / 180.177.44 / 182.882.20 / 124.287.04 / 125.8177.9
D2F85.82 / 98.961.20 / 105.081.30 / 127.975.31 / 100.366.46 / 112.760.37 / 105.268.62 / 122.565.08 / 118.4111.4
FlowBlock92.65 / 254.276.20 / 332.193.51 / 378.992.80 / 239.786.59 / 279.482.32 / 282.483.61 / 162.188.36 / 161.3261.2

关键数字:

  • FlowBlock vs LLaDA-2.0: 2.35× 平均 TPS 提升 (最高 3.17×)
  • FlowBlock vs LLaDA-2.1: 1.45× 平均 TPS 提升 (最高 1.57×)
  • FlowBlock vs D2F: 2.37× 平均 TPS 提升,准确率 +16.5 分
  • FlowBlock 平均准确率 87.00,比 LLaDA-2.1 高 +1.3 分
  • FlowBlock TPF 达到 7.23,比 LLaDA-2.1 (4.62) 高 1.6×

Batched Serving 结果

在 Minerva-Algebra 上 B=16 时达到 1293 TPS (2.05× LLaDA-2.1 best),在 HumanEval 上 B=32 时达到 1471 TPS (2.95× improvement)。与 LLaDA-2.0 相比,峰值差距在 Minerva-Algebra B=8 时达到 4.01×,延迟降低最高 77.1%。

D2F 无法有效扩展: 在 HumanEval 上从 B=1 的 113 TPS 降至 B=32 的 89 TPS,而 FlowBlock 在同一 batch 下达到 16.6× 吞吐优势。

HWP 消融实验 (Section 5.4)

HWP vs 同步波前在 GSM8K 上的 TPS 优势:

Batch SizeHWP 优势
B=21.46×
B=41.82×
B=82.12×
B=162.15×
B=321.87× (延迟降低 38%)

超参数敏感性 (Section 5.5)

θspawn\theta_{\text{spawn}} 敏感性: 近无门控 admission 在 W=2W=2 时比 LLaDA-2.1 低 2.0 分,在 W=5W=5 时低 4.0 分。中等门控恢复至串行参考水平。

WW 敏感性: throughput 随 WW 单调递减(因为每个 forward 处理 B⋅W⋅blB \cdot W \cdot bl 查询位置)。

最优配置: W=2,θspawn=0.6W=2, \theta_{\text{spawn}}=0.6 → GSM8K 上 92.62% accuracy + 918 TPS (LLaDA-2.1 serving scale 的 1.54×)。

Block Length 鲁棒性 (Table 2)

在 GSM8K 上 blbl 从 64 增长到 128 时:

Methodblbl=64 Accblbl=96 Accblbl=128 Acc
LLaDA-2.192.57%89.99%77.41%
D2F53.98%31.54%22.82%
FlowBlock92.19%91.05%80.06%

FlowBlock 在 bl=128bl=128 时仍比 LLaDA-2.1 高 +2.65 分,TPF 保持 5.70 (1.72× lead)。

Generation Length 鲁棒性 (Table 3)

FlowBlock 在 GSM8K 上保持恒定 TPF = 6.73,不受生成长度影响:

LengthTPS (FlowBlock)Lat (s)Acc (%)
512253.31.1790.75
1024253.81.2592.27
2048249.61.3692.65

七、相关工作

Diffusion Language Models

  • Austin et al. 2021a (Structured denoising), Li et al. 2022 (Diffusion-lm), Sahoo et al. 2024 (MDA)
  • Recent models: LLaDA (Nie et al. 2025), Dream (Ye et al. 2025), Mercury (Labs et al. 2025), Seed Diffusion (Song et al. 2025)
  • 问题: vanilla dLLMs 做 bidirectional full-sequence denoising,所有位置每步刷新 KV cache,无法复用

Block-wise Diffusion LLMs

  • Han et al. 2023 (SSD-LM), Arriola et al. 2025 (Block diffusion)
  • LLaDA-2.0 (Bie et al. 2025): 扩展 block-wise 方案
  • LLaDA-2.1 (Bie et al. 2026): 引入 T2T editing
  • D2F (Wang et al. 2025): 通过后训练暴露块间并行性 —— FlowBlock 的对比基线,证明 training-free 方法可以超越 post-training

KV Cache for dLLMs

  • Wu et al. 2025 (Fast-DLLM): 启用 KV cache + parallel decoding
  • Ma et al. 2025a (DKV-cache): diffusion LLM 的 KV cache

八、总结

核心贡献

  1. 结构机会发现: 在自校正 dLLMs 中识别出 T2T 编辑放松块间依赖的机会,实现推理时的免训练调度
  2. 门控波前解码 (GWD): 结合就绪度门控 admission、联合 T2T 细化、W-shaped 块因果掩码,在保留精确 frozen-prefix KV 复用的前提下安全重叠块
  3. 异构波前打包 (HWP): 将异步 per-sequence 波前通过 per-row gather、绝对位置 KV 索引、块对角 attention 转化为密集 shape-stable batched forward
  4. dInfer 实现验证: 在 8 个 math/code benchmark 上一致提升吞吐和延迟,匹配或超越基线准确率,batched serving 可扩展

技术影响

FlowBlock 将 block-wise 解码从串行流水线转变为自定时数据流执行:块作为 pipeline stage,active window 形成从左到右推进的 wavefront,admission 和 retirement 由解码状态触发而非固定调度。这为自校正扩散语言模型提供了一个通用的执行框架。

局限性

  1. 仅限自校正 dLLMs: 当前设计依赖 T2T editing 能力,不适用于无自校正能力的 vanilla dLLMs(如 LLaDA-2.0 需配合 GWD 效果有限)
  2. Wavefront width 限制: 较大 WW 增加 compute cost 且 throughput 单调递减,实际推荐 W=2W=2
  3. Gate 调参: θspawn\theta_{\text{spawn}} 需按任务和 benchmark 选择(GSM8K 上 0.6 最优),缺乏自动选择机制
  4. 仅 MoE 模型验证: 目前仅在 LLaDA-2.1-mini (MoE) 上评估,非 MoE dLLM 的扩展性待验证

九、参考资源