Stability-AI/generative-models · error · ValueError
Order {order} too high for step {i}
Error message
Order {order} too high for step {i} What it means
linear_multistep_coeff builds the linear multistep coefficient for order-order solvers; it needs `order-1` previous steps, so calling it at step i with order-1 > i raises ValueError.
Source
Thrown at sgm/modules/diffusionmodules/sampling_utils.py:9
import torch
from scipy import integrate
from ...util import append_dims
def linear_multistep_coeff(order, t, i, j, epsrel=1e-4):
if order - 1 > i:
raise ValueError(f"Order {order} too high for step {i}")
def fn(tau):
prod = 1.0
for k in range(order):
if j == k:
continue
prod *= (tau - t[i - k]) / (t[i - j] - t[i - k])
return prod
return integrate.quad(fn, t[i], t[i + 1], epsrel=epsrel)[0]
def get_ancestral_step(sigma_from, sigma_to, eta=1.0):
if not eta:
return sigma_to, 0.0
sigma_up = torch.minimum(
sigma_to,
etaView on GitHub (pinned to e8cd657656)
Solutions
- Use min(order, i+1) as the effective order for the first steps in the sampling loop
- Lower the sampler order (e.g. order=2 or 3) in the sampling config
- Ensure the sampler's ramp-up logic (self.rampup / get_order) is invoked rather than calling linear_multistep_coeff directly with a fixed order
Example fix
// before coef = linear_multistep_coeff(4, t, i, old_order) // after order = min(4, i + 1) coef = linear_multistep_coeff(order, t, i, old_order)
Defensive patterns
Strategy: validation
Validate before calling
def assert_order_fits(order, i):
if order - 1 > i:
raise ValueError(f"order {order} needs {order-1} prior steps, but i={i}")
assert_order_fits(sampler.order, step_index) Type guard
def order_fits(order: int, i: int) -> bool:
return order - 1 <= i Try / catch
try:
x = sampler.sample(S, shape, order=4)
except ValueError as e:
if "too high for step" in str(e):
x = sampler.sample(S, shape, order=2)
else:
raise Prevention
- Use the sampler's built-in ramp-up (min(order, i+1)) instead of calling linear_multistep_coeff directly
- Keep sampler order small (2-3) for short schedules
- Add an assertion early in custom sampling loops that order <= num_steps
When it happens
Trigger: Running a linear multistep sampler (e.g. LDMS) with order > i+1 at early steps — e.g. sampler order=4 while ramping starts at i=0 and the sampler does not reduce order for the first steps.
Common situations: Custom sampling loops calling LinearMultistepCoeff/Sampler.sample with a high order and too few warm-up steps; misconfigured sampler args (order larger than allowed for the step schedule).
Related errors
- unknown merge strategy {self.merge_strategy}
- Decay must be between 0 and 1
- unknown merge strategy {merge_strategy}
- rearranging not available for {len(in_shape)}-dimensional in
- Unknown loss type {self.loss_type}
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/b60146b39ab925f2.
Report an issue: GitHub.