diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

EDMEulerScheduler.set_timesteps fails with a list of sigmas, and custom sigmas are passed through the karras ramp

Open MaiAditya opened this issue 2 weeks ago • 2 comments

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:

  1. A list raises AttributeError: 'list' object has no attribute 'to'. Only None, a single float and a tensor are handled (scheduling_edm_euler.py, the isinstance(sigmas, float) / sigmas.to(...) branch). retrieve_timesteps in the pipelines documents sigmas as list[float], so a list from a pipeline call hits this.
  2. 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.

MaiAditya avatar Nov 12 '26 17:11 MaiAditya

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.

houyunsun avatar Nov 15 '26 00:11 houyunsun

@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.

MaiAditya avatar Nov 18 '26 11:11 MaiAditya