{"record":{"id":"98b69edc4903fd88","repo":"sgl-project/sglang","slug":"missing-last-sample-as-a-required-keyword-argume-98b69e","errorCode":null,"errorMessage":"missing `last_sample` as a required keyword argument","messagePattern":"missing `last_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":945,"sourceCode":"            this_timestep (`int`):\n                The current timestep `t`.\n            last_sample (`torch.Tensor`):\n                The generated sample before the last predictor `x_{t-1}`.\n            this_sample (`torch.Tensor`):\n                The generated sample after the last predictor `x_{t}`.\n            order (`int`):\n                The `p` of UniC-p at this step. The effective order of accuracy should be `order + 1`.\n\n        Returns:\n            `torch.Tensor`:\n                The corrected sample tensor at the current timestep.\n        \"\"\"\n        this_timestep = args[0] if len(args) > 0 else kwargs.pop(\"this_timestep\", None)\n        if last_sample is None:\n            if len(args) > 1:\n                last_sample = args[1]\n            else:\n                raise ValueError(\"missing `last_sample` as a required keyword argument\")\n        if this_sample is None:\n            if len(args) > 2:\n                this_sample = args[2]\n            else:\n                raise ValueError(\"missing `this_sample` as a required keyword argument\")\n        if order is None:\n            if len(args) > 3:\n                order = args[3]\n            else:\n                raise ValueError(\"missing `order` as a required keyword argument\")\n        if this_timestep is not None:\n            deprecate(\n                \"this_timestep\",\n                \"1.0.0\",\n                \"Passing `this_timestep` is deprecated and has no effect as model output conversion is now handled via an internal counter `self.step_index`\",\n            )\n\n        model_output_list = self.model_outputs","sourceCodeStart":927,"sourceCodeEnd":963,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py#L927-L963","documentation":"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.","triggerScenarios":"Calling multistep_uni_c_bh_update(model_output) without last_sample; using an old call signature that passed (model_output, this_sample, ...) only.","commonSituations":"Direct calls to scheduler internals; normal pipelines never hit this because step() passes this_sample from the previous SchedulerOutput.","solutions":["Use scheduler.step() which manages last/this samples internally","If calling directly pass (model_output, last_sample, this_sample, order) in that positional order"],"exampleFix":"// before\nsched.multistep_uni_c_bh_update(model_output)\n// after\nsched.multistep_uni_c_bh_update(model_output, last_sample, this_sample, order)","handlingStrategy":"validation","validationCode":"assert last_sample is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let scheduler.step() thread last/this samples between iterations","Keep the previous SchedulerOutput and pass .prev_sample forward"],"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"}