← 返回 2026-05-07

LIVEditor-14B:通过上下文稀疏注意力实现闪电式统一视频编辑 Lightning Unified Video Editing via In-Context Sparse Attention

Shitong Shao, Zikai Zhou, Haopeng Li, Yingwei Song, Wenliang Zhong, Lichen Bai, Zeke Xie 📅 2026-05-06 👍 18 2026-07-13 08:36
ICL加速 In-Context Learning 扩散Transformer 稀疏注意力 视频编辑

提出首个面向ICL视频编辑的近无损稀疏注意力ISA,配合1.7M数据集与14B模型,在四个基准上超越SOTA并将注意力延迟降低约60%。

前置知识

In-Context Learning (ICL) 视频编辑

在扩散 Transformer 中,把源视频 token 和参考/上下文 token 直接拼接到同一序列里做全注意力,让模型从上下文直接学到编辑关系,省去显式的 ControlNet、跨注意力注入等额外模块。代价是序列长度翻倍、注意力从 $O(N^2 D)$ 涨到约 $O((L_{src}+L_{ctx})^2 D)$,成为推理瓶颈。

本文方法专门针对 ICL 这一范式做设计,ICL 是 2025 年视频编辑从专用模型走向统一框架的关键架构选择;不理解 ICL 就无法理解为什么 context token 和 source token 要被区别对待。

标准缩放点积注意力 (SDPA) 与 FlashAttention v2/v3

SDPA 是 $O(N^2)$ 的密集注意力,FlashAttention 通过分块和 online softmax 将复杂度降到 $O(N^2)$ 但常数项小很多,并显著降低 HBM 读写。本文中以 SDPA、FA2、FA3 作为延迟基准:在 head dim 64、序列长 23768 时 SDPA 耗时约 735ms,FA2 约 199ms,FA3 约 96ms,FA3 是 ISA 的对照线。

ISA 是相对这一族高效注意力做进一步稀疏的加速方案,必须先理解 FA 才能理解 ISA 的贡献定位。

块稀疏注意力与 Pooling Attention

把 Q/K/V 切成大小为 $b$ 的连续块,在块级别计算 mask $M \in \{0,1\}^{N_Q \times N_K}$,复杂度从 $O(N S D)$ 降到 $O(N_Q N_K b D)$。Pooling Attention 是其中一种 mask 推导方式:先对块做平均池化得到 $Q_c, K_c$,在低分辨率 $S_{coarse}=Q_c K_c^\top$ 上做注意力,再用 TopK 选出重要块。

ISA 的 pre-selection 阶段直接复用 Pooling Attention 的低分图,所以读者需要先理解分块和粗打分这两个前置工具。

0 阶 Taylor 近似注意力

用 $\exp(Q_i K_c^\top) V_c$ 替代 $\exp(Q_i K^\top) V$,即用块均值 $K_c, V_c$ 代替块内所有 token。本质上把 $L_Q L_K$ 次乘法降到 $L_Q$,把 $O(L_Q L_K D)$ 降到 $O(L_Q D)$。证明上对应把 softmax 内的 $Q K^\top$ 替换成常数 $Q K_c^\top$,误差与块内方差成正比。

这是 ISA 的核心计算 kernel,论文有完整的误差上界定理 3.1 把 Taylor 误差和 query sharpness 联系起来。

研究动机

视频编辑正从跨注意力机制(VACE、AVID 等)迁移到 In-Context Learning 范式(EditVerse、UniVideo、InstructX 等),把源视频和参考视频在 token 序列层面直接拼接做全注意力。在 ICL 设定下,context token 数量通常与 source token 相当,序列长度从 5K 翻倍到 10K-50K,注意力计算量随长度二次增长,导致 GPU 显存与延迟同步爆炸。论文 Fig. 2 的实测显示,序列长 23768、head dim 128 时 SDPA 需要约 735ms,FA2 仍需约 199ms。现有稀疏注意力方案(VSA、Sparge、STA、SWA、Radial Attention)都基于通用视频生成设计,把所有 token 等同看待,既没有利用 ICL 中 source 与 context 的结构差异,也未考虑 context token 在注意力打分上显著低于 source token 的特性(Fig. 5 实证:越深的层两者差距越大),因此难以在 ICL 场景中既快又好。

本文的目标是作者要构建一个 14B 参数级别的统一视频编辑模型 LIVEditor-14B,通过把稀疏注意力直接整合进模型架构,在 32 步 CFG 推理全流程中实现比 FlashAttention-3 高约 1.47× 的端到端加速,同时在 EditVerseBench、VIE-Bench、IVE-Bench、FiVE-Bench 四个基准上全面超越现有 SOTA(EditVerse、Lucy Edit、InsV2V、Ditto、Pika、VACE、Omni-Video 等),并保持视觉质量不降级甚至小幅提升。

与已有工作不同的是,论文从两个相互支撑的角度切入:第一,从理论层面证明 query 块内 softmax 分布的能量(即 block-wise sharpness $M_u$)和 0 阶 Taylor 近似的误差上界成正相关(Theorem 3.1),由此可以按 sharpness 把 query 切分成高/低两组分别走精确和近似路径;第二,从 ICL 数据特征出发,发现 source 注意力远强于 context 注意力,因此可以通过 TopK 预选在 context 维度上直接裁掉大量低显著性 token。两点结合形成了 ISA 这套『context 预选 + query 锐度分组』的稀疏方案,与已有通用稀疏方法在设计哲学上根本不同。

核心方法

ISA 的整体思路可以拆成三层流水线:先在低分辨率上做 Pooling 注意力,根据 source×context 的打分对 context 块做 TopK 预选(Select Ratio $\alpha_s=0.125$),把 KV 序列从 $L_{src}+L_{ctx}$ 砍到 $L_{src}+\alpha_s L_{ctx}$;然后在粗分数图上计算每个 query 块的 sharpness $M_i = \mathrm{Var}(\mathrm{softmax}(Q_c K_c^\top))$,按 $\alpha_f=0.5$ 把 query 切成 sharp 块和 flat 块;最后 sharp 块走标准 FlashAttention,flat 块走本文新提的 block-wise 0 阶 Taylor 稀疏注意力(No-Sparsity Ratio $\alpha_{ns}=0.0625$ 决定精确注意力密度),用 online softmax 累加器把两条路径的输出融合。这一整套机制用 Triton 实现前向+反向并端到端可训练,配合两阶段训练(1.7M→0.089M)和 decoupled RoPE,最终得到 LIVEditor-14B。

与已有稀疏方法的关键区别在于:通用稀疏方法(如 VSA 的 trainable mask、Radial 的能量衰减、STA 的滑动窗口)都把所有 token 一视同仁,主要利用『距离远的不重要』这一时间-空间局部性;ISA 利用的是 ICL 特有的 source-context 二分结构 + 概率分布锐度差异。具体而言,ISA 同时在 KV 维度(context TopK 预选,把上下文砍掉 87.5%)和 query 维度(按 sharpness 把 50% 的 query 改用 Taylor 近似)做稀疏,理论上有 Theorem 3.1 证明 sharpness 与误差上界成正比作为依据,训练上有 fine-tune 后近似误差从 0.5 降到 0.1 以下(Fig. 7)的实证支撑,最终实现 93.75% 的 Taylor 路径稀疏率而几乎不掉点。

方法步骤详情

完整推理步骤:(1) 块化与压缩:把 $Q, K, V$ 按 $b=64$ 分块并 padding,对每块做平均池化得 $Q_c, K_c, V_c \in \mathbb{R}^{B\times H\times T\times D}$,再算粗分数 $S_{coarse}=Q_c K_c^\top/\sqrt{D}$。(2) 预选 context KV:取出 $S_{coarse}$ 的 source×context 区域,沿 Q 维度求和得到每个 context 块的重要性分数,做 TopK 保留 $\alpha_s \cdot \lceil L_{ctx}/b\rceil$ 个,gather 出 $K_{ctx}^{sel}, V_{ctx}^{sel}$,与源 KV 拼接成 $K_{new}, V_{new}$,复杂度从 $O(NSD)$ 降到 $O(N(L_{src}+\alpha_s L_{ctx})D)$。(3) 计算 sharpness:对每个 query 块 $i$ 算 $M_i=\mathrm{Var}(S_{coarse}[:,:,:, :L_{src}/b])_i$,按降序排序,sharp 块(占比 $1-\alpha_f$)保留走 FA,flat 块(占比 $\alpha_f=0.5$)走 0 阶 Taylor 路径。(4) Sharp 块精确注意力:对 $Q_{sharp}$ 用 $K_{new}, V_{new}$ 跑标准 FA2/FA3,按 online softmax 公式更新 $\ell_i$ 和 $O_i$。(5) Flat 块 Taylor 注意力:对每个 query 块 $Q_i$,已选中的块($\alpha_{ns} \cdot$ 总块数)做 $\exp(Q_i K_j^\top/\sqrt{D})V_j$ 精确计算;其余块加载压缩后的 $K_c^j, V_c^j$,用 $\exp(Q_i (K_c^j)^\top/\sqrt{D}) \cdot V_c^j \cdot L_K$ 近似,并按 $m_i, \ell_i, O_i$ 累加,最后 $O_i = O_i/\ell_i$。(6) 残差融合:把 sharp 与 flat 两组输出 scatter 回原顺序,加上 $\gamma \cdot O_{coarse}$ 作为低频残差。训练阶段对 $\alpha_s, \alpha_{ns}, \alpha_f$ 三个超参做 ablation,验证稀疏率与性能的权衡。

技术新颖性

技术新颖性体现在四点:(a) 首次为 ICL 视频编辑量身设计的稀疏注意力框架,区别于通用稀疏方案只利用时空局部性;(b) 给出严格误差上界定理 3.1,把 0 阶 Taylor 误差与 block-wise sharpness 通过 Jacobian 谱范数和 Lipschitz 常数联系起来,且证明 $M_u$ 主导误差项,为分组计算提供理论保证;(c) 完整的 Triton 前向+反向实现使 ISA 完全可微,训练时 32 个 80GB GPU、DeepSpeed ZeRO-3 训练 1.7M 样本 0.089M 样本两阶段;(d) 把 0 阶 Taylor 与 TopK 预选融合,论文 Fig. 7 显示 fine-tune 后与全注意力的逐块误差从最高 0.5 降到 0.1 以下,这是稀疏后还能反超 dense 的关键。补充创新包括 decoupled RoPE(source/context 各自从 0 开始编码位置)和 4 阶段自动化数据合成 pipeline(Gemini 2.5 Flash + Gemini 2.5 Image Preview + 自研 14B T2I2V + YOLO/DINO/SAM 一致性过滤)。

Visualization of LIVEditor-14B (ISA). The superior video editing performance of LIVEditor-14B (ISA) stems from a unified framework that leverages in-context sparse attention.
Figure 1: Visualization of LIVEditor-14B (ISA). The superior video editing performance of LIVEditor-14B (ISA) stems from a unified framework that leverages in-context sparse attention.
The speedup of ISA relative to SDPA and FA2 becomes increasingly pronounced as sequence length grows.
Figure 2: The speedup of ISA relative to SDPA and FA2 becomes increasingly pronounced as sequence length grows.
The workflow of In-Context Sparse Attention (ISA).
Figure 3: The workflow of In-Context Sparse Attention (ISA).
This visualization results demonstrate that the Taylor error Ei is directly proportional to the coarse-grained variance Mi (sharpness).
Figure 6: This visualization results demonstrate that the Taylor error Ei is directly proportional to the coarse-grained variance Mi (sharpness).
The automated synthesis pipeline for video-to-video editing.
Figure 11: The automated synthesis pipeline for video-to-video editing.
Distribution of Editing Tasks in the Constructed Dataset.
Figure 12: Distribution of Editing Tasks in the Constructed Dataset.
The data scheduling strategy for LIVEditor proceeds in two stages.
Figure 15: The data scheduling strategy for LIVEditor proceeds in two stages.

实验结果

主实验覆盖 4 个基准。EditVerseBench(Table 1)LIVEditor(ISA) 在 VLM 评测四项均第一:Quality 7.89(vs EditVerse 7.65 +0.24)、Text Align 20.09(vs 20.07 +0.02)、Temporal Consistency 27.19(vs 27.14 +0.05)、Editing Quality 24.55(vs Señorita-2M 24.32 +0.23);Pick Score Frame 99.32 / Video 99.22,比此前最高的 98.56/98.44 分别提升 0.76/0.78。同时在所有指标上反超 LIVEditor(full-attn),唯一例外 Video Pick Score 略低 0.04。Table 2 训练-free 场景下与 Radial/Sparse/STA/SWA/VSA 对比,ISA 在 7 项指标上全部领先 sparse 基线并超过 full-attn,1.47× 加速比。VIE-Bench(Table 14)五类任务 Add/Remove/Swap/Style/Hybrid 平均分 8.84/6.81/8.14/8.16/8.12,全面超越 Omni-Video(6.24/5.59/4.75/5.37/5.43)、InsV2V、VACE、Pika,Add 任务对 Omni-Video 提升 2.6 分。IVE-Bench(Table 13)总分 0.67 与 Ditto/InsV2V 并列第一,但在 Video Quality 四子项拿到最高 0.97/0.98/0.99/1.00,Instruction Compliance 从 full-attn 的 0.43 升到 0.47。FiVE-Bench(Table 5-12)四个细粒度任务(Rigid Replace / Non-Rigid Replace / Color Alter / Material / Add)上 ISA 在 Structure Dist.、PSNR、LPIPS、SSIM、CLIP-S、FiVE-Acc 上几乎全面超越 full-attn,最显著的是 Object Addition 任务 Motion Fidelity 从 57.05 跳到 76.39。Table 3-4 显示第二阶段 fine-tune 后 VLM Quality 从 6.46 升到 7.89,VIE-Bench Avg 从 5.16 升到 6.81,验证了 0.089M 高质量子集的关键作用。Fig. 8 显示稀疏率与加速比呈单调关系,$\alpha_{ns}$ 降到 0 时 128K 序列可达 5× 加速。Fig. 9 三组超参扫描揭示模型对 $\alpha_f$ 高敏感、$\alpha_s/\alpha_{ns}$ 低敏感,因此默认 $\alpha_f=0.5, \alpha_{ns}=0.0625, \alpha_s=0.125$。

EditVerseBench Evaluation Results. Our proposed LIVEditor (ISA) outperforms related methods across nearly all metrics and surpasses LIVEditor (full-attn).
Table 1: EditVerseBench Evaluation Results. Our proposed LIVEditor (ISA) outperforms related methods across nearly all metrics and surpasses LIVEditor (full-attn).
EditVerseBench Evaluation Results. In the training-free scenarios, we compare our proposed ISA against several attention mechanism variants.
Table 2: EditVerseBench Evaluation Results. In the training-free scenarios, we compare our proposed ISA against several attention mechanism variants.
EditVerseBench Evaluation Results. The model performance is further enhanced following fine-tuning with the high-quality dataset in Stage II.
Table 3: EditVerseBench Evaluation Results. The model performance is further enhanced following fine-tuning with the high-quality dataset in Stage II.
VIE-Bench Evaluation Results. The model performance is further enhanced following fine-tuning with the high-quality dataset in Stage II.
Table 4: VIE-Bench Evaluation Results. The model performance is further enhanced following fine-tuning with the high-quality dataset in Stage II.
FiVE-Bench Results (Object Replacement (Rigid)). LIVEditor (ISA) outperforms LIVEditor (full-attn) on almost all metrics.
Table 5: FiVE-Bench Results (Object Replacement (Rigid)). LIVEditor (ISA) outperforms LIVEditor (full-attn) on almost all metrics.
IVE-Bench Evaluation Results. Our proposed LIVEditor (ISA) achieved superior performance across 7 metrics.
Table 13: IVE-Bench Evaluation Results. Our proposed LIVEditor (ISA) achieved superior performance across 7 metrics.
VIE-Bench Evaluation Results. Our proposed LIVEditor (ISA) achieves state-of-the-art performance across all tasks, including Add, Remove, Swap, Style, and Hybrid.
Table 14: VIE-Bench Evaluation Results. Our proposed LIVEditor (ISA) achieves state-of-the-art performance across all tasks, including Add, Remove, Swap, Style, and Hybrid.
FiVE-Bench Results (Object Replacement (Non-Rigid)). LIVEditor (ISA) outperforms LIVEditor (full-attn) on almost all metrics.
Table 7: FiVE-Bench Results (Object Replacement (Non-Rigid)). LIVEditor (ISA) outperforms LIVEditor (full-attn) on almost all metrics.
FiVE-Bench Results (Object Addition).
Table 12: FiVE-Bench Results (Object Addition).
ISA is a trainable sparse attention mechanism. After post-training, the discrepancy between the output of ISA and that of full attention is significantly reduced across nearly all blocks.
Figure 7: ISA is a trainable sparse attention mechanism. After post-training, the discrepancy between the output of ISA and that of full attention is significantly reduced across nearly all blocks.
Reducing the Flat Ratio αf and No Sparsity Ratio αns leads to an exponential increase in the speedup of ISA relative to SDPA. Moreover, this speedup becomes increasingly pronounced as sequence length grows.
Figure 8: Reducing the Flat Ratio αf and No Sparsity Ratio αns leads to an exponential increase in the speedup of ISA relative to SDPA. Moreover, this speedup becomes increasingly pronounced as sequence length grows.
EditVerseBench Evaluation Results. The sparsity of ISA is governed by three hyperparameters: Flat Ratio, No Sparsity Ratio, and Select Ratio.
Figure 9: EditVerseBench Evaluation Results. The sparsity of ISA is governed by three hyperparameters: Flat Ratio, No Sparsity Ratio, and Select Ratio.
ISA Performance Visualization. Our proposed ISA not only surpasses VSA, SWA, Sparge Attn, and Radial Attn in inference speed but also outperforms all other sparse attention mechanisms in terms of model performance.
Figure 10: ISA Performance Visualization. Our proposed ISA not only surpasses VSA, SWA, Sparge Attn, and Radial Attn in inference speed but also outperforms all other sparse attention mechanisms in terms of model performance.
查看结构化数据
任务指标本文基线提升
EditVerseBench VLM Quality VLM Quality Score (越高越好) 7.89 EditVerse 7.65;LIVEditor(full-attn) 7.62 +0.24 vs EditVerse SOTA;+0.27 vs full-attn
EditVerseBench Editing Quality VLM Editing Quality (越高越好) 24.55 Señorita-2M 24.32;LIVEditor(full-attn) 23.80 +0.23 vs SOTA;+0.75 vs full-attn
EditVerseBench Pick Score Pick Score Frame / Video 99.32 / 99.22 Lucy Edit 98.56 / 98.44 +0.76 / +0.78
VIE-Bench Object Addition VLM Average Score 8.84 Omni-Video 6.24 +2.60
VIE-Bench Video Stylization VLM Average Score 8.16 Omni-Video 5.37;InsV2V 7.45 +2.79 vs Omni;+0.71 vs InsV2V
IVE-Bench Total Total Score 0.67 Ditto 0.67;InsV2V 0.67;LucyEdit 0.64;LIVEditor(full-attn) 0.66 并列第一且 Instruction 0.43→0.47
FiVE-Bench Object Addition Motion Fidelity (越高越好) 76.39 LIVEditor(full-attn) 57.05 +19.34
FiVE-Bench Object Replacement (Rigid) FiVE-Acc (越高越好) 50.71 LIVEditor(full-attn) 43.80 +6.91
推理加速(end-to-end 32 步 CFG) Speedup vs FA3 1.47× Radial 1.28×;Sparge 1.40×;STA 2.09×;SWA 1.37×;VSA 1.38× STA 虽 2.09× 但 VLM Quality 仅 4.45(崩溃);ISA 1.47× 同时 Quality 7.78(最高)

局限与改进

作者承认的局限:(1) ISA 对 $\alpha_f$ 高度敏感(图 9),Flat Ratio 必须保持 0.5 不能降,否则性能显著下降,意味着至少 50% 的 query 必须走精确注意力,稀疏率上限被锁死;(2) Stage I 训练后 object removal 任务存在明显缺陷(VIE-Bench Remove Avg 仅 5.16),需要 Stage II 用 Minimax Remover 生成的 0.06M 数据专门修补,揭示稀疏机制对长程去除这类任务的学习更困难;(3) 仅在 Wan 2.2 高噪声分支上做了 post-training,未验证 ISA 在原生训练流程中的可学习性,扩展到 100K+ 极长序列时仍未充分测试;(4) 与最新 MLLM-based 方法(EditVerse、UniVideo、InstructX)因无可用实现而未对比,无法判断 ISA 在 MLLM 编辑范式下的相对位置。我自己的观察还包括:(a) 1 阶/2 阶 Taylor 因硬件不友好被放弃,但代价是丢掉高阶修正项,在 sharpness 边界附近的 query 可能引入系统性偏差;(b) Decoupled RoPE 解决了位置编码冲突,但完全 reset 索引等于丢掉相对位置信息,可能在依赖相对位移的任务(如 motion edit)上影响精度;(c) Triton 实现在 64K 以上序列长时 TileLang 已超过它(Fig. 17),目前采用 Triton 是因为训练需要反向,但生产部署时 TileLang 可能更适合。

独立分析的弱点

独立分析的弱点:(1) TopK 预选只在 KV 维度做了一次性筛选,没有迭代式 refine,当 context 内部存在层级相关(如参考视频含多帧)时可能选错块;改进方向是引入 dynamic KV eviction 配合 query 端信号在推理时迭代。(2) Decoupled RoPE 把 source 和 context 都 reset 到 0,对依赖时序的运动/视角类编辑(数据中 Other 类仅 1.09%)可能不够友好,可改为 source 保留绝对位置、context 端引入独立相对位置编码。(3) $\alpha_f=0.5$ 的硬性下限意味着 Taylor 路径最多处理一半 query,理论稀疏率天花板约 50%;可探索用 learning-to-route 替代固定阈值,让模型自己学哪些 query 适合近似。(4) 数据合成 pipeline 高度依赖 Gemini 2.5 Flash/Image Preview 闭源 API,prompt 调整与版权可解释性都受限,且 human edit 类别仅 12.80%,对人类中心编辑的细粒度控制仍弱;改进方向是开源 caption 模型+ControlNet-Style 的本地化合成,并扩大人像/手势类数据。(5) 仅在视频编辑单任务验证 ISA,对通用 ICL 视频生成/理解的迁移性未给出证据。

未来方向

作者提出 + 我基于结果的延伸:(1) 把 ISA 推广到 100K-1M token 的极长视频生成与多镜头理解任务,验证 Theorem 3.1 在长程注意力上的可推广性;(2) 探索与 diffusion 蒸馏(作者团队积累的 MagicDistillation、Catch-up Distillation 等)结合的稀疏-蒸馏联合加速,目标 4-step 内编辑;(3) 把 ISA 作为通用 ICL 加速 backbone 应用到图像编辑、3D 编辑、文档编辑等多模态统一模型;(4) 引入 RLHF/VLM-as-judge 微调(Table 13 显示 Object Removal 上 LIVEditor 仍不如 Minimax Remover 等专用模型),用偏好学习补齐 Stage II 未覆盖的细粒度能力;(5) TileLang 在 64K+ 序列已超过 Triton,预期把 forward kernel 切到 TileLang、backward 仍用 Triton,可在生产环境拿到更高加速比;(6) 把 sharpness 指标 $M_i$ 引入 diffusion 采样步的 early-exit,跳过 $\alpha_{ns}$ 之外的 query 在所有 step 的更新,进一步节省 30%-50% 算力。

复现评估

复现评估:作者声称开源 LIVEditor-14B 仓库,模型基于 Wan 2.2 高噪声分支 post-training,训练分两阶段——Stage I 1.7M 样本、lr=1e-5、global batch 16,Stage II 0.089M 样本、lr=5e-6、EMA=0.995,使用 AdamW($\beta_1=0.9, \beta_2=0.999$, weight decay=1e-2),32 张 80GB GPU 跨 4 节点 + 序列并行 size 2 + DeepSpeed ZeRO-3 Offload。数据 pipeline 完全依赖 Gemini 2.5 Flash/Image Preview 闭源 API 和自研 14B T2I2V 扩散模型,外部复现需要先复刻其 14B 内部 T2V 模型,否则只能复用其 1.7M 公开数据子集(Ditto 0.7M + 自合 1M 中的开源部分)。ISA 算法本身在 Triton 上完整开源,包含 Algorithm 1/2 伪代码和 Triton vs TileLang 性能对比(Fig. 17),因此稀疏机制本身易复现;但端到端 14B 模型复现算力门槛约 $32 \times 80GB \times 2 \text{ stages} \times \text{数天}$,对大多数研究组偏高。整体难度评估:算法级中、数据级难、模型级高。