{"record":{"id":"aaf8ed2e87815603","repo":"sgl-project/sglang","slug":"missing-sample-as-a-required-keyword-argument-aaf8ed","errorCode":null,"errorMessage":"missing `sample` as a required keyword argument","messagePattern":"missing `sample` as a required keyword argument","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py","lineNumber":734,"sourceCode":"\n        Args:\n            model_output (`torch.Tensor`):\n                The direct output from the learned diffusion model.\n            timestep (`int`):\n                The current discrete timestep in the diffusion chain.\n            sample (`torch.Tensor`):\n                A current instance of a sample created by the diffusion process.\n\n        Returns:\n            `torch.Tensor`:\n                The converted model output.\n        \"\"\"\n        timestep = args[0] if len(args) > 0 else kwargs.pop(\"timestep\", None)\n        if sample is None:\n            if len(args) > 1:\n                sample = args[1]\n            else:\n                raise ValueError(\"missing `sample` as a required keyword argument\")\n        if timestep is not None:\n            deprecate(\n                \"timesteps\",\n                \"1.0.0\",\n                \"Passing `timesteps` is deprecated and has no effect as model output conversion is now handled via an internal counter `self.step_index`\",\n            )\n\n        sigma = self.sigmas[self.step_index]\n        alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)\n\n        if self.predict_x0:\n            if self.config.prediction_type == \"epsilon\":\n                x0_pred = (sample - sigma_t * model_output) / alpha_t\n            elif self.config.prediction_type == \"sample\":\n                x0_pred = model_output\n            elif self.config.prediction_type == \"v_prediction\":\n                x0_pred = alpha_t * sample - sigma_t * model_output\n            elif self.config.prediction_type == \"flow_prediction\":","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py#L716-L752","documentation":"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.","triggerScenarios":"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.","commonSituations":"User code calling scheduler internals directly instead of scheduler.step(); upgrading from old diffusers versions where the call signature differed.","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"],"exampleFix":"// before\nx0 = sched.convert_model_output(model_output)\n// after\nx0 = sched.convert_model_output(model_output, sample=sample)\n# or preferably\nout = sched.step(model_output, t, sample)","handlingStrategy":"validation","validationCode":"assert sample is not None, \"sample tensor is required\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call convert_model_output directly; use scheduler.step()","Pass sample by keyword if you must call internals"],"tags":["scheduler","diffusion","api-misuse","unipc"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}