How LTX2Scheduler Controls Sigma Schedules in LTX-2
LTX2Scheduler generates adaptive noise-scale sequences by applying a token-count-dependent linear shift followed by a non-linear transformation and optional terminal stretching.
LTX2Scheduler is the default diffusion scheduler in LTX-2, Lightricks’ open-source video generation framework. It dynamically calculates sigma schedules—the noise-scale values that guide the diffusion process—by adapting to latent token counts and applying configurable mathematical transformations. The implementation resides in packages/ltx-core/src/ltx_core/components/schedulers.py and integrates directly into the inference pipelines.
The Three-Stage Sigma Schedule Algorithm
Token-Count-Dependent Linear Shift
The scheduler first calculates a dynamic sigma shift value based on the input latent dimensions. When a latent tensor is provided, the code computes the total token count as math.prod(latent.shape[2:]), falling back to MAX_SHIFT_ANCHOR (4096) when no latent is supplied. This token count drives a linear interpolation between base_shift (0.95) and max_shift (2.05) across the range defined by BASE_SHIFT_ANCHOR (1024) and MAX_SHIFT_ANCHOR (4096).
The linear mapping follows the formula σ_shift = m·tokens + b, where the slope m equals (max_shift - base_shift) / (MAX_SHIFT_ANCHOR - BASE_SHIFT_ANCHOR). This ensures smaller latent representations receive lower shift values, while larger contexts approach the maximum shift.
Non-Linear Sigma Conversion
After determining the shift, the scheduler creates a base linear schedule from 1.0 to 0.0 using torch.linspace(1.0, 0.0, steps + 1). It then applies a closed-form transformation to each non-zero element using the formula:
σ = e^{σ_shift} / (e^{σ_shift} + (1/s - 1)^{power})
With power defaulting to 1, this transformation converts the linear progression into a curve that decays gently during early denoising steps and sharply near the end. The implementation uses torch.where to preserve zero values while applying the exponential mapping to all other positions.
Optional Schedule Stretching
When stretch=True, the scheduler rescales the tail of the distribution so that the final non-zero sigma equals the terminal parameter (default 0.1). The code calculates scale_factor = (1.0 - last_sigma) / (1.0 - terminal), then linearly remaps all non-zero values by computing stretched = 1.0 - (one_minus_z / scale_factor). This ensures the schedule terminates at the exact noise level required by the target model.
Source Implementation Details
The LTX2Scheduler class is implemented in packages/ltx-core/src/ltx_core/components/schedulers.py. The core logic executes inside the execute() method, which accepts parameters including steps, latent, base_shift, max_shift, stretch, and terminal. The method returns a torch.FloatTensor of shape (steps + 1,) containing the sigma values cast to float32.
Key default parameters defined in the source:
base_shift: 0.95max_shift: 2.05terminal: 0.1default_number_of_tokens: 4096
Integration with LTX-2 Inference Pipelines
In production pipelines such as packages/ltx-pipelines/src/ltx_pipelines/ti2vid_one_stage.py, the scheduler is instantiated once during pipeline initialization:
self._scheduler = LTX2Scheduler()
During inference, the pipeline invokes the scheduler to generate the sigma sequence:
sigmas = (sigmas if sigmas is not None else
self._scheduler.execute(steps=num_inference_steps)).to(
dtype=torch.float32, device=self.device)
This pattern appears across multiple pipeline files including ti2vid_two_stages.py, keyframe_interpolation.py, and retake.py, ensuring consistent schedule generation throughout the LTX-2 ecosystem.
Practical Usage Examples
Basic execution with fixed steps:
from ltx_core.components.schedulers import LTX2Scheduler
import torch
scheduler = LTX2Scheduler()
sigmas = scheduler.execute(steps=50)
print(sigmas.shape) # torch.Size([51])
Token-aware execution with custom shift parameters:
latent = torch.randn(1, 4, 16, 16) # 256 tokens
sigmas = scheduler.execute(
steps=50,
latent=latent,
base_shift=0.9,
max_shift=2.2
)
Disabling terminal stretching:
sigmas = scheduler.execute(steps=30, stretch=False, terminal=0.05)
Summary
- LTX2Scheduler adapts sigma schedules based on latent token counts using linear interpolation between
base_shift(0.95) andmax_shift(2.05). - The scheduler applies a non-linear transformation formula to convert linear progressions into diffusion-optimized decay curves.
- Optional stretching rescales the schedule tail to match a specific
terminalvalue (default 0.1) for model compatibility. - The implementation in
packages/ltx-core/src/ltx_core/components/schedulers.pyprovides a configurableexecute()method used across all LTX-2 pipelines includingti2vid_one_stage.py.
Frequently Asked Questions
What is the default terminal value for LTX2Scheduler?
The default terminal parameter is 0.1, representing the final non-zero sigma value when stretching is enabled. This ensures compatibility with models expecting specific noise levels at the end of the diffusion process.
How does LTX2Scheduler determine the shift value without a latent tensor?
When no latent is provided, the scheduler defaults to MAX_SHIFT_ANCHOR (4096 tokens) as the token count, placing the shift value at the upper end of the interpolation range near max_shift (2.05).
Why does the sigma schedule use a non-linear transformation instead of linear interpolation?
The non-linear formula σ = e^{shift} / (e^{shift} + (1/s - 1)^{power}) creates a schedule that decays more slowly during early denoising steps and more aggressively at the end. This allocation improves generation quality by dedicating more steps to fine detail refinement.
Where is LTX2Scheduler instantiated in the LTX-2 codebase?
The scheduler is instantiated in pipeline files within packages/ltx-pipelines/src/ltx_pipelines/, such as ti2vid_one_stage.py, where it is stored as self._scheduler and invoked during the inference preparation phase to generate noise-scale schedules.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →