diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Scheduler set_timesteps has no shared contract at small step counts: a 49-scheduler census on 0.43.0

Open 1OF1Research opened this issue 2 weeks ago • 0 comments

I swept every scheduler class exported by diffusers 0.43.0 (49 classes) with a fresh instance per call, calling set_timesteps(n) for n in {0, 1, 2, 10} under default construction (num_train_timesteps=1000). The small-count behaviour splits four ways at n=0, and two schedulers fail at counts a caller can plausibly request:

At n=0:

  • Clean ValueError naming the problem (5): BlockRefinement, DiscreteDDIM, EntropyBound, MiniMaxH3 (also at n=1), Piflow.
  • ZeroDivisionError: integer division or modulo by zero (13): CMStochasticIterative, CogVideoXDDIM, CogVideoXDPM, DDIMInverse, DDIMParallel, DDIM, DDPMParallel, DDPM, LCM, PNDM, RePaint, TCD, and (at n=1 instead) UnCLIP — #14586 is one instance of this group.
  • TypeError: object of type 'NoneType' has no len() (2): DPMSolverSinglestep, HeunDiscrete.
  • Silently accepted, returning an empty schedule (most of the rest) — a pipeline then runs zero steps and returns its input, with no signal.
  • Silently accepted and returns a non-empty schedule (1): DDPMWuerstchen returns 1 timestep for n=0 (and n+1 in general).

At working counts:

  • PNDMScheduler.set_timesteps(1), (2), and (3) raise ValueError: operands could not be broadcast together with shapes (2,) (8,) / (4,) (8,) / (6,) (8,); n>=4 works. The message gives no hint that the step count is the problem.
  • HeliosScheduler and HeliosDMDScheduler: set_timesteps(10) with the default stage_index=None raises KeyError: None (the stage lookup at scheduling_helios.py:227). The pipeline passes a stage index, so the class works there, but the documented scheduler-level call crashes opaquely at every count.

The fix shape already exists inside the library: MiniMaxH3 and BlockRefinement validate up front and raise a ValueError that names the count and the requirement. Applying the same up-front validation across set_timesteps implementations — each scheduler stating its own minimum (1 for most, 2 where the math divides by n-1, 4 for PNDM's prk steps, a stage requirement for Helios) — would turn all four behaviours into one clear error at the call site.

Happy to open a PR with the validation plus a parametrized small-count test over the scheduler classes if this direction is welcome. The full 49x4 result table is available if useful.

1OF1Research avatar Nov 15 '26 21:11 1OF1Research