Files
2026-07-13 10:21:25 +00:00

16 KiB
Raw Permalink Blame History

Note

本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。

LongLive2.0 logo

🎬 LongLive 2.0:面向长视频生成的 NVFP4 并行基础设施

Paper Paper Paper Video Code Demo Docs

Watch the video

💡 TLDR:面向训练与推理的 NVFP4 并行基础设施

LongLive2.0 teaser

News

  • 🔥 [2026.07.08] LongLive 2.0 现已支持 FP8 推理。请参阅此处.
  • 🔥 [2026.06.01] 我们发布了 LongLive-RAG,,这是一个面向长视频生成的通用检索增强(Retrieval-Augmented Generation, RAG)框架。
  • 🔥 [2026.05.30] LongLive2.0 现已支持 Wan2.2-TI2V-5B 的 I2V AR 教师强制(teacher-forcing)训练与 I2V DMD 蒸馏。
  • [2026.05.25] 我们优化了 NVFP4 推理路径:融合 Triton RoPE/adaLN 内核、降低 KV-cache 同步开销、原地量化 KV-cache 更新、更快的 FP4 KV 反量化、固定(pinned)VAE 传输,以及更安全的量化前 LoRA 配置,整体吞吐量提升 18.6%
  • 🔥 [2026.05.13] 我们发布 LongLive 2.0,这是一款支持 NVFP4、并行化与多镜头(multi-shot)的 AR 训练、DMD 蒸馏及推理(45.7 FPS)的基础设施。原版 LongLive 1.0 现位于 v1.0 分支。
  • 🔥 [2026.04.12] LongLive 支持通过 TriAttention, 进行 kv cache 压缩,KV 减少 50% 且质量无损。请查看此处
  • 🎉 [2026.1.27] LongLive 已被 ICLR-2026 接收。
  • 🔥 [2026.1.11] LongLive 支持将 LongLive 原始 RoPE 适配为 KV-cache 相对 RoPE,并可生成无限长视频!
  • 🔥 [2025.11.3] 我们已在线性注意力模型 SANA-Video! 上实现 LongLive。现在 SANA-Video 可实时生成 60 秒交互式视频。
  • 🔥 [2025.9.29] 我们发布了 Paper,、本 GitHub 仓库 LongLive(包含全部训练与推理代码)、模型权重 LongLive-1.3B, 以及演示页面 Website.

Introduction

LongLive 1.0:实时交互式长视频生成。可在此处查看(位于我们的 V1.0 分支)。

LongLive 2.0:面向长视频生成的 NVFP4 并行基础设施

  • 训练方面,支持
    • T2V/I2V AR 训练(教师强制)的均衡序列并行(Balanced Sequence Parallel)。
    • 在多镜头(或单镜头)视频上进行 T2V/I2V AR 训练。
    • AR 训练与少步蒸馏均支持 NVFP4(或 BF16)。
  • 推理方面,支持
    • NVFP4 推理(W4A4)与 NVFP4 KV Cache。
    • 基于 BF16 checkpoint 的 TorchAO FP8 PTQ 推理(W8A8)。
    • 多镜头 attention sink。
    • 序列并行推理。
    • 异步解码。

LongLive2.0 framework overview

LongLive 1.0:实时交互式长视频生成。它接收顺序用户提示词,并实时生成对应视频,从而实现用户引导的长视频生成。其核心思路包括 attention sink、KV-recache 与流式长时微调(streaming long tuning)。

LongLive1.0 framework overview

Getting Started

默认 git clone 会拉取所有分支的对象,包括包含大型资源的 demopage 分支。日常使用通常只需 main 分支。请仅克隆 main:

git clone --single-branch --branch main --depth 1 https://github.com/NVlabs/LongLive.git

Quick Start

BF16

import torch
from omegaconf import OmegaConf

from pipeline import CausalDiffusionInferencePipeline
from utils.config import normalize_config
from utils.inference_utils import (
    load_generator_checkpoint,
    place_vae_for_streaming,
    prepare_single_prompt_inputs,
    save_video,
)

prompt = "A compact silver robot walks through a clean robotics lab."
merged_checkpoint_path = "LongLive-2.0-5B/model_bf16.pt"

config = normalize_config(OmegaConf.load("configs/inference.yaml"))
device = torch.device("cuda")

torch.set_grad_enabled(False)
pipe = CausalDiffusionInferencePipeline(config, device=device)
load_generator_checkpoint(pipe.generator, merged_checkpoint_path)
pipe = pipe.to(device=device, dtype=torch.bfloat16)
place_vae_for_streaming(pipe, config)  # honor streaming_vae + vae_device when set
pipe.generator.model.eval().requires_grad_(False)

noise, prompts = prepare_single_prompt_inputs(config, prompt, device)
video = pipe.inference(noise=noise, text_prompts=prompts)
save_video(video[0], "videos/quickstart/sample.mp4", fps=24)

除非 inference.streaming_vae 为 true 且已设置 inference.vae_device,否则 place_vae_for_streaming 为无操作(no-op);因此只需在 yaml 中切换 streaming-pipeline 解码即可,无需修改脚本。

FP8 PTQ

Efficient-Large-Model/LongLive-2.0-5B, 下载 model_bf16.ptconfigs/fp8/inference_fp8.yaml 中设置 checkpoints.generator_ckpt,然后运行:

python inference.py --config_path configs/fp8/inference_fp8.yaml

这将加载 BF16 生成器,应用 TorchAO 按行动态 FP8 W8A8 PTQ 然后启用现有的 torch.compile 路径。对于提供的 5B 模型, 300 个符合条件的核心 Linear 层使用 FP8;六个较小的条件/输出 投影层保持 BF16,以确保稳定性并避免 FP8 开销。

经验证的技术栈为 Python 3.10、PyTorch 2.8.0+cu128 与 TorchAO 0.13.0(运行于 H100SM90));需要计算能力 8.9 或更高。提供的配置 使用 torch_compile: auto。其 max-autotune 预热可能需要数分钟, 因为会编译 guard/shape 变体,因此测量稳态性能时请重复推理,并排除 所有编译/预热样本。设置 torch_compile: false 可进行简短的 eager 模式冒烟测试。

提供的配置使用在 H100 上验证过的单 8-latent-frame 块。 更长生成会引入额外的 KV-cache 形状,并可能触发更多 编译或 eager 回退;在基准测试或部署前,请先验证目标帧数。

NVFP4

configs/nvfp4/inference_nvfp4.yaml 中将 checkpoints.generator_ckpt 指向已下载的 checkpoint,并根据所用后端设置 model_quant_use_transformer_engine

  • TransformerEngine checkpointmodel_te.pt):model_quant_use_transformer_engine: true
  • FourOverSix checkpointmodel_4o6.pt):model_quant_use_transformer_engine: false

setup_nvfp4_pipeline 负责 checkpoint 加载、NVFP4 模块封装、权重物化、dtype/设备放置,以及两种后端的 streaming-pipeline VAE 迁移——此处 bf16 pipe.to(...) 快捷方式不安全,因为它会强制转换量化缓冲区。

import torch
from omegaconf import OmegaConf

from pipeline import CausalDiffusionInferencePipeline
from utils.config import normalize_config
from utils.inference_utils import prepare_single_prompt_inputs, save_video, setup_nvfp4_pipeline

prompt = "A compact silver robot walks through a clean robotics lab."

config = normalize_config(OmegaConf.load("configs/nvfp4/inference_nvfp4.yaml"))
device = torch.device("cuda")

torch.set_grad_enabled(False)
pipe = CausalDiffusionInferencePipeline(config, device=device)
setup_nvfp4_pipeline(pipe, config, device)
pipe.generator.model.eval().requires_grad_(False)

noise, prompts = prepare_single_prompt_inputs(config, prompt, device)
video = pipe.inference(noise=noise, text_prompts=prompts)
save_video(video[0], "videos/quickstart/sample_nvfp4.mp4", fps=24)

Training Modes

LongLive2.0 supports both T2V and I2V training. Each modality follows the same two-stage recipe: AR teacher-forcing training first, then DMD distillation from the AR checkpoint.

T2V Training

torchrun --standalone --nnodes=1 --nproc_per_node=8 train.py \
  --config_path configs/train_ar.yaml \
  --logdir logs/train_ar \
  --wandb-save-dir wandb \
  --disable-wandb

torchrun --standalone --nnodes=1 --nproc_per_node=8 train.py \
  --config_path configs/train_dmd.yaml \
  --logdir logs/train_dmd \
  --wandb-save-dir wandb \
  --disable-wandb

I2V 训练

torchrun --standalone --nnodes=1 --nproc_per_node=8 train.py \
  --config_path configs/train_i2v_ar.yaml \
  --logdir logs/train_i2v_ar \
  --wandb-save-dir wandb \
  --disable-wandb

torchrun --standalone --nnodes=1 --nproc_per_node=8 train.py \
  --config_path configs/train_i2v_dmd.yaml \
  --logdir logs/train_i2v_dmd \
  --wandb-save-dir wandb \
  --disable-wandb

对于 I2V 配置,请设置 algorithm.i2v: truealgorithm.independent_first_frame: truedata.image_or_video_shape[1] 是完整 latent 序列长度,例如 96,而非 96 + 1:在去噪过程中,干净的图像 latent 会替换第一个 latent,且该第一个 latent 会从训练损失中掩蔽掉。对于 I2V DMD,请将 checkpoints.generator_ckpt 设置为用于初始化 student 的 I2V AR 检查点。

模型

模型 FPS ↑ 参数量 VBench ↑ 多镜头
LongLive-1.3B 20.7 1.3B 84.87
LongLive-2.0-5B 24.8 5B 85.06
LongLive-2.0-5B-NVFP4-4Step 29.7 5B 84.51
LongLive-2.0-5B-NVFP4-2Step 45.7 5B 83.14

基于 LongLive 的优秀工作

  • DreamForge-World 0.1: 在 LongLive AR 视频技术栈基础上,通过残差动作通路实现低算力、实时可控的世界建模。
  • DreamX-World 1.0: 沿袭 LongLive,通过在长序列上进行长 rollout 与局部时间窗口适配,实现稳定的长时域 AR 世界生成。
  • SANA-Video: 将 SANA-Video 与 LongLive 结合,构建具备恒定内存 KV cache 的实时分钟级视频生成变体 LongSANA。
  • Daydream Scope: 将 LongLive 封装为流式 AR 视频扩散流水线,用于交互式文生视频与视频生视频工作流。
  • MemFlow: 基于 LongLive 代码库,加入自适应记忆检索,以生成更一致的长叙事视频。
  • ShotStream: 基于 LongLive 的蒸馏流程,实现实时流式多镜头 AR 视频生成。
  • Stream-T1: 基于 LongLive 代码库与算法,加入测试时扩展(test-time scaling)、噪声传播、奖励剪枝与记忆下沉(memory sinking)。
  • KVPO: 基于 LongLive 及相关 AR 视频代码库,通过历史 KV 语义探索实现 GRPO 风格对齐。
  • LoL: 基于 LongLive 研究并缓解 sink-collapse 问题,以支持超长 AR 流式视频生成。
  • TriAttention: 将三角 KV-cache 压缩集成进 LongLive 因果推理流水线,降低其局部注意力窗口内的 KV 内存占用。
  • StreamEdit: 基于 LongLive v1.0 代码库,提供 LongLive_StreamEdit 实现,用于免训练流式视频编辑。
  • Streaming Autoregressive Video Generation via Diagonal Distillation: 基于 LongLive 代码库,支持从 LongLive-1.3B 检查点直接初始化,用于流式 AR 视频蒸馏。
  • Forcing-KV: 为 LongLive 添加混合 KV-cache 压缩,包含 LongLive 推理与交互式生成脚本。
  • Dummy Forcing: 统一 Self-Forcing、LongLive 与 Causal-Forcing 流水线,并提供 LongLive 推理、VBench 与交互式生成配置。
  • MemRoPE: 以 LongLive 为支持的基础模型,实现免训练无限视频生成,并采用演化的记忆 token。
  • Astrolabe: 支持将 LongLive 作为蒸馏后的自回归视频骨干,并提供 LongLive 专用 RL 配置与 LoRA 初始化。

许可证

本仓库基于 Apache 2.0 许可证发布。详情请参阅 LICENSE

引用

若您觉得我们的工作有帮助,欢迎引用:

@article{longlive_2.0,
  title={LongLive2.0: An NVFP4 Parallel Infrastructure for Long Video Generation},
  author={Chen, Yukang and Wang, Luozhou and Huang, Wei and Yang, Shuai and Zhang, Bohan and Xiao, Yicheng and Chu, Ruihang and Mao, Weian and Hu, Qixin and Liu, Shaoteng and Zhao, Yuyang and Mao, Huizi and Chen, Ying-Cong and Xie, Enze and Qi, Xiaojuan and Han, Song},
  journal={arXiv preprint arXiv: 2605.18739},
  year={2026}
}
@inproceedings{longlive,
    title={Longlive: Real-time interactive long video generation}, 
    author={Yang, Shuai and Huang, Wei and Chu, Ruihang and Xiao, Yicheng and Zhao, Yuyang and Wang, Xianbang and Li, Muyang and Xie, Enze and Chen, Yingcong and Lu, Yao and others},
    booktitle={ICLR},
    year={2026},
}
@article{longlive_rag,
  title         = {LongLive-RAG: A General Retrieval-Augmented Framework for Long Video Generation},
  author        = {Hu, Qixin and Yang, Shuai and Huang, Wei and Han, Song and Chen, Yukang},
  journal       = {arXiv preprint arXiv:2606.02553},
  year          = {2026}
}

致谢

  • Self-Forcing: 我们在此基础上构建的 AR 训练代码库与方法论。
  • Wan2.2: 本版本所使用的基座视频扩散模型组件。