Comfy-Org/ComfyUI · error · ValueError
Order {order} too high for step {i}
Error message
Order {order} too high for step {i} What it means
Raised by linear_multistep_coeff, the coefficient helper for sample_lms (linear multistep sampler). An order-N Adams-Bashforth step at position i needs i+1 previous points; if order-1 > i (i.e. the very first steps of the schedule don't yet have enough history), the Lagrange product would index negative positions, so it refuses up front.
Source
Thrown at comfy/k_diffusion/sampling.py:408
if sigma_down == 0:
# Euler method
dt = sigma_down - sigmas[i]
x = x + d * dt
else:
# DPM-Solver-2
sigma_mid = sigmas[i].log().lerp(sigma_down.log(), 0.5).exp()
dt_1 = sigma_mid - sigmas[i]
dt_2 = sigma_down - sigmas[i]
x_2 = x + d * dt_1
denoised_2 = model(x_2, sigma_mid * s_in, **extra_args)
d_2 = to_d(x_2, sigma_mid, denoised_2)
x = x + d_2 * dt_2
x = (alpha_ip1/alpha_down) * x + noise_sampler(sigmas[i], sigmas[i + 1]) * s_noise * renoise_coeff
return x
def linear_multistep_coeff(order, t, i, j):
if order - 1 > i:
raise ValueError(f'Order {order} too high for step {i}')
def fn(tau):
prod = 1.
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=1e-4)[0]
@torch.no_grad()
def sample_lms(model, x, sigmas, extra_args=None, callback=None, disable=None, order=4):
extra_args = {} if extra_args is None else extra_args
s_in = x.new_ones([x.shape[0]])
sigmas_cpu = sigmas.detach().cpu().numpy()
ds = []
for i in trange(len(sigmas) - 1, disable=disable):
denoised = model(x, sigmas[i] * s_in, **extra_args)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Clamp order during warmup: order = min(order, i + 1) exactly as sample_lms does
- Lower the global order to <= number of early steps you can skip, or start integration after enough history exists
- When calling linear_multistep_coeff directly, ensure i >= order-1
Example fix
# before coeff = linear_multistep_coeff(4, t, i=1, j=1) # order-1 > i # after order = min(4, i + 1) coeff = linear_multistep_coeff(order, t, i=1, j=1)
Defensive patterns
Strategy: validation
Validate before calling
order = min(order, i + 1) # warmup clamp, mirrors sample_lms coeff = linear_multistep_coeff(order, t, i, j)
Prevention
- Always clamp multistep order to available history (i+1 points)
- Keep the min(order, i+1) line when copying sample_lms
When it happens
Trigger: Calling sample_lms (or linear_multistep_coeff directly) with order > number of warmup steps available — concretely order=4 is fine because sample_lms clamps with min(order, i+1), but direct calls to linear_multistep_coeff(order, t, i, j) with order-1 > i raise. Also custom samplers that forget the warmup clamp.
Common situations: Copy-pasting sample_lms into a custom sampler without the `order = min(order, i + 1)` warmup line; calling the coefficient helper standalone for unit tests with small i; schedules with very few steps combined with high order in modified code.
Related errors
- Unsupported noise schedule {}. The schedule needs to be 'dis
- sigma_min and sigma_max must not be 0
- solver_type must be 'heun' or 'midpoint'
- solver_type must be 'phi_1' or 'phi_2'
- ar_video sampler requires 5-D video latents [B,C,T,H,W], got
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/244d1166d26a3896.
Report an issue: GitHub.