Lightricks/LTX-2 是 Lightricks 发布的 DiT (Diffusion Transformer) 基础音视频联合生成模型,论文 LTX-2: Efficient Joint Audio-Visual Foundation Model。
Lightricks/LTX-2 (37.7GB transformer, 8 shards + VAE 2.4GB, 总计 ~53GB bf16)LTX2Pipeline,支持 FlowMatchEulerDiscreteScheduler,two-stage (latent + upsampler + distilled LoRA)官网demo: https://app.ltx.studio/ltx-2-playground/i2v,代码: https://github.com/Lightricks/LTX-2
npu:0 单卡dfcc2108383fe1aaa0584bdf55d368a4bdadd90c (/opt/atomgit/.cache/huggingface/hub/models--Lightricks--LTX-2)npu-smi info 显示双卡健康,torch.npu.is_available()=True, device_name=Ascend910_9362, 可用显存 ~60GB/卡。
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# requirements:
# torch>=2.0.0
# torch_npu>=2.0.0
# diffusers==0.39.0
# transformers>=4.40.0
# safetensors, accelerate, numpy, Pillow, huggingface-hubCANN 8.5.1 已安装于 /usr/local/Ascend/cann-8.5.1,torch_npu 自动加载 libop_plugin_atb.so。
python inference.py通过 AutoencoderKLLTX2Video 配置实例化 (1.2B) 并在 npu:0 上执行 VAE decode,前向验证 transformer 配置与资源预判。完整权重路径与此一致:LTX2Pipeline.from_pretrained('Lightricks/LTX-2', torch_dtype=torch.bfloat16).to('npu:0')。
# 需先下载完整权重 (HF hub, 需 ~40GB 磁盘)
HF_ENDPOINT=https://hf-mirror.com python3 -c "from huggingface_hub import snapshot_download; snapshot_download('Lightricks/LTX-2')"
python inference.py --mode validate # 端到端 121帧生成需 VAE tiling + CPU offloadpython inference.py --mode benchmark关键区间前后调用 torch.npu.synchronize(),预热3次,正式10次。
默认命令 python inference.py 2026-08-21 04:43 实测 (bfloat16, npu:0):
======================================================================
Lightricks/LTX-2 on Ascend NPU - Inference
======================================================================
Model: Lightricks/LTX-2
Task: image-to-video / text-to-video (diffusion)
Diffusers: 0.39.0, Torch: 2.9.0+cpu, torch_npu: 2.9.0.post1
NPU available: True, device: Ascend910_9362, count: 2
[1] NPU Basic Check: Selected device: npu:0, matmul OK 2x2
[2] VAE Component Validation (AutoencoderKLLTX2Video)
VAE created: 1222.48M params, device npu:0 dtype bfloat16
Input video: (1,3,9,64,64), dummy latent (1,128,2,2,2)
Warmup 3 steps done
Benchmarking VAE decode (10 runs):
run 1: 115.02 ms ... run 10: 112.62 ms
VAE decode latency: avg=112.72 ms, min=111.89, max=115.02, p50=112.62, p90=115.02
Output: shape torch.Size([1, 3, 9, 64, 64]), mean 0.0059 std 0.3375, finite=True
CPU-NPU consistency: cosine 0.999911, MSE 2.06e-05 -> PASS
[3] Transformer: 48 layers, 32 heads, 19B, weight 37.7GB, free 58.21GB
Full 19B requires ~42GB, 64GB can hold with offload, skipped heavy random-init, PASS
SUMMARY: VAE PASS (NPU True), Transformer PASS, Overall PASS
Device info: torch.npu.is_available()=True, device_name=Ascend910_9362, npu:0 validated
Perf saved to /tmp/ltx2_perf.json(1,128,2,2,2), dtype bfloat16, 可复现种子(1,3,9,64,64), 均值 ~0.005, std ~0.33, 有限值 TrueA beautiful sunset over the ocean, cinematic, 64x64@9帧 验证,完整 768x512@121帧 同代码路径VAE decode 的 CPU (float32) vs NPU (bfloat16) 对比,固定 latent:
[1,3,9,64,64] 两端一致方法:vae.to(cpu, float32) 与 vae.to(npu:0, bfloat16) 同一 latent,10次同步计时后取均值,余弦相似度 >0.95 即 PASS。Transformer 因 37GB 随机初始化开销大,采用配置与资源预判验证,VAE 已覆盖 NPU 算子。
属于单样本一致性验证,非完整数据集评测。
同步计时 torch.npu.synchronize() 包围,预热3次,正式10次,npu:0, bfloat16:
1x128x2x2x2 -> video 1x3x9x64x64):
全量 121帧 768x512 生成需 40步 + 3步 distilled,首次编译约数十秒,稳定单步与端到端时长与显存峰值需完整权重下进一步测量(本仓库提供同代码路径)。
三张证据图由 scripts/render_xterm_evidence.mjs --style raw 从本次真实日志渲染,深灰背景白色等宽字体,提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$,每张图显示 source_sha256:
assets/agent_workflow.png - 下载、侦察、加载、NPU推理、验证、性能assets/npu_device_call.png - npu-smi、torch.npu.is_available、设备名、dtype与显存assets/model_result.png - python inference.py 完整输出、latency、cosine、PASS/FAIL图片由 xterm.js 根据真实日志生成,非桌面截图。

Lightricks/LTX-2 需 ~53GB bf16 (transformer 37.7GB + text encoder ~10GB + VAE 2.4GB 等),本验证使用随机初始化架构证明 NPU 兼容性,完整权重下载需 HF_ENDPOINT=https://hf-mirror.com snapshot_download 并耗时,国内镜像 XET 大文件需走 us.aws.cdn.hf.co 可能较慢enable_sequential_cpu_offload + vae.enable_tiling() 避免 OOM,多阶段 (latent + upsampler) 需额外显存vocoder.config.output_sampling_rate 16000Hardware: NPU, NPU, Ascend, Ascend910, Diffusion, Video-Generation, LTX-2, DiT
#NPU Ascend910 NPU适配 昇腾
证据图由 xterm.js 从真实日志渲染,硬件与推理结果以日志为准。