Skip to content

fix(ltx2): use actual video sequence length for dynamic timestep shift#14266

Open
sergioperezcheco wants to merge 1 commit into
huggingface:mainfrom
sergioperezcheco:fix/ltx2-dynamic-shift-sequence-length
Open

fix(ltx2): use actual video sequence length for dynamic timestep shift#14266
sergioperezcheco wants to merge 1 commit into
huggingface:mainfrom
sergioperezcheco:fix/ltx2-dynamic-shift-sequence-length

Conversation

@sergioperezcheco

Copy link
Copy Markdown

LTX2Pipeline computed the dynamic-shift mu with max_image_seq_len as the image_seq_len argument to calculate_shift(), which collapses mu to a constant (the max_shift value) regardless of resolution or frame count. With use_dynamic_shifting=True enabled this had no effect at all — the shift never actually varied with the sample.

The fix passes the sample's real packed sequence length (latent_num_frames * latent_height * latent_width) as image_seq_len, matching the Flux/SD3 pipelines and the LTX reference implementation (math.prod(latent.shape[2:])). This value was already computed earlier in the call (it even existed as a commented-out line), and the latent dims are defined a few lines above the timestep section. I also removed the stale commented line since the variable is now used for real.

This is a behavior change: mu will now scale with the actual sequence length rather than always hitting max_shift, so the timestep distribution will shift for all LTX2 generations. That's the intended behavior of dynamic shifting, but flagging it since it's not a no-op. Fixes #14243.

calculate_shift() was being called with max_image_seq_len as its first
argument (image_seq_len), which collapses mu to a constant max_shift
regardless of resolution or frame count. With use_dynamic_shifting=True
this had no effect. Pass the sample's packed sequence length
(latent_num_frames * latent_height * latent_width) instead, matching the
Flux/SD3 pipelines and the LTX reference (math.prod(latent.shape[2:])).

Fixes huggingface#14243

Signed-off-by: Sergio Perez <sergio@checo.cc>
@github-actions github-actions Bot added fixes-issue pipelines size/S PR with diff < 50 LOC labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LTX2Pipeline: dynamic timestep shift mu is constant, ignores the actual sequence length

1 participant