{"record":{"id":"0335fcd34cebaf10","repo":"lllyasviel/ControlNet","slug":"solver-order-must-be-1-or-2-or-3-got","errorCode":null,"errorMessage":"Solver order must be 1 or 2 or 3, got {}","messagePattern":"Solver order must be 1 or 2 or 3, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ldm/models/diffusion/dpm_solver/dpm_solver.py","lineNumber":853,"sourceCode":"            order: A `int`. The order of DPM-Solver. We only support order == 1 or 2 or 3.\n            return_intermediate: A `bool`. If true, also return the model value at time `s`, `s1` and `s2` (the intermediate times).\n            solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.\n                The type slightly impacts the performance. We recommend to use 'dpm_solver' type.\n            r1: A `float`. The hyperparameter of the second-order or third-order solver.\n            r2: A `float`. The hyperparameter of the third-order solver.\n        Returns:\n            x_t: A pytorch tensor. The approximated solution at time `t`.\n        \"\"\"\n        if order == 1:\n            return self.dpm_solver_first_update(x, s, t, return_intermediate=return_intermediate)\n        elif order == 2:\n            return self.singlestep_dpm_solver_second_update(x, s, t, return_intermediate=return_intermediate,\n                                                            solver_type=solver_type, r1=r1)\n        elif order == 3:\n            return self.singlestep_dpm_solver_third_update(x, s, t, return_intermediate=return_intermediate,\n                                                           solver_type=solver_type, r1=r1, r2=r2)\n        else:\n            raise ValueError(\"Solver order must be 1 or 2 or 3, got {}\".format(order))\n\n    def multistep_dpm_solver_update(self, x, model_prev_list, t_prev_list, t, order, solver_type='dpm_solver'):\n        \"\"\"\n        Multistep DPM-Solver with the order `order` from time `t_prev_list[-1]` to time `t`.\n        Args:\n            x: A pytorch tensor. The initial value at time `s`.\n            model_prev_list: A list of pytorch tensor. The previous computed model values.\n            t_prev_list: A list of pytorch tensor. The previous times, each time has the shape (x.shape[0],)\n            t: A pytorch tensor. The ending time, with the shape (x.shape[0],).\n            order: A `int`. The order of DPM-Solver. We only support order == 1 or 2 or 3.\n            solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.\n                The type slightly impacts the performance. We recommend to use 'dpm_solver' type.\n        Returns:\n            x_t: A pytorch tensor. The approximated solution at time `t`.\n        \"\"\"\n        if order == 1:\n            return self.dpm_solver_first_update(x, t_prev_list[-1], t, model_s=model_prev_list[-1])\n        elif order == 2:","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/ldm/models/diffusion/dpm_solver/dpm_solver.py#L835-L871","documentation":"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.","triggerScenarios":"Calling sample(..., method='singlestep', order=4) or passing order=0/negative; also any programmatic loop that sweeps order values beyond 3.","commonSituations":"UI exposure of unbounded order sliders; assuming DPM-Solver3 supports arbitrary order like linear multistep methods in ODE libraries.","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"],"exampleFix":"# before\norder = int(request.args['order'])  # user can send 5\ndpm.sample(x, steps=20, order=order, ...)\n# after\norder = min(max(int(request.args['order']), 1), 3)\ndpm.sample(x, steps=20, order=order, ...)","handlingStrategy":"validation","validationCode":"order = int(order)\nassert order in (1, 2, 3), f'order must be 1-3, got {order}'","typeGuard":"def is_valid_order(o) -> bool:\n    return isinstance(o, int) and not isinstance(o, bool) and o in (1, 2, 3)","tryCatchPattern":null,"preventionTips":["Clamp user-facing order values to 1-3","Convert numeric inputs to int early in the sampling wrapper"],"tags":["dpm-solver","order","sampling","value-error"],"backgroundTag":"argument-out-of-range","analyzedSha":"ed85cd1e25a5ed592f7d8178495b4483de0331bf","analyzedAt":"2026-08-27T12:58:54.167Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}