Skip to content

fix(ltx2): pass actual sequence length to calculate_shift for dynamic timestep shift - #14373

Open
AloysJehwin wants to merge 1 commit into
huggingface:mainfrom
AloysJehwin:fix/ltx2-dynamic-timestep-shift
Open

fix(ltx2): pass actual sequence length to calculate_shift for dynamic timestep shift#14373
AloysJehwin wants to merge 1 commit into
huggingface:mainfrom
AloysJehwin:fix/ltx2-dynamic-timestep-shift

Conversation

@AloysJehwin

Copy link
Copy Markdown

What does this PR do?

Fixes #14243

In LTX2Pipeline.__call__, mu was computed by passing max_image_seq_len as both the first (image_seq_len) and third (max_image_seq_len) arguments to calculate_shift. Since the function returns image_seq_len * m + b, passing the maximum always yields max_shift — so use_dynamic_shifting=True had no effect.

The fix was already suggested in the code: a commented-out line # video_sequence_length = latent_num_frames * latent_height * latent_width sat directly above. Uncommented it and passed the result as image_seq_len, matching LTX v1 pipeline (pipeline_ltx.py:725-728) and the LTX reference implementation.

Before

mu = calculate_shift(
    self.scheduler.config.get(max_image_seq_len, 4096),  # always max -> mu is always max_shift
    ...
    self.scheduler.config.get(max_image_seq_len, 4096),
    ...
)

After

video_sequence_length = latent_num_frames * latent_height * latent_width
mu = calculate_shift(
    video_sequence_length,  # actual sequence length -> mu scales with resolution/frames
    ...
    self.scheduler.config.get(max_image_seq_len, 4096),
    ...
)

Implemented with Claude Code assistance. All changed lines reviewed manually.

… timestep shift

LTX2Pipeline passed max_image_seq_len as the first argument to
calculate_shift(), which also receives it as the third argument (the
maximum). Since calculate_shift returns image_seq_len * m + b, passing
the maximum as image_seq_len always returns max_shift — making mu
constant regardless of resolution or frame count.

The commented-out line below already computed the correct value.
Uncommented it and passed video_sequence_length as image_seq_len,
matching LTX v1 pipeline (pipeline_ltx.py:725-728) and the LTX
reference implementation.

Fixes huggingface#14243

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>
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