Skip to content

Commit ffdbe98

Browse files
fix(ltx2): use actual video sequence length for dynamic timestep shift
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 #14243 Signed-off-by: Sergio Perez <sergio@checo.cc>
1 parent 175fe6b commit ffdbe98

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/diffusers/pipelines/ltx2/pipeline_ltx2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,6 @@ def __call__(
12761276
raise ValueError(
12771277
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]."
12781278
)
1279-
# video_sequence_length = latent_num_frames * latent_height * latent_width
12801279

12811280
num_channels_latents = self.transformer.config.in_channels
12821281
latents = self.prepare_latents(
@@ -1332,8 +1331,9 @@ def __call__(
13321331

13331332
# 5. Prepare timesteps
13341333
sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps) if sigmas is None else sigmas
1334+
video_sequence_length = latent_num_frames * latent_height * latent_width
13351335
mu = calculate_shift(
1336-
latents.shape[1],
1336+
video_sequence_length,
13371337
self.scheduler.config.get("base_image_seq_len", 1024),
13381338
self.scheduler.config.get("max_image_seq_len", 4096),
13391339
self.scheduler.config.get("base_shift", 0.95),

0 commit comments

Comments
 (0)