Skip to content

Limit seq_length to max_tokens in timestep_samplers#230

Open
lsl0007 wants to merge 1 commit into
Lightricks:mainfrom
lsl0007:main
Open

Limit seq_length to max_tokens in timestep_samplers#230
lsl0007 wants to merge 1 commit into
Lightricks:mainfrom
lsl0007:main

Conversation

@lsl0007

@lsl0007 lsl0007 commented Jun 8, 2026

Copy link
Copy Markdown

Problem

When seq_length exceeds max_tokens (4096), _get_shift_for_sequence_length
computes an unbounded mu (e.g. seq_len=93060 → mu≈34). Both percentile bounds
saturate at 1.0, causing division by zero in zero_terminal_raw and NaN sigmas.
This propagates to noised latents and loss, crashing training.

Fix

Clamp seq_length to max_tokens before computing the shift, matching the
inference-side LTX2Scheduler anchor range (1024–4096 → shift 0.95–2.05).

Verification

Before After
seq_len 93060 (capped to 4096)
percentile_999 / 005 1.0 / 1.0 ~0.99 / ~0.37
zero_terminal_raw NaN ~0.85

Cap sequence length to max_tokens to prevent NaN errors.(Without this cap, very large seq_length drives mu up, both percentile bounds saturate near 1.0, and zero_terminal_raw divides by ~0 → NaN.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant