sgl-project/sglang · error · ValueError
missing `sample` as a required keyword argument
Error message
missing `sample` as a required keyword argument
What it means
convert_model_output requires the noisy sample tensor; the legacy signature allows positional args, but if `sample` was not passed as the second positional arg or as a keyword, there is nothing to convert and it raises. `timestep` is likewise deprecated because step indexing is internal now.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py:734
Args:
model_output (`torch.Tensor`):
The direct output from the learned diffusion model.
timestep (`int`):
The current discrete timestep in the diffusion chain.
sample (`torch.Tensor`):
A current instance of a sample created by the diffusion process.
Returns:
`torch.Tensor`:
The converted model output.
"""
timestep = args[0] if len(args) > 0 else kwargs.pop("timestep", None)
if sample is None:
if len(args) > 1:
sample = args[1]
else:
raise ValueError("missing `sample` as a required keyword argument")
if timestep is not None:
deprecate(
"timesteps",
"1.0.0",
"Passing `timesteps` is deprecated and has no effect as model output conversion is now handled via an internal counter `self.step_index`",
)
sigma = self.sigmas[self.step_index]
alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)
if self.predict_x0:
if self.config.prediction_type == "epsilon":
x0_pred = (sample - sigma_t * model_output) / alpha_t
elif self.config.prediction_type == "sample":
x0_pred = model_output
elif self.config.prediction_type == "v_prediction":
x0_pred = alpha_t * sample - sigma_t * model_output
elif self.config.prediction_type == "flow_prediction":View on GitHub (pinned to 0132848349)
Solutions
- Call scheduler.step(model_output, timestep, sample) instead of convert_model_output directly
- If calling convert_model_output, pass sample explicitly: convert_model_output(model_output, sample=sample)
- Do not pass timestep — it is deprecated and ignored
Example fix
// before x0 = sched.convert_model_output(model_output) // after x0 = sched.convert_model_output(model_output, sample=sample) # or preferably out = sched.step(model_output, t, sample)
Defensive patterns
Strategy: validation
Validate before calling
assert sample is not None, "sample tensor is required"
Prevention
- Never call convert_model_output directly; use scheduler.step()
- Pass sample by keyword if you must call internals
When it happens
Trigger: Calling scheduler.convert_model_output(model_output) with no `sample` positional/keyword, e.g. porting old code that passed only (model_output, sample) order incorrectly or omitted sample.
Common situations: User code calling scheduler internals directly instead of scheduler.step(); upgrading from old diffusers versions where the call signature differed.
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
- missing `order` as a required keyword argument
- missing `last_sample` as a required keyword argument
- missing `this_sample` as a required keyword argument
- {beta_schedule} is not implemented for {self.__class__}
- {solver_type} is not implemented for {self.__class__}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/aaf8ed2e87815603.
Report an issue: GitHub.