Repository navigation
Studio diffusion training: LTX-2.5 LoRA training (captions through the Gemma 4 worker, dev DiT, baked into the distilled Video page model) - #18386
Conversation
Train LTX-2.5 (Lightricks/LTX-2.5-Diffusers) style LoRAs from still images on the DiT trainer. Captions go through the Video page's Gemma 4 encoder worker (the encoder needs the transformers 5.10 sidecar), once, before the DiT loads; the worker exits with its memory. The LoRA trains against the pack's dev DiT (transformer_full/, the model card's trainable model) on LTX-2's sigma schedule and bakes into the distilled DiT on the Video page. UNSLOTH_LTX25_TRAIN_DIT=distilled trains the distilled DiT instead.
…n the fetch is the mirror The ungated unsloth/LTX-2.5-FP8 mirror ships only the distilled DiT; the dev DiT then comes from Lightricks/LTX-2.5-Diffusers when the token can read it, else the run trains the distilled DiT. Also stage model_index.json when the Hub listing arrives as a generator.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a2e468778
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _LTX25_DIT_SOURCES[key] = ( | ||
| (repo, _LTX25_DEV_SUBFOLDER) if repo else (base, _LTX25_DISTILLED_SUBFOLDER) | ||
| ) | ||
| return _LTX25_DIT_SOURCES[key] |
There was a problem hiding this comment.
Record the resolved DiT source in checkpoint identity
When resuming an LTX-2.5 run after changing UNSLOTH_LTX25_TRAIN_DIT, or after upstream access changes which fallback is selected, this resolver can choose different frozen weights and a different scheduler without invalidating the checkpoint. identity_for_config() and the later with_resolved_revision(identity, fetch_cfg.base_model) record only the configured fetch repository, not the resolved DiT repository/subfolder. Because dev and distilled adapters have matching shapes, restoration can silently apply the previous adapter and optimizer moments to a different base, corrupting the resumed experiment. Persist and compare the resolved DiT repository, revision, and subfolder before restoring training state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 59e7975: the identity records the resolved DiT repo, subfolder and revision, and a mismatched resume is refused.
The trainer picks the dev or distilled DiT, from the upstream pack or the mirror, at load time. Both have the adapter's shapes, so a resume after UNSLOTH_LTX25_TRAIN_DIT or token access changed silently continued the old adapter and moments on another base. The identity now records the resolved repo:subfolder and its revision and refuses a mismatch; a bundle without the field resumes only onto the default dev DiT of its base. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The conditioning cache keyed captions on family, base and revision only, so after the Gemma 4 encoder switched between int8 and bf16 (UNSLOTH_LTX25_TE_INT8, or the hosted int8 file becoming unavailable) a warm cache served captions from the other encoder. Text keys now carry the resolved precision and source (hosted int8 file with its revision, int8 quantized at load, or bf16); families without a per-run encoder choice keep their keys.
…users is absent The diffusion CI shard runs without diffusers; the subfolder and scheduler tests imported it unguarded. They now skip with the repo's 'diffusers is not importable here' message, as the tiny-pack fixture does.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The LTX saver dropped transformer_lora_adapter_metadata, so diffusers reloaded an adapter trained with lora_alpha != rank at alpha == rank.
…Gemma 4 fits The trainer started the worker resident on every GPU, which loads the whole encoder on the card beside the 6.34 GB connectors and skips the worker's layer-streamed and CPU fallbacks. It is now resident only when the free memory covers the encoder weights, the encode margin and the worker context.
|
@codex review |
1 similar comment
|
@codex review |
The cache namespace read the base revision before load_conditioners fetched it, so a first run on a fresh Hub cache wrote under "unresolved" and the next run, which resolves the commit, missed every entry. The namespace is read again after the encode; on a change the captions are copied over and the latents are written under the resolved namespace. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
) ## Summary `(Python 3.13, diffusion)` fails on `main` for every PR (seen on #18477, which only touches Hub frontend hooks): ``` FAILED tests/test_diffusion_windows_rocm_wide_head.py::test_dit_trainer_guards_the_preview_vae_a_warm_cache_loads[False] core/training/diffusion_dit_trainer.py:3050: in _rekey_conditioning_cache if (fresh.family, getattr(fresh, "text_encoder", "")) == ( E AttributeError: 'object' object has no attribute 'family' ``` Reproduced locally on `main` at `3ee3907c23`. ## Root cause #18386 added `_rekey_conditioning_cache`, which reopens the persistent conditioning cache once the conditioners are on disk and compares its namespace (`family`, `text_encoder`) with the one the run opened. That is correct for the real `PersistentConditioningCache`, which always sets both attributes in `__init__`. The test replaced `PersistentConditioningCache` with `lambda *_a: object()`, a bare object with none of the cache's attributes. It only worked while the cold path never read one. So the trainer change is fine and the stub was too thin. ## Changes - `test_diffusion_windows_rocm_wide_head.py` and `test_diffusion_training_download_phases.py` no longer stub `PersistentConditioningCache`. Both already point `cond_cache_dir` at `tmp_path`, and the real constructor only creates that directory, so the tests now run against the real cache and keep working when the trainer reads another of its attributes. The encode and warm-load steps around it stay stubbed as before, so nothing is encoded or downloaded. No source change. ## Testing - `pytest tests/test_diffusion_windows_rocm_wide_head.py tests/test_diffusion_training_download_phases.py` (from `studio/backend`): 19 passed; on `main` the `[False]` case fails as above. - The existing `tests/test_diffusion_cond_cache_rekey.py` covers `_rekey_conditioning_cache` itself and is unchanged.
## Problem A diffusion LoRA trained with a `lora_alpha` other than its rank reloads at the wrong strength. diffusers' `save_lora_weights` only writes the adapter config (rank, alpha) into the safetensors header when it is passed `*_lora_adapter_metadata`; without it the loader assumes `lora_alpha == rank`. Qwen-Image-2.1, FLUX.3, MOSS, Wan and (since #18386) LTX-2.5 already pass it. FLUX.1, Qwen-Image, Z-Image, Krea 2, FLUX.2-dev, FLUX.2-klein and the SDXL UNet trainer still saved without it, and LTX-2 had its own inline copy of the logic. `lora_alpha` defaults to the rank, so a default run is unaffected. A run that sets `lora_alpha` (the training API accepts it) saves a file that loads scaled by `rank / alpha` instead of `alpha / rank`. ## Change - One helper, `_save_transformer_lora`, passes the trained adapter's `LoraConfig` as `transformer_lora_adapter_metadata` when this diffusers' `save_lora_weights` takes it (older diffusers keep the old call). - Those families now set `save_takes_metadata = True` and save through the helper; LTX-2's inline copy from #18386 is replaced by it. - The SDXL trainer passes `unet_lora_adapter_metadata` the same way. ## Tests `studio/backend/tests/test_diffusion_lora_alpha_metadata.py`: every DiT family in `_SPECS` (skipped where the installed diffusers has no pipeline for it) and SDXL save an r=4, alpha=8 adapter and the header must read `lora_alpha` 8. On main 7 of these fail; here all pass. The DiT trainer, conditioning cache and train suites: 410 passed (CPU). --------- Co-authored-by: Nilay Yadav <[email protected]>
Summary
Studio runs LTX-2.5 on the Video page, but its diffusion trainer refused it. The family was never marked trainable,
get_trainerand_DIT_TRAIN_FAMILIESonly knewltx-2, and a local LTX-2.5 folder was explicitly refused.This PR adds LTX-2.5 LoRA training using the same still-image style flow as LTX-2. A trained LoRA loads back on the Video page.
Design
transformer_full/), since the model card says "The dev transformer is fully trainable". The Video page bakes it into the distilled DiT it renders with, as Studio already does for Krea and FLUX.2 Klein. The dev scheduler gives exactly LTX-2's sigma table.unsloth/LTX-2.5-FP8mirror, which has no dev DiT, the dev DiT is read fromLightricks/LTX-2.5-Diffusersif the token can access it. Otherwise training falls back to the distilled DiT with a warning.UNSLOTH_LTX25_TRAIN_DIT=distilledtrains the distilled DiT on purpose.ltx-2uses. The hosted INT8-ConvRot / FP8 files are distilled-only and are not training bases; GGUF was already refused.model_index.json.ltx-2, or a 2.0 folder asltx-2.5, is still refused.Lightricks/LTX-2.5release is refused with a pointer to the Diffusers pack.Results
LTX-2.5, A100-80 on Colab: nf4 base, 512 px, rank 32, lr 2e-4, 300 steps, seed 0, 16 style stills.
Video page renders through Studio's
VideoBackend, distilled two-stage defaults, 768x512, 25 frames, seed 7:The effect grows with strength, and the backend status shows the LoRA baked at the requested weight.
LTX-2 regression, same VM, interleaved base / head / base / head / base, 40 steps:
Tests
studio/backend/tests/test_diffusion_dit_trainer_ltx25.pyhas 25 tests. They fail at import on main and pass here.VideoBackend. The output difference grows with strength.Not covered
VideoBackendwere driven directly.