SLA2 修正 SLA 的 renormalization mismatch(用可学习 α 替代 projection)并引入 learnable router + QAT,在视频扩散模型上实现 97% attention sparsity / 18.6× attention speedup 且质量超越 full attention。
SLA (Sparse-Linear Attention) 将注意力分解为 sparse + linear 两支,但存在两个系统性缺陷:
| 组件 | Before (SLA) | After (SLA2) |
|---|---|---|
| Sparse-linear mixing | $O = O_s + \mathrm{Proj}(O_l)$ — projection 要同时补偿 scaling 和 linear | $O = \alpha \odot O_s + (1-\alpha) \odot O_l$ — convex combination, 无 projection |
| Routing | Heuristic: $\mathrm{softmax}(\bar{Q}\bar{K}^\top)$ → Top-k | Learnable: $\mathrm{proj}_q(\bar{Q}) \cdot \mathrm{proj}_k(\bar{K})^\top$ → Top-k |
| Acceleration | — | Sparse branch: QAT (INT8/FP8 forward, FP16 backward) |
| Training | 单阶段 fine-tune | 两阶段: Stage 1 init router+α on QKV data; Stage 2 end-to-end diffusion loss |
核心技术壁垒: $\alpha = P_1 \mathbf{1}$(行概率质量)的精确公式化使得 sparse 和 linear 分支可用 convex combination 直接重组——消除 projection 后线性 branch 只需补偿 $(1-\alpha)$ 比例的 output,学习难度大幅降低。
| 符号 | 含义 | 维度 |
|---|---|---|
| $Q, K, V$ | Query, Key, Value | $\mathbb{R}^{N \times d}$ |
| $S = QK^\top/\sqrt{d}$ | Attention scores | $\mathbb{R}^{N \times N}$ |
| $P = \mathrm{softmax}(S)$ | Full attention weights | $\mathbb{R}^{N \times N}$ |
| $M$ | Binary sparse mask | $\{0,1\}^{N \times N}$ |
| $P_1 = P \odot M$ | Mask-selected part | $\mathbb{R}^{N \times N}$ |
| $P_s = P_1 / \alpha$ | Sparse attention (renormalized) | $\mathbb{R}^{N \times N}$ |
| $\alpha = P_1 \mathbf{1}$ | Row-wise probability mass | $\mathbb{R}^{N \times 1}$ |
| $\phi(\cdot)$ | Linear attention activation (softmax) | — |
| $\mathrm{proj}_q, \mathrm{proj}_k$ | Router projections | $\mathbb{R}^{d \times d}$ |
| $b_q, b_k$ | Block sizes | 128, 64 |
Eq. 9: $P_1 V = \alpha \odot O_s$ — sparse softmax 的重新归一化使输出多了一个行级 scale $\alpha$。这是 SLA 中 projection 必须补偿的根本原因。
Eq. 11: $P \approx \alpha \odot P_s + (1-\alpha) \odot P_l$ — full attention 可精确表达为 sparse 和 linear 的 convex combination($\alpha + (1-\alpha) = 1$),行归一化自动保持。
Eq. 17 SoftTop-k: $\sigma((P_c)_{ij}/\tau + \lambda_i)$ — sigmoid 做 differentiable relaxation,$\lambda_i$ 通过 binary search 保证每行 sum = k%,使 gradient 可流过 router。
| Stage | Purpose | Data | Steps | Model |
|---|---|---|---|---|
| Stage 1 | Init router + α | Q,K,V tensors from all layers/timesteps | — | Wan2.1-1.3B/14B |
| Stage 2 | E2E diffusion fine-tune | 3000 private videos (~5s each), Qwen3-VL-Flash captions | 500 steps | Wan2.1-1.3B (bs=64) / 14B (bs=15) |
Wan2.1-1.3B-480P @ 97% sparsity:
| Method | IQ↑ | OC↑ | AQ↑ | VR↑ | FLOPs |
|---|---|---|---|---|---|
| Full Attention | 63.67 | 20.27 | 64.41 | 0.1084 | 52.75T |
| VMoBA @90% | 65.31 | 20.82 | 64.14 | 0.0936 | 5.28T |
| SLA @90% | 63.10 | 20.88 | 64.34 | 0.0872 | 5.40T |
| SLA2 @97% | 66.64 | 21.42 | 64.62 | 0.1039 | 1.82T |
Wan2.1-14B-720P @ 95% sparsity:
| Method | IQ↑ | VR↑ | FLOPs |
|---|---|---|---|
| Full Attention | 68.01 | 0.1238 | 292.6T |
| VMoBA @95% | 21.27 | -0.0965 | 14.63T |
| SLA @95% | 64.43 | 0.1078 | 14.87T |
| SLA2 @95% | 69.02 | 0.1125 | 15.11T |
| Variant | VR↑ | Δ vs SLA2 |
|---|---|---|
| w/o QAT | 0.0850 | -18% |
| Topk-router (heuristic) | 0.0876 | -16% |
| SLA2 (full) | 0.1039 | baseline |
| Step | 论据 | 证据 | 结论 |
|---|---|---|---|
| 1 | SLA 的 sparse branch 存在 renormalization mismatch | $P_s = P_1/\alpha$ (Eq. 7-8), projection 需同时补偿 scaling + linear | SLA formulation 非最优 |
| 2 | Convex combination $\alpha \odot O_s + (1-\alpha) \odot O_l$ 消除 mismatch | Eq. 9-12 推导; 无需 extra projection | 更 faithful 的分解 |
| 3 | Heuristic routing 不保证最优 sparse/low-rank split | Ablation: Topk-router VR=0.0876 vs learned router 0.1039 | Learnable projections 显著改善分配质量 |
| 4 | QAT 进一步加速 sparse branch | Ablation: w/o QAT VR drops to 0.0850; QAT 提供 ~1.3× kernel speedup | QAT 同时改善质量(通过 fine-tune)和速度 |
| 5 | 三组件协同: 97% sparsity 质量仍超 baselines @90% | Table 1 across both models | SLA2 是 sparse attention 在 video diffusion 的 Pareto-optimal |
代码: 论文使用 SLA 的 official open-source implementation 作为 baseline; SLA2 自身代码状态未明确声明。
关键实现细节:
Backward pass: 手动推导 gradient(Appendix A, Algorithm 3),linear branch 的 $dH_i, dZ_i$ 预计算后主循环仅需一次 matrix addition。
[实现未公开]