Skip to content

Commit 72eeb02

Browse files
Auraithmcursoragent
andcommitted
fix: use table lookup for boundary index instead of inverse sigma_shift formula
Replace the analytical inverse sigma_shift formula with a direct table lookup on scheduler.timesteps. This avoids floating-point precision issues (e.g. 0.24999 vs 0.25) and the sigma_min != 0 approximation error, giving an exact boundary at the intended timestep threshold. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 93110ce commit 72eeb02

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

mova/diffusion/pipelines/mova_train.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,14 +1386,9 @@ def training_step(
13861386
mode_scale=1.0,
13871387
independent_timesteps=False,
13881388
)
1389-
# The sigma_shift formula in flow_match.py L57:
1390-
# sigma_shifted = shift * sigma_linear / (1 + (shift - 1) * sigma_linear)
1391-
# boundary_ratio is in shifted space; invert to get sigma_linear:
1392-
# sigma_linear = boundary_ratio / (shift - (shift - 1) * boundary_ratio)
1393-
# index_boundary = 1 - sigma_linear, which simplifies to:
1394-
# shift * (1 - boundary_ratio) / (1 + (shift - 1) * (1 - boundary_ratio))
1395-
# e.g. shift=3, boundary_ratio=0.9 => sigma_linear=0.75 => index=0.25
1396-
boundary = self.scheduler.shift * (1 - self.boundary_ratio) / (1 + (self.scheduler.shift - 1) * (1 - self.boundary_ratio))
1389+
# Look up the index boundary directly from the scheduler's timestep table.
1390+
# boundary_ratio=0.9 means timestep 900; count how many timesteps >= 900 to get the index fraction.
1391+
boundary = (self.scheduler.timesteps >= self.boundary_ratio * self.scheduler.num_train_timesteps).sum().item() / self.scheduler.num_train_timesteps
13971392
if global_step % 2 == 0:
13981393
timestep_config.max_timestep_boundary = boundary
13991394
else:

0 commit comments

Comments
 (0)