{"record":{"id":"688547c626e4b0d2","repo":"sgl-project/sglang","slug":"callback-on-step-end-tensor-inputs-has-to-be-in","errorCode":null,"errorMessage":"`callback_on_step_end_tensor_inputs` has to be in {self._callback_tensor_inputs}, but found {[k for k in callback_on_step_end_tensor_inputs if k not in self._callback_tensor_inputs]}","messagePattern":"`callback_on_step_end_tensor_inputs` has to be in (.+?), but found (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py","lineNumber":1096,"sourceCode":"        callback_on_step_end_tensor_inputs,\n        prompt_embeds=None,\n    ):\n        if (\n            height is not None\n            and height % (self.vae_scale_factor * self.transformer.config.patch_size)\n            != 0\n            or width is not None\n            and width % (self.transformer.config.patch_size) != 0\n        ):\n            logger.warning(\n                f\"`height` and `width` have to be divisible by {self.vae_scale_factor * 2} but are {height} and {width}. Dimensions will be resized accordingly\"\n            )\n\n        if callback_on_step_end_tensor_inputs is not None and not all(\n            k in self._callback_tensor_inputs\n            for k in callback_on_step_end_tensor_inputs\n        ):\n            raise ValueError(\n                f\"`callback_on_step_end_tensor_inputs` has to be in {self._callback_tensor_inputs}, but found {[k for k in callback_on_step_end_tensor_inputs if k not in self._callback_tensor_inputs]}\"\n            )\n\n        if prompt is not None and prompt_embeds is not None:\n            raise ValueError(\n                f\"Cannot forward both `prompt`: {prompt} and `prompt_embeds`: {prompt_embeds}. Please make sure to\"\n                \" only forward one of the two.\"\n            )\n        elif prompt is None and prompt_embeds is None:\n            raise ValueError(\n                \"Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined.\"\n            )\n        elif prompt is not None and (\n            not isinstance(prompt, str) and not isinstance(prompt, list)\n        ):\n            raise ValueError(\n                f\"`prompt` has to be of type `str` or `list` but is {type(prompt)}\"\n            )","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py#L1078-L1114","documentation":"check_inputs validates callback_on_step_end_tensor_inputs: every name in that list must be one of the pipeline's registered tensor inputs (self._callback_tensor_inputs, e.g. latents, prompt_embeds, negative_prompt_embeds). Passing an unknown key means the step-end callback would receive a tensor the pipeline cannot provide.","triggerScenarios":"Calling the pipeline with callback_on_step_end_tensor_inputs=[\"my_custom_latents\"] or a key renamed in a newer version (e.g. \"prompt_embeds\" vs an older alias) that is not in _callback_tensor_inputs.","commonSituations":"Porting callback code from diffusers pipelines whose _callback_tensor_inputs set differs; using a key that only exists in another model's pipeline; typos in the input names.","solutions":["Print self._callback_tensor_inputs and restrict your list to those names","Fix typos/renamed keys (commonly latents, prompt_embeds, negative_prompt_embeds)","Pass None to use the callback without extra tensor inputs"],"exampleFix":"# before\npipe(prompt=\"a cat\", callback_on_step_end=cb, callback_on_step_end_tensor_inputs=[\"latentss\"])\n\n# after\npipe(prompt=\"a cat\", callback_on_step_end=cb, callback_on_step_end_tensor_inputs=[\"latents\"])","handlingStrategy":"type-guard","validationCode":"valid = set(stage._callback_tensor_inputs)\nkeys = [k for k in callback_on_step_end_tensor_inputs or [] if k in valid]\npipe(prompt=p, callback_on_step_end=cb, callback_on_step_end_tensor_inputs=keys or None)","typeGuard":"def valid_tensor_inputs(stage, requested) -> list:\n    return [k for k in requested if k in stage._callback_tensor_inputs]","tryCatchPattern":"except ValueError as e:\n    if \"callback_on_step_end_tensor_inputs\" in str(e):\n        retry_with_filtered_keys()  # intersect with _callback_tensor_inputs\n    else:\n        raise","preventionTips":["Read _callback_tensor_inputs from the pipeline instance instead of assuming names","Version-pin when porting diffusers callback code","Add a startup assertion that all configured callback keys are registered"],"tags":["glm-image","callback","tensor-inputs","input-validation","valueerror"],"backgroundTag":"invalid-callback-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}