From 4b9bc8ec8f334d78b4eedfcbc5741f9a1262457f Mon Sep 17 00:00:00 2001 From: Aloys Jehwin Date: Mon, 3 Aug 2026 22:54:41 +0530 Subject: [PATCH] fix(ltx2): pass actual sequence length to calculate_shift for dynamic timestep shift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #14243 Signed-off-by: Aloys Jehwin --- src/diffusers/pipelines/ltx2/pipeline_ltx2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffusers/pipelines/ltx2/pipeline_ltx2.py b/src/diffusers/pipelines/ltx2/pipeline_ltx2.py index 493db96e48a7..bd8a512f7077 100644 --- a/src/diffusers/pipelines/ltx2/pipeline_ltx2.py +++ b/src/diffusers/pipelines/ltx2/pipeline_ltx2.py @@ -1108,7 +1108,7 @@ def __call__( raise ValueError( f"Provided `latents` tensor has shape {latents.shape}, but the expected shape is either [batch_size, seq_len, num_features] or [batch_size, latent_dim, latent_frames, latent_height, latent_width]." ) - # video_sequence_length = latent_num_frames * latent_height * latent_width + video_sequence_length = latent_num_frames * latent_height * latent_width num_channels_latents = self.transformer.config.in_channels latents = self.prepare_latents( @@ -1165,7 +1165,7 @@ def __call__( # 5. Prepare timesteps sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps) if sigmas is None else sigmas mu = calculate_shift( - self.scheduler.config.get("max_image_seq_len", 4096), + video_sequence_length, self.scheduler.config.get("base_image_seq_len", 1024), self.scheduler.config.get("max_image_seq_len", 4096), self.scheduler.config.get("base_shift", 0.95),