lllyasviel/ControlNet · error · ValueError
Solver order must be 1 or 2 or 3, got {}
Error message
Solver order must be 1 or 2 or 3, got {} What it means
singlestep_dpm_solver_update dispatches on the order argument and only implements orders 1, 2, and 3; anything else (including floats like 2.0 in some paths or order>=4) raises this ValueError. It is called from sample() for singlestep/adaptive methods.
Source
Thrown at ldm/models/diffusion/dpm_solver/dpm_solver.py:853
order: A `int`. The order of DPM-Solver. We only support order == 1 or 2 or 3.
return_intermediate: A `bool`. If true, also return the model value at time `s`, `s1` and `s2` (the intermediate times).
solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.
The type slightly impacts the performance. We recommend to use 'dpm_solver' type.
r1: A `float`. The hyperparameter of the second-order or third-order solver.
r2: A `float`. The hyperparameter of the third-order solver.
Returns:
x_t: A pytorch tensor. The approximated solution at time `t`.
"""
if order == 1:
return self.dpm_solver_first_update(x, s, t, return_intermediate=return_intermediate)
elif order == 2:
return self.singlestep_dpm_solver_second_update(x, s, t, return_intermediate=return_intermediate,
solver_type=solver_type, r1=r1)
elif order == 3:
return self.singlestep_dpm_solver_third_update(x, s, t, return_intermediate=return_intermediate,
solver_type=solver_type, r1=r1, r2=r2)
else:
raise ValueError("Solver order must be 1 or 2 or 3, got {}".format(order))
def multistep_dpm_solver_update(self, x, model_prev_list, t_prev_list, t, order, solver_type='dpm_solver'):
"""
Multistep DPM-Solver with the order `order` from time `t_prev_list[-1]` to time `t`.
Args:
x: A pytorch tensor. The initial value at time `s`.
model_prev_list: A list of pytorch tensor. The previous computed model values.
t_prev_list: A list of pytorch tensor. The previous times, each time has the shape (x.shape[0],)
t: A pytorch tensor. The ending time, with the shape (x.shape[0],).
order: A `int`. The order of DPM-Solver. We only support order == 1 or 2 or 3.
solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.
The type slightly impacts the performance. We recommend to use 'dpm_solver' type.
Returns:
x_t: A pytorch tensor. The approximated solution at time `t`.
"""
if order == 1:
return self.dpm_solver_first_update(x, t_prev_list[-1], t, model_s=model_prev_list[-1])
elif order == 2:View on GitHub (pinned to ed85cd1e25)
Solutions
- Use order in {1, 2, 3}
- Clamp/validate user input before calling sample
- Use DPM-Solver-fast by omitting method to let the library pick valid orders
Example fix
# before order = int(request.args['order']) # user can send 5 dpm.sample(x, steps=20, order=order, ...) # after order = min(max(int(request.args['order']), 1), 3) dpm.sample(x, steps=20, order=order, ...)
Defensive patterns
Strategy: validation
Validate before calling
order = int(order)
assert order in (1, 2, 3), f'order must be 1-3, got {order}' Type guard
def is_valid_order(o) -> bool:
return isinstance(o, int) and not isinstance(o, bool) and o in (1, 2, 3) Prevention
- Clamp user-facing order values to 1-3
- Convert numeric inputs to int early in the sampling wrapper
When it happens
Trigger: Calling sample(..., method='singlestep', order=4) or passing order=0/negative; also any programmatic loop that sweeps order values beyond 3.
Common situations: UI exposure of unbounded order sliders; assuming DPM-Solver3 supports arbitrary order like linear multistep methods in ODE libraries.
Related errors
- 'order' must be '1' or '2' or '3'.
- 'solver_type' must be either 'dpm_solver' or 'taylor', got {
- Unsupported noise schedule {}. The schedule needs to be 'dis
- Unsupported skip_type {}, need to be 'logSNR' or 'time_unifo
- resize_method {self.__resize_method} not implemented
AI-assisted analysis of lllyasviel/ControlNet@ed85cd1e25 (2026-08-27).
Data as JSON: /api/errors/0335fcd34cebaf10.
Report an issue: GitHub.