sgl-project/sglang · error · ValueError

Conditioning (prompt_embeds) must be provided

Error message

Conditioning (prompt_embeds) must be provided

What it means

The denoising loop needs conditioning embeddings (batch.prompt_embeds) produced by the image encoder stage from the input image. If prompt_embeds is empty or its first element is None, the DiT has no conditioning signal and the stage aborts. cond = batch.prompt_embeds[0] if batch.prompt_embeds else None.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/hunyuan3d/shape.py:332

        freshly_loaded = load_transformer_if_needed(self, server_args)
        if freshly_loaded:
            self._maybe_enable_cache_dit(cache_dit_num_inference_steps, batch)
            self._maybe_torch_compile(self.transformer)
            register_loaded_transformer(self, server_args, pipeline)
        else:
            self._maybe_enable_cache_dit(cache_dit_num_inference_steps, batch)

        timesteps = batch.timesteps
        if timesteps is None:
            raise ValueError("Timesteps must be provided")

        latents = batch.latents
        if latents is None:
            raise ValueError("Latents must be provided")

        cond = batch.prompt_embeds[0] if batch.prompt_embeds else None
        if cond is None:
            raise ValueError("Conditioning (prompt_embeds) must be provided")

        if batch.raw_latent_shape is None:
            batch.raw_latent_shape = latents.shape

        guidance = batch.extra.get("shape_guidance")
        num_inference_steps = batch.num_inference_steps
        num_warmup_steps = len(timesteps) - num_inference_steps * scheduler.order

        extra_step_kwargs = self.prepare_extra_func_kwargs(
            scheduler.step,
            {"generator": batch.generator, "eta": batch.eta},
        )

        target_dtype = next(self.transformer.parameters()).dtype
        autocast_enabled = False

        pos_cond_kwargs = {"encoder_hidden_states": cond}
        neg_cond_kwargs = {}

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure the image/condition encoding stage runs before the Hunyuan3D denoising stage and writes batch.prompt_embeds
  2. Check upstream encoder logs for silent failures (unloadable image, dtype/device errors) and fix those
  3. Populate prompt_embeds manually in tests: batch.prompt_embeds = [encoder(image)]

Example fix

# before
batch.prompt_embeds = []

# after
batch.prompt_embeds = [image_encoder.encode(pil_image)]  # non-empty tensor
Defensive patterns

Strategy: validation

Validate before calling

if not batch.prompt_embeds or batch.prompt_embeds[0] is None:
    raise ValueError("run image encoding stage first") from None

Type guard

def has_conditioning(batch) -> bool:
    pe = getattr(batch, "prompt_embeds", None)
    return bool(pe) and pe[0] is not None

Prevention

When it happens

Trigger: Running the denoising stage without the preceding image-encoding stage; the encoder stage produced an empty list; manual batch construction that skips prompt_embeds; image path invalid so encoder emitted nothing.

Common situations: Pipeline composition missing the image-encoder stage; upstream encoder silently failed (bad image, OOM) and forwarded an empty embedding list; test harness omitting embeddings; field renamed during refactor.

Related errors


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