sgl-project/sglang · error · ValueError

missing `order` as a required keyword argument

Error message

missing `order` as a required keyword argument

What it means

multistep_uni_p_bh_update requires the solver `order` (number of correction history terms); if not supplied as the third positional arg or keyword, the B(h) polynomial loop bound is unknown.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py:815

                A current instance of a sample created by the diffusion process.
            order (`int`):
                The order of UniP at this timestep (corresponds to the *p* in UniPC-p).

        Returns:
            `torch.Tensor`:
                The sample tensor at the previous timestep.
        """
        prev_timestep = args[0] if len(args) > 0 else kwargs.pop("prev_timestep", None)
        if sample is None:
            if len(args) > 1:
                sample = args[1]
            else:
                raise ValueError("missing `sample` as a required keyword argument")
        if order is None:
            if len(args) > 2:
                order = args[2]
            else:
                raise ValueError("missing `order` as a required keyword argument")
        if prev_timestep is not None:
            deprecate(
                "prev_timestep",
                "1.0.0",
                "Passing `prev_timestep` is deprecated and has no effect as model output conversion is now handled via an internal counter `self.step_index`",
            )
        model_output_list = self.model_outputs

        s0 = self.timestep_list[-1]
        m0 = model_output_list[-1]
        x = sample

        if self.solver_p:
            x_t = self.solver_p.step(model_output, s0, x).prev_sample
            return x_t

        sigma_t, sigma_s0 = (
            self.sigmas[self.step_index + 1],

View on GitHub (pinned to 0132848349)

Solutions

  1. Call scheduler.step() instead
  2. Pass order explicitly, typically min(self.step_index + 1, solver_order)

Example fix

// before
sched.multistep_uni_p_bh_update(model_output, sample)
// after
order = min(sched.step_index + 1, sched.config.solver_order)
prev = sched.multistep_uni_p_bh_update(model_output, sample, order)
Defensive patterns

Strategy: validation

Validate before calling

assert order is not None and order >= 1

Prevention

When it happens

Trigger: Calling multistep_uni_p_bh_update(model_output, sample) with only two args and no order keyword.

Common situations: Direct internal API calls ported from older versions with a different arity; step() computes order from self.step_index and passes it, so this only affects manual calls.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/beb0b6eb7c6cb022. Report an issue: GitHub.