Skip to navigation

PyTorch API

For developers who want direct Python integration or custom workflows beyond ComfyUI, LTX offers two paths: the native ltx-pipelines package (full control, all features) and the HuggingFace Diffusers integration (familiar API, quick start).

Repository Structure

The LTX-2 codebase is a monorepo with three packages:

PackagePurpose
ltx-coreModel architecture, schedulers, guiders, noisers, and patchifiers
ltx-pipelinesHigh-level inference pipelines for text-to-video, image-to-video, and IC-LoRA workflows
ltx-trainerLoRA, IC-LoRA, and full fine-tuning (see Trainer docs)

Requirements

  • Python >= 3.12
  • CUDA >= 12.7
  • PyTorch ~= 2.7

See System Requirements for full hardware specifications.

Installation

# Clone the repository
git clone https://github.com/Lightricks/LTX-2.git
cd LTX-2
# Set up the environment
uv sync
source .venv/bin/activate

Download Models

LTX-2.5 ships as a split pack — one .safetensors file per component (transformer, text encoder, video/audio VAEs, duration head). The distilled text-to-video pipeline needs the files below. Download them with the Hugging Face CLI (click Agree and Access on the model page on first download):

hf auth login
# LTX-2.5 distilled split pack
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 \
model_patches/ltx-2.5-duration-head-bf16.safetensors \
latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors \
--local-dir models/ltx-2.5

Use the bf16 files with ltx-pipelines. The *-comfy-int8_convrot variants are ComfyUI-only and are not loaded by the PyTorch path. For the full checkpoint list (dev transformer, conv VAE, distilled LoRA, upscalers), see the LTX-2.5 model card.


Option 1: Native Pipelines (ltx-pipelines)

The ltx-pipelines package provides the most complete feature set, including two-stage generation, IC-LoRA, and fine-grained guidance control.

Available Pipelines

PipelineUse case
TI2VidTwoStagesPipelineText/image-to-video with two-stage upscaling. Recommended for production.
TI2VidTwoStagesHQPipelineSame two-stage flow with the res_2s second-order sampler — fewer steps, highest quality.
TI2VidOneStagePipelineSingle-stage text/image-to-video for quick prototyping (no upscaling).
DistilledPipelineFast two-stage generation on the distilled checkpoint. Best for speed and batch runs.
ICLoraPipelineVideo-to-video with IC-LoRA adapters (control, restoration, creative transforms). Distilled model.
DubItPipelineDub-It — re-voice or rephrase speech with matched lips and preserved speaker identity. Distilled model.
HDRICLoraPipelineVideo-to-video with HDR output (linear-float EXR for color grading). Distilled model.
A2VidPipelineTwoStageAudio-to-video conditioned on an input audio track.
T2AOneStagePipelineText-to-audio — audio-only output (no video branch) from a text prompt.
RetakePipelineRegenerate a specific time region of an existing video without starting over.
KeyframeInterpolationPipelineInterpolate between keyframe images for smooth transitions.

All pipelines also run from the command line (python -m ltx_pipelines.<module> --help). For the full module list, shared CLI flags, and a per-pipeline reference, see Installation & Usage and Available Pipelines on GitHub.

Text-to-Video Example

This runs the distilled pipeline from the command line — the same interface as the Pipeline Quick Start. Each split component is passed with its own path flag:

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 \
--duration-head-path models/ltx-2.5/model_patches/ltx-2.5-duration-head-bf16.safetensors \
--spatial-upsampler-path models/ltx-2.5/latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors \
--prompt "A golden retriever running through a sunlit meadow, cinematic lighting. Sound of panting, rustling grass, distant birdsong." \
--seed 42 \
--output-path output.mp4

You can drive the same pipeline from Python, passing the split paths through ModelPaths:

from ltx_pipelines.distilled import DistilledPipeline
from ltx_pipelines.utils.model_paths import ModelPaths
model_paths = ModelPaths.from_split(
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",
duration_head_path="models/ltx-2.5/model_patches/ltx-2.5-duration-head-bf16.safetensors",
)
pipe = DistilledPipeline(
model_paths=model_paths,
spatial_upsampler_path="models/ltx-2.5/latent_upscale_models/ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors",
)
# See packages/ltx-pipelines for the __call__ arguments (prompt, seed, num_frames, images, …).

Add --help to any pipeline module to see its full option list, including the guidance parameters below.

Dimension constraints: Width and height must be divisible by 32. Frame count must follow the pattern 8n + 1 (valid values: 1, 9, 17, 25, …, 97, 105, 113, 121, etc.). Omit --num-frames to let the duration head pick a length from the prompt (LTX-2.5+), or set it explicitly, e.g. --num-frames 121.

Guidance Parameters

The native pipelines expose MultiModalGuiderParams for fine-grained control over generation:

ParameterRangeDescription
cfg_scale2.0–5.0Classifier-Free Guidance. Higher values increase prompt adherence. Set to 1.0 to disable.
stg_scale0.5–1.5Spatio-Temporal Guidance for temporal coherence. Set to 0.0 to disable.
stg_blockse.g. [28]Transformer blocks to perturb for STG. Set to [] to disable.
rescale_scale~0.7Rescales guided prediction to prevent over-saturation.
modality_scale1.0–3.0Audio-visual sync strength. Set > 1.0 when generating with audio.

Memory Optimization

For consumer GPUs, reduce VRAM by running the transformer in FP8 and offloading weights to CPU — add these flags to any pipeline command:

uv run python -m ltx_pipelines.distilled \
...model + prompt flags... \
--quantization fp8-cast \
--offload cpu
  • --quantization fp8-cast downcasts the bf16 transformer on the fly and works on any FP8-capable GPU. Use the bf16 checkpoints for this — the *-comfy-int8_convrot files are ComfyUI-only.
  • --quantization fp8-scaled-mm is the alternative for a native-FP8 checkpoint on Hopper+ GPUs.
  • --offload cpu streams weights from system RAM per layer; --offload disk reads them from disk on demand (lowest memory, slower).

Additional tip: set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to improve memory allocation.


Option 2: HuggingFace Diffusers

LTX-2.5 is published as a Diffusers-compatible pack in a separate repo, Lightricks/LTX-2.5-Diffusers — the same model in Diffusers-friendly packaging. Load it with from_pretrained against that repo id:

import torch
from diffusers import LTX2Pipeline
pipeline = LTX2Pipeline.from_pretrained(
"Lightricks/LTX-2.5-Diffusers",
torch_dtype=torch.bfloat16,
)
pipeline.to("cuda")
result = pipeline(
prompt="A golden retriever running through a sunlit meadow, "
"wildflowers swaying in a gentle breeze.",
width=768,
height=512,
)

The Diffusers integration provides a simpler interface but may not expose all features available in the native ltx-pipelines package (e.g., IC-LoRA, advanced guidance parameters). For full feature access, use the native pipelines.

For the exact pipeline class and current examples, see the Lightricks/LTX-2.5-Diffusers model card.


Generation Parameters Reference

Resolution

Standard aspect ratios:

ResolutionAspect RatioNotes
768×5123:2 landscapeGood default for wide shots
512×7682:3 portraitVertical/mobile content
704×5124:3 standardClassic frame
512×7043:4 vertical
640×6401:1 squareSocial media

Higher resolutions are supported (up to 4K) but require significantly more VRAM. Start with lower resolutions for testing.

Frame Count & Duration

FramesDuration (24fps)Duration (25fps)
65~2.7s~2.6s
97~4.0s~3.9s
121~5.0s~4.8s
161~6.7s~6.4s
257~10.7s~10.3s

Sampling

ParameterDistilled ModelFull Model
Steps4–820–50
CFG Scale1.02.0–5.0
Recommended3.0–3.53.0–3.5