sgl-project/sglang · error · ValueError

missing `last_sample` as a required keyword argument

Error message

missing `last_sample` as a required keyword argument

What it means

multistep_uni_c_bh_update (the UniC corrector) requires `last_sample` — the sample from the previous step. Legacy positional layout expects it as the second argument; if absent as arg or keyword, the corrector cannot form its residual.

Source

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

            this_timestep (`int`):
                The current timestep `t`.
            last_sample (`torch.Tensor`):
                The generated sample before the last predictor `x_{t-1}`.
            this_sample (`torch.Tensor`):
                The generated sample after the last predictor `x_{t}`.
            order (`int`):
                The `p` of UniC-p at this step. The effective order of accuracy should be `order + 1`.

        Returns:
            `torch.Tensor`:
                The corrected sample tensor at the current timestep.
        """
        this_timestep = args[0] if len(args) > 0 else kwargs.pop("this_timestep", None)
        if last_sample is None:
            if len(args) > 1:
                last_sample = args[1]
            else:
                raise ValueError("missing `last_sample` as a required keyword argument")
        if this_sample is None:
            if len(args) > 2:
                this_sample = args[2]
            else:
                raise ValueError("missing `this_sample` as a required keyword argument")
        if order is None:
            if len(args) > 3:
                order = args[3]
            else:
                raise ValueError("missing `order` as a required keyword argument")
        if this_timestep is not None:
            deprecate(
                "this_timestep",
                "1.0.0",
                "Passing `this_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

View on GitHub (pinned to 0132848349)

Solutions

  1. Use scheduler.step() which manages last/this samples internally
  2. If calling directly pass (model_output, last_sample, this_sample, order) in that positional order

Example fix

// before
sched.multistep_uni_c_bh_update(model_output)
// after
sched.multistep_uni_c_bh_update(model_output, last_sample, this_sample, order)
Defensive patterns

Strategy: validation

Validate before calling

assert last_sample is not None

Prevention

When it happens

Trigger: Calling multistep_uni_c_bh_update(model_output) without last_sample; using an old call signature that passed (model_output, this_sample, ...) only.

Common situations: Direct calls to scheduler internals; normal pipelines never hit this because step() passes this_sample from the previous SchedulerOutput.

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/98b69edc4903fd88. Report an issue: GitHub.