How to Use the LTX-2 Model with ComfyUI: Complete Integration Guide
LTX-2 checkpoints are exported with the diffusion_model. prefix automatically applied during training, making them immediately compatible with ComfyUI's standard Checkpoint Loader without requiring conversion scripts or custom nodes.
The Lightricks LTX-2 repository includes a specialized training framework that handles weight key renaming during the export process. This built-in compatibility layer ensures that any checkpoint saved from the ltx-trainer package follows the exact naming convention expected by ComfyUI's native loaders.
How LTX-2 Ensures ComfyUI Compatibility
The LTX-2 training pipeline performs automatic key transformation during checkpoint serialization. This eliminates the manual conversion steps typically required when moving models between training frameworks and inference UIs.
Key Renaming During Checkpoint Export
When the trainer saves a checkpoint, it rewrites the state dictionary keys to match ComfyUI's expected format. In packages/ltx-trainer/src/ltx_trainer/trainer.py (lines 950-952), the LtxvTrainer class applies the following transformation:
# LtxTrainer: convert to Comfy-UI-compatible format (add "diffusion_model." prefix)
state_dict = {f"diffusion_model.{k}": v for k, v in state_dict.items()}
This operation prefixes every weight key with diffusion_model., which is the standard naming convention used by ComfyUI's UNet and diffusion model loaders.
Helper Mapping for Loading
On the consumption side, the LTX-2 core library provides a mapping definition that strips this prefix when loading within Comfy-compatible pipelines. Found in packages/ltx-core/src/ltx_core/loader/sd_ops.py (lines 135-138), the LTXV_LORA_COMFY_RENAMING_MAP handles the reverse operation:
LTXV_LORA_COMFY_RENAMING_MAP = (
SDOps("LTXV_LORA_COMFY_PREFIX_MAP").with_matching().with_replacement("diffusion_model.", "")
)
This dual-layer approach ensures that exported checkpoints work seamlessly with ComfyUI's native loading mechanisms while maintaining flexibility for other inference pipelines.
Exporting LTX-2 Checkpoints for ComfyUI
To generate a ComfyUI-compatible checkpoint from your LTX-2 training run, use the standard trainer API. The conversion happens automatically during the save operation:
from ltx_trainer.trainer import LtxvTrainer
from ltx_trainer.config import LtxTrainerConfig
# 1. Load a trainer configuration (e.g. from a YAML file)
cfg = LtxTrainerConfig.from_yaml("configs/my_ltxv.yaml")
# 2. Create the trainer and run training
trainer = LtxvTrainer(cfg)
# ... training loop ...
trainer.train()
# 3. Save a checkpoint (automatically applies ComfyUI-compatible naming)
checkpoint_path = trainer._save_checkpoint()
print(f"Comfy-UI-compatible checkpoint written to: {checkpoint_path}")
The resulting file will be saved as a .safetensors file in your checkpoints directory, with all weight keys already prefixed with diffusion_model. and ready for immediate use in ComfyUI.
Loading LTX-2 in ComfyUI
Since the exported checkpoint follows ComfyUI's native naming scheme, you can load it using the standard workflow:
-
Copy the
.safetensorsfile to your ComfyUI checkpoints folder (typicallyComfyUI/models/checkpoints). -
Launch ComfyUI and add a Checkpoint Loader node.
-
Select your LTX-2 checkpoint from the dropdown menu.
-
Connect the loader's outputs (MODEL, CLIP, VAE) to your standard generation pipeline (KSampler, VAE Decode, etc.).
No custom nodes or additional conversion steps are required. The checkpoint behaves identically to standard Stable Diffusion models within the ComfyUI node graph.
Programmatic Loading (Optional)
If you are developing a custom ComfyUI node or need to load the checkpoint programmatically, you can use the same helper that ComfyUI uses internally:
import torch
from comfy import sd
# Path to the exported LTX-2 checkpoint
ckpt_path = "/path/to/ComfyUI/models/checkpoints/model_weights_step_01000.safetensors"
# Load the checkpoint - expects the "diffusion_model." prefix already present
model = sd.load_checkpoint(ckpt_path)
# model now contains the UNet, VAE, and text-encoder weights ready for inference
Summary
- Automatic prefixing: The
LtxvTrainerclass inpackages/ltx-trainer/src/ltx_trainer/trainer.pyautomatically adds thediffusion_model.prefix to all weight keys during checkpoint export. - Native compatibility: Exported .safetensors files load directly into ComfyUI's standard Checkpoint Loader without conversion scripts.
- Bidirectional mapping: The
LTXV_LORA_COMFY_RENAMING_MAPinsd_ops.pyensures weights can be loaded back into LTX-2 pipelines while maintaining ComfyUI compatibility. - No custom nodes required: Standard ComfyUI installations can load and run LTX-2 models immediately after copying the checkpoint file.
Frequently Asked Questions
Do I need to install custom nodes to use LTX-2 with ComfyUI?
No. LTX-2 checkpoints are exported in ComfyUI's native format with the diffusion_model. prefix already applied. You can load them immediately using the standard Checkpoint Loader node that comes with ComfyUI. The ltx-trainer package handles all necessary key conversions during the export process.
What file format does LTX-2 export for ComfyUI?
LTX-2 exports checkpoints in the .safetensors format. This is the standard, safe tensor serialization format preferred by ComfyUI and the Stable Diffusion ecosystem. The file contains the complete state dictionary with keys prefixed according to ComfyUI's expectations.
Can I use LoRA checkpoints from LTX-2 in ComfyUI?
Yes. The same key renaming logic applies to both full model checkpoints and LoRA (Low-Rank Adaptation) checkpoints exported from the LTX-2 trainer. The LTXV_LORA_COMFY_RENAMING_MAP defined in packages/ltx-core/src/ltx_core/loader/sd_ops.py ensures that LoRA weights follow the same compatibility standards, allowing you to use LTX-2 trained LoRAs with ComfyUI's LoRA loading nodes.
Where does the key renaming happen in the LTX-2 codebase?
The key renaming occurs in two specific locations: first, during checkpoint export in packages/ltx-trainer/src/ltx_trainer/trainer.py (lines 950-952) where the diffusion_model. prefix is added; and second, in packages/ltx-core/src/ltx_core/loader/sd_ops.py (lines 135-138) where the mapping definition is created for loading the checkpoint back into LTX-2 compatible pipelines.
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 →