Lightricks开源的音视频生成模型,支持音画同步、高保真输出,配套Python推理包和LoRA训练工具。
LTX-2 是首个基于 DiT 的音视频基础模型,在一个模型中包含了现代视频生成的所有核心能力:音视频同步、高保真度、多种性能模式、生产级输出、API 访问以及开放访问。
git clone https://github.com/Lightricks/LTX-2.git
cd LTX-2
安装依赖。natten extra 是下方 diffusion video VAE 的最快后端,仅支持 Linux + CUDA——在 Windows 和 macOS 上会自动跳过,回退到 Triton 或 eager 实现,因此同样的命令在所有平台都能运行(参见 neighborhood attention backends)。
uv sync --extra natten
下载模型或使用 Hugging Face CLI:
hf auth login
hf download Lightricks/LTX-2.5 \
diffusion_models/ltx-2.5-22b-distilled-transformer-bf16.safetensors \
text_encoders/gemma4-12b-with-proj-ltx-2.5-bf16.safetensors \
vae/ltx-2.5-video-vae-bf16.safetensors \
vae/ltx-2.5-audio-vae-bf16.safetensors \
latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors \
--local-dir models/ltx-2.5
总计约 66 GiB。CLI 会在 --local-dir 下保持仓库的文件夹布局,因此下方路径包含 diffusion_models/、vae/ 等目录前缀。
如果遇到 401/403 错误,请在 Hugging Face 上接受模型条款并使用 Read token 登录(细粒度 token 需要启用 "read gated repos" 权限)。
uv run python -m ltx_pipelines.distilled \
--transformer-path models/ltx-2.5/diffusion_models/ltx-2.5-22b-distilled-transformer-bf16.safetensors \
--text-encoder-path models/ltx-2.5/text_encoders/gemma4-12b-with-proj-ltx-2.5-bf16.safetensors \
--video-vae-path models/ltx-2.5/vae/ltx-2.5-video-vae-bf16.safetensors \
--audio-vae-path models/ltx-2.5/vae/ltx-2.5-audio-vae-bf16.safetensors \
--spatial-upsampler-path models/ltx-2.5/latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors \
--num-frames 121 \
--seed 42 \
--output-path output.mp4 \
--prompt "A medium close-up shot features a Caucasian man with a beard, wearing a green and white baseball cap without any letters on the front, and a light blue shirt over a white t-shirt. He is positioned in the center of the frame, looking intently directly at the camera, his eyes focused on camera. His facial expression is one of deep concentration, with his brow slightly raised. As he looks straight at the camera, a quick sniff sound is heard, and then he speaks with a deep male voice and a satisfied tone, saying, 'I think it's so good.' The camera remains static throughout, maintaining a shallow depth of field, which keeps the man in sharp focus while the background is softly blurred, showing a beige wall behind him. After a brief pause, another short, audible sniff is heard. The man then continues to speak, his voice maintaining the same quality, as he states, 'So good. So good.' He elaborates further, emphasizing his point with a final statement, 'This got to be, it's got to be the best tool I've ever seen.'"
在 GPU 内存受限的情况下,可考虑使用 --quantization fp8-cast --offload {cpu, disk}。参见其他参数说明。
这里使用的是蒸馏模型和 pipeline,以获得快速结果。如需更高质量或其他能力,参见 Models and Pipelines。
LTX-2.5 是推荐的模型,也是快速上手使用的版本。其权重以每个组件一个文件的形式发布,因此只需下载 pipeline 需要的部分。
从 LTX-2.5 HuggingFace 仓库下载:
Transformer(选择并下载其中一个)
Text Encoder - Gemma 4 12B,针对 LTX 微调,文本投影包含在内;所有 pipeline 都需要。它随模型一起打包,无需单独下载 Gemma。Google 官方的 Gemma 4 不能替代:加载时会检查 encoder 版本与 checkpoint 训练时的版本是否匹配(gemma4-12b-ltx-v1)
Video VAE(选择并下载其中一个)
Audio VAE - 生成或解码音频的 pipeline 需要
Spatial Upscaler - 本仓库中两阶段 pipeline 实现需要
Temporal Upscaler - DFRPipeline 运行时间细化轮次时需要(--temporal-upsample-rounds)
Distilled LoRA - 两阶段 pipeline 实现中需要运行完整模型做 stage 1 的版本需要(DistilledPipeline、ICLoraPipeline 和 DubItPipeline 除外)
Detailing IC-LoRA - 可选;DFRPipeline 细化阶段的空间 detailing LoRA(--detailing-lora)。它存放在独立仓库 LTX-2.5-22b-IC-LoRA-Pixel-Spatial-Upscaler 中
Duration Head - 可选;允许省略 --num-frames,由模型根据 prompt 预测视频长度
本仓库中的每个 pipeline 也可以在 LTX-2.3 上运行。其 checkpoint 是打包了 transformer、VAE 和文本投影的单一文件,Gemma 3 text encoder 单独下载。两个模型的权重文件不通用,LoRA 只能用于其训练对应的模型。
完整的 LTX-2.3 模型列表参见 LTX-2.3 models。
DistilledPipeline - 最快推理,仅需 8 个预定义 sigma(推荐)
DFRPipeline - 细节保真渲染:生成关键帧 + 空间 detailing 通道,可选时间 2x/4x 细化
TI2VidTwoStagesPipeline - 生产级 text-to-video / image-to-video,支持 2x 上采样
TI2VidTwoStagesHQPipeline - 与上述相同的两阶段流程,但使用 res_2s 二阶采样器(步数更少,质量更好)
TI2VidOneStagePipeline - 单阶段生成,用于快速原型
ICLoraPipeline - video-to-video 和 image-to-video 变换(使用蒸馏模型)
KeyframeInterpolationPipeline - 关键帧图像之间的插值
A2VidPipelineTwoStage - 基于输入音频文件的 audio-to-video 生成
RetakePipeline - 重新生成现有视频的特定时间区域
HDRICLoraPipeline - 输出 HDR IC-LoRA 的 video-to-video(通过 LogC3 逆解码的线性浮点,适合 EXR 导出和 tone mapping)
DubItPipeline - Dub-It:在匹配说话人身份和唇动的条件下改写措辞(蒸馏模型,单 IC-LoRA,两阶段)
Native HDR / EXR — 标准 pipeline 接受 EXR 静帧和 EXR 帧文件夹,使用 --hdr {SRGB_LINEAR,ACESCG,ACESCCT} 并输出 half EXR 帧加上 BT.2020/HLG 主文件。参见 HDR Support。
使用 DistilledPipeline - 最快推理,仅需 8 个预定义 sigma(stage 1 八步,stage 2 四步)
启用 FP8 量化 - 减少显存占用:--quantization fp8-cast(CLI)或 quantization=QuantizationPolicy.fp8_cast()(Python)。fp8-cast 应与 bf16 checkpoint 配合使用,会即时向下转换。在具有原生 FP8 支持的 Hopper+ GPU 上,使用 --quantization fp8-scaled-mm 进行 FP8 缩放矩阵乘法。fp8-scaled-mm 应与 fp8 checkpoint 配合使用。
安装注意力优化 - 在数据中心 Blackwell GPU(B200)上手动安装 FlashAttention 4:uv pip install 'flash-attn-4==4.0.0b9'(此特定版本是我们验证过与 torch 2.9.1+cu128 配合的版本;更新版本的 beta 存在已知问题)。在 Hopper GPU 上安装 FlashAttention 3 wheel。在其他 CUDA GPU 上,PyTorch SDPA 会自动使用。已安装的后端在运行时自动选中;强制使用特定后端是 Python API 选项(AttentionFunction.FLASH_ATTENTION_3/FLASH_ATTENTION_4),不是 CLI 参数。
使用梯度估计 - 在保持质量的同时将推理步数从 40 减少到 20-30(参见 pipeline 文档)
跳过内存清理 - 如果显存充足,禁用阶段间自动内存清理以加快处理速度
选择单阶段 pipeline - 当不需要高分辨率时,使用 TI2VidOneStagePipeline 可以更快生成
编写 prompt 时,专注于详细、按时间顺序描述动作和场景。包括具体的动作、外观、摄像机角度和环境细节——全部放在一个流畅的段落中。直接以动作开头,保持描述具体且精准。像电影摄影师描述镜头清单那样思考。保持在 200 词以内。最佳结果的 prompt 结构:
更多 prompt 编写指导参见 https://ltx.io/blog/prompting-guide-for-ltx-2
Automatic Prompt Enhancement
LTX-2 pipeline 支持通过 enhance_prompt 参数自动增强 prompt。
要在 ComfyUI 中使用本模型,请按照 https://github.com/Lightricks/ComfyUI-LTXVideo/ 上的说明操作。
本仓库组织为包含三个主要包的 monorepo:
ltx-core - 核心模型实现、推理栈和工具函数
ltx-pipelines - text-to-video、image-to-video 等生成模式的高级 pipeline 实现
ltx-trainer - LoRA、全量微调和 IC-LoRA 的训练和微调工具
每个包都有自己的 README 和文档。参见下方的 Documentation 部分。
每个包都包含全面的文档:
LTX-Core README - 核心模型实现、推理栈和工具函数
LTX-Pipelines README - 高级 pipeline 实现和使用指南
LTX-Trainer README - 训练和微调文档,包含详细指南