Note
本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
LongLive 1.0:实时交互式长视频生成。可在此处查看(位于我们的 V1.0 分支)。
LongLive 2.0:面向长视频生成的 NVFP4 并行基础设施
LongLive 1.0:实时交互式长视频生成。它接收顺序用户提示词,并实时生成对应视频,从而实现用户引导的长视频生成。其核心思路包括 attention sink、KV-recache 与流式长时微调(streaming long tuning)。
默认 git clone 会拉取所有分支的对象,包括包含大型资源的 demopage 分支。日常使用通常只需 main 分支。请仅克隆 main:
git clone --single-branch --branch main --depth 1 https://github.com/NVlabs/LongLive.git
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 解码即可,无需修改脚本。
从
Efficient-Large-Model/LongLive-2.0-5B,
下载 model_bf16.pt,
在 configs/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(运行于
H100(SM90));需要计算能力 8.9 或更高。提供的配置
使用 torch_compile: auto。其 max-autotune 预热可能需要数分钟,
因为会编译 guard/shape 变体,因此测量稳态性能时请重复推理,并排除
所有编译/预热样本。设置
torch_compile: false 可进行简短的 eager 模式冒烟测试。
提供的配置使用在 H100 上验证过的单 8-latent-frame 块。 更长生成会引入额外的 KV-cache 形状,并可能触发更多 编译或 eager 回退;在基准测试或部署前,请先验证目标帧数。
在 configs/nvfp4/inference_nvfp4.yaml 中将 checkpoints.generator_ckpt 指向已下载的 checkpoint,并根据所用后端设置 model_quant_use_transformer_engine:
model_te.pt):model_quant_use_transformer_engine: truemodel_4o6.pt):model_quant_use_transformer_engine: falsesetup_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)
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.
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
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: true 和 algorithm.independent_first_frame: true。data.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_StreamEdit 实现,用于免训练流式视频编辑。LongLive-1.3B 检查点直接初始化,用于流式 AR 视频蒸馏。本仓库基于 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}
}