Repository navigation
Fix LTX video loss on fixed conditioning tokens - #1755
Open
taking-lying-flat wants to merge 1 commit into
Open
taking-lying-flat wants to merge 1 commit into
taking-lying-flat wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LTX first-frame conditioning replaces the corresponding noisy video latents with clean inputs and sets their token timesteps to zero, but
FlowMatchSFTAudioVideoLossstill regresses those outputs againstnoise - clean. Changing only the discarded noise therefore changes the loss and gradients even when all model inputs are identical. In a two-token example, the current loss changes from 2.5 to 6.5 and the fixed-position output gradient from -1 to -3.When video latents are replaced through
input_latents_video, exclude positions wheredenoise_mask_video == 0from the video loss. Average over channels and normalize over each sample's supervised positions before averaging the batch, matching the official LTX masked-loss convention. Nonzero mask values retain full supervision, including soft conditioning; they are not treated as fractional loss weights. A sample with no supervised video positions contributes zero video loss. The unconditioned path and audio loss keep their existing behavior.The example now returns loss 4.0 for both noise samples and zero direct output gradient at the fixed position. This concerns replaced target positions; appended reference tokens used by
end_imageare already removed from the returned prediction.Validation: 64 local CPU cases passed using the actual loss, conditioning unit, model wrapper, scheduler methods and patchifiers, with pre-encoded VAE fixtures and recorder/trainable-linear DiT substitutes:
compute_loss, with and without audio.git diff --checkpass.Only
diffsynth/diffusion/loss.pyis changed; the local validation scripts are not included. No full-model or CUDA training was run.Official reference: https://github.com/Lightricks/LTX-2/blob/be6d6d0a69d11a0a399c462ed92606692e5f8697/packages/ltx-trainer/src/ltx_trainer/training_strategies/text_to_video.py#L256-L278