How to Disable Guidance for Faster Inference in LTX-2
Set cfg_scale to 1.0 and stg_scale to 0.0 to disable classifier-free guidance and spatio-temporal guidance, cutting inference time roughly in half while maintaining base model output.
LTX-2 from Lightricks uses classifier-free guidance (CFG) and spatio-temporal guidance (STG) to enhance video generation quality, but these mechanisms require extra forward passes that significantly slow down inference. Disabling guidance removes the conditional and unconditional computations during sampling, allowing the model to run in its fastest configuration. This guide covers the exact configuration parameters, source file locations, and API calls needed to disable guidance using the LTX-2 source code.
Understanding Guidance Mechanisms in LTX-2
LTX-2 implements two distinct guidance techniques that trade compute for generation quality. Understanding how each works helps clarify why disabling them improves performance.
Classifier-Free Guidance (CFG)
CFG improves output quality by comparing the model's conditional output against its unconditional output. In packages/ltx-trainer/src/ltx_trainer/config.py, the guidance scale is defined as:
guidance_scale: float = Field(
default=4.0,
description="CFG guidance scale to use during validation",
ge=1.0,
)
The validation constraint ge=1.0 (greater than or equal to 1.0) indicates that a value of 1.0 represents the neutral state where no guidance is applied. At this value, the model performs only a single forward pass per sampling step instead of the dual passes required for CFG computation.
Spatio-Temporal Guidance (STG)
STG adds temporal coherence by applying perturbations to transformer blocks. The configuration in the same file shows:
stg_scale: float = Field(
default=1.0,
description="STG (Spatio-Temporal Guidance) scale. 0.0 disables STG.",
ge=0.0,
)
Setting this parameter to 0.0 completely disables the additional perturbation step, allowing transformer blocks to skip the extra compute associated with temporal guidance.
Where Guidance Parameters Are Defined
The guidance scales originate in packages/ltx-trainer/src/ltx_trainer/config.py, where Pydantic Field objects define validation rules and defaults. These values propagate through the pipeline infrastructure defined in packages/ltx-pipelines/src/ltx_pipelines/utils/args.py, which exposes them as CLI flags --video-cfg-guidance-scale and --video-stg-guidance-scale. The pipeline implementations in packages/ltx-pipelines/src/ltx_pipelines/ti2vid_one_stage.py consume these parameters during the denoising process.
Disabling Guidance from the Command Line
For inference scripts, pass the neutral values to disable both guidance mechanisms:
python -m ltx_pipelines.ti2vid_one_stage \
--prompt "A sunny beach with waves" \
--video-cfg-guidance-scale 1.0 \
--video-stg-guidance-scale 0.0
These flags are available across all video pipelines in the repository, including ti2vid_two_stages and ti2vid_two_stages_hq. For audio generation tasks, equivalent parameters exist as --audio-cfg-guidance-scale and --audio-stg-guidance-scale.
Disabling Guidance from Python
When using the Python API, instantiate the pipeline with the guidance scales set to their disabled values:
from ltx_pipelines.ti2vid_one_stage import TI2VidOneStagePipeline
pipeline = TI2VidOneStagePipeline(
model_path="ltx-2.3-22b-dev.safetensors",
cfg_scale=1.0, # Disables classifier-free guidance
stg_scale=0.0, # Disables spatio-temporal guidance
)
result = pipeline.generate(prompt="A sunny beach with waves")
The cfg_scale parameter maps directly to the CLI's --video-cfg-guidance-scale, while stg_scale maps to --video-stg-guidance-scale.
Performance Impact
Disabling guidance yields substantial speed improvements by eliminating redundant computation:
- No CFG (
cfg_scale=1.0): Removes the unconditional forward pass, halving the number of model evaluations per sampling step. - No STG (
stg_scale=0.0): Skips the perturbation calculations in transformer blocks.
Together, these changes roughly halve inference time, though exact speed-up depends on hardware configuration and other pipeline settings such as resolution and frame count.
Summary
- Guidance mechanisms: LTX-2 uses CFG (controlled by
guidance_scale) and STG (controlled bystg_scale) to improve output quality. - Disable CFG: Set
cfg_scaleto1.0inpackages/ltx-trainer/src/ltx_trainer/config.py, via--video-cfg-guidance-scale 1.0in CLI, orcfg_scale=1.0in Python. - Disable STG: Set
stg_scaleto0.0in configuration, via--video-stg-guidance-scale 0.0in CLI, orstg_scale=0.0in Python. - Speed gain: Disabling both guidance mechanisms approximately doubles inference speed by removing extra forward passes and perturbation steps.
Frequently Asked Questions
What is the difference between CFG and STG in LTX-2?
Classifier-Free Guidance (CFG) compares conditional and unconditional model outputs to steer generation toward the prompt, requiring two forward passes per step. Spatio-Temporal Guidance (STG) applies additional perturbations to transformer blocks to improve temporal coherence, adding compute overhead. CFG uses a scale ≥ 1.0 where 1.0 is neutral, while STG uses a scale ≥ 0.0 where 0.0 is neutral.
Will disabling guidance reduce video quality?
Disabling guidance reverts the model to its base output distribution without the quality-enhancing corrections that CFG and STG provide. While generation speed increases significantly, videos may exhibit less adherence to prompts and reduced temporal consistency compared to guided outputs.
Can I disable only one guidance mechanism?
Yes. You can disable CFG while keeping STG active by setting cfg_scale=1.0 and stg_scale to a positive value, or vice versa by setting stg_scale=0.0 while maintaining cfg_scale > 1.0. This allows fine-grained control over the speed-quality trade-off.
Are there audio-specific guidance parameters?
Yes. The LTX-2 pipeline supports --audio-cfg-guidance-scale and --audio-stg-guidance-scale flags for audio generation tasks, following the same conventions as their video counterparts. Set these to 1.0 and 0.0 respectively to disable guidance for audio inference.
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 →