sgl-project/sglang · error · ValueError

`callback_on_step_end_tensor_inputs` has to be in {self._cal

Error message

`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]}

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py:1096

        callback_on_step_end_tensor_inputs,
        prompt_embeds=None,
    ):
        if (
            height is not None
            and height % (self.vae_scale_factor * self.transformer.config.patch_size)
            != 0
            or width is not None
            and width % (self.transformer.config.patch_size) != 0
        ):
            logger.warning(
                f"`height` and `width` have to be divisible by {self.vae_scale_factor * 2} but are {height} and {width}. Dimensions will be resized accordingly"
            )

        if callback_on_step_end_tensor_inputs is not None and not all(
            k in self._callback_tensor_inputs
            for k in callback_on_step_end_tensor_inputs
        ):
            raise ValueError(
                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]}"
            )

        if prompt is not None and prompt_embeds is not None:
            raise ValueError(
                f"Cannot forward both `prompt`: {prompt} and `prompt_embeds`: {prompt_embeds}. Please make sure to"
                " only forward one of the two."
            )
        elif prompt is None and prompt_embeds is None:
            raise ValueError(
                "Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined."
            )
        elif prompt is not None and (
            not isinstance(prompt, str) and not isinstance(prompt, list)
        ):
            raise ValueError(
                f"`prompt` has to be of type `str` or `list` but is {type(prompt)}"
            )

View on GitHub (pinned to 0132848349)

Solutions

  1. Print self._callback_tensor_inputs and restrict your list to those names
  2. Fix typos/renamed keys (commonly latents, prompt_embeds, negative_prompt_embeds)
  3. Pass None to use the callback without extra tensor inputs

Example fix

# before
pipe(prompt="a cat", callback_on_step_end=cb, callback_on_step_end_tensor_inputs=["latentss"])

# after
pipe(prompt="a cat", callback_on_step_end=cb, callback_on_step_end_tensor_inputs=["latents"])
Defensive patterns

Strategy: type-guard

Validate before calling

valid = set(stage._callback_tensor_inputs)
keys = [k for k in callback_on_step_end_tensor_inputs or [] if k in valid]
pipe(prompt=p, callback_on_step_end=cb, callback_on_step_end_tensor_inputs=keys or None)

Type guard

def valid_tensor_inputs(stage, requested) -> list:
    return [k for k in requested if k in stage._callback_tensor_inputs]

Try / catch

except ValueError as e:
    if "callback_on_step_end_tensor_inputs" in str(e):
        retry_with_filtered_keys()  # intersect with _callback_tensor_inputs
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/688547c626e4b0d2. Report an issue: GitHub.