-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Open
Labels
bugSomething isn't workingSomething isn't workingstaleIssues that haven't received updatesIssues that haven't received updates
Description
Describe the bug
Description
In the index_for_timestep() method, there's a precision issue when comparing floating-point timesteps with integer schedule_timesteps. The comparison schedule_timesteps == timestep can fail to find matching indices due to floating-point truncation, causing some timestep indices to be missed.
Location: scheduling_flow_match_euler_discrete.py, line 303:
indices = (schedule_timesteps == timestep).nonzero()Reproduction
import torch
import numpy as np
from diffusers.schedulers.scheduling_flow_match_euler_discrete import FlowMatchEulerDiscreteScheduler
num_train_timesteps = 1000
batch_size = 1
noise_scheduler = FlowMatchEulerDiscreteScheduler(
num_train_timesteps=num_train_timesteps,
)
device = "cuda:0"
for i in range(100000):
print(i)
action_gt = torch.rand(64, 128).to(device)
noise = torch.randn(
action_gt.shape, dtype=action_gt.dtype, device=device
)
timesteps = torch.randint(
1, num_train_timesteps,
(batch_size,), device=device
).long()
noisy_action = noise_scheduler.scale_noise(
sample=action_gt,
noise=noise,
timestep=timesteps,
)Logs
File "/anaconda3/envs/rdt/lib/python3.10/site-packages/diffusers/schedulers/scheduling_flow_match_euler_discrete.py", line 175, in scale_noise
step_indices = [self.index_for_timestep(t, schedule_timesteps) for t in timestep]
File "/anaconda3/envs/rdt/lib/python3.10/site-packages/diffusers/schedulers/scheduling_flow_match_euler_discrete.py", line 175, in <listcomp>
step_indices = [self.index_for_timestep(t, schedule_timesteps) for t in timestep]
File "/anaconda3/envs/rdt/lib/python3.10/site-packages/diffusers/schedulers/scheduling_flow_match_euler_discrete.py", line 292, in index_for_timestep
return indices[pos].item()
IndexError: index 0 is out of bounds for dimension 0 with size 0System Info
diffusers version: 0.32.1
Python version: 3.10
OS: Linux / Ubuntu 22
Who can help?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleIssues that haven't received updatesIssues that haven't received updates