EDMEulerScheduler.set_timesteps fails with a list of sigmas, and custom sigmas are passed through the karras ramp
Describe the bug
EDMEulerScheduler.set_timesteps is annotated sigmas: torch.Tensor | list[float] | None and documented as "Custom sigmas to use for the denoising process", but:
- A list raises
AttributeError: 'list' object has no attribute 'to'. OnlyNone, a singlefloatand a tensor are handled (scheduling_edm_euler.py, theisinstance(sigmas, float)/sigmas.to(...)branch).retrieve_timestepsin the pipelines documentssigmasaslist[float], so a list from a pipeline call hits this. - A tensor is not used as the sigma schedule: it goes through
_compute_karras_sigmas(or_compute_exponential_sigmas) as if it were the ramp in[0, 1]. Actual sigmas such as[80, 10, 1, 0.1]produce a meaningless schedule.
Reproduction
import torch
from diffusers import EDMEulerScheduler
sched = EDMEulerScheduler() # sigma_schedule="karras" by default
try:
sched.set_timesteps(sigmas=[80.0, 10.0, 1.0, 0.1])
except Exception as e:
print("list sigmas ->", type(e).__name__, e)
custom = torch.tensor([80.0, 10.0, 1.0, 0.1])
sched.set_timesteps(sigmas=custom)
print("tensor sigmas in :", custom.tolist())
print("scheduler sigmas :", [round(x, 4) for x in sched.sigmas.tolist()])
Context
I was checking how the schedulers handle custom sigmas passed through retrieve_timesteps.
Logs
list sigmas -> AttributeError 'list' object has no attribute 'to'
tensor sigmas in : [80.0, 10.0, 1.0, 0.10000000149011612]
scheduler sigmas : [-263018948591616.0, -53744588.0, 0.002, 45.3137, 0.0]
System Info
diffusers 0.43.0 (same code on main 843f174), torch 2.15.0, Python 3.12.7, macOS.
Who can help?
@yiyixuxu
Which behaviour is intended for sigmas here: actual sigma values (used as given, like most other schedulers' sigmas=), or ramp positions in [0, 1] that the configured schedule maps to sigmas (which is how the default torch.linspace(0, 1, n) path works)? I'm happy to open a PR for whichever you prefer: accept lists in both cases, and either skip the ramp transform for custom sigmas or document that the values are ramp positions and validate the range.
AI disclosure: I used Claude Code (Anthropic) to scan the schedulers and draft the reproduction; I ran the reproduction myself and wrote this up after checking the code paths named above.
The list-of-sigmas crash and the karras ramp both come from set_timesteps running custom values through _compute_karras_sigmas — that transform only makes sense for the default torch.linspace(0, 1, n) ramp.
Opened #15296 to use custom sigmas as given (lists included), and documented the expected order (largest to smallest) so it matches what the default schedule produces. With that, sigmas=[80.0, 9.723, 0.47, 0.002] and num_inference_steps=4 give the same schedule.
@sunhouy thanks, but I filed this and asked above which semantics sigmas should have (actual sigma values vs ramp positions), since the two lead to different fixes. Per CONTRIBUTING I'm waiting for a maintainer to pick one before opening a PR, so I'd rather leave that call to @yiyixuxu.