Skip to content

Commit 7803632

Browse files
authored
fix: convert boundary_ratio from timestep space to index space (#32)
* fix: convert boundary_ratio from timestep space to index space via inverse sigma_shift * 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.
1 parent 942d493 commit 7803632

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

mova/diffusion/pipelines/mova_train.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,10 +1386,13 @@ def training_step(
13861386
mode_scale=1.0,
13871387
independent_timesteps=False,
13881388
)
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
13891392
if global_step % 2 == 0:
1390-
timestep_config.max_timestep_boundary = self.boundary_ratio
1393+
timestep_config.max_timestep_boundary = boundary
13911394
else:
1392-
timestep_config.min_timestep_boundary = self.boundary_ratio
1395+
timestep_config.min_timestep_boundary = boundary
13931396

13941397
timestep, audio_timestep = self.sample_timestep_pair(timestep_config)
13951398
timestep = timestep.to(device=device)

0 commit comments

Comments
 (0)