sgl-project/sglang · error · ValueError

SANA-WM denoising requires positive prompt embeds.

Error message

SANA-WM denoising requires positive prompt embeds.

What it means

Raised by the SANA-WM denoising forward when the positive prompt embeds are None — the text-encoder stage did not produce prompt embeddings on the batch.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:861

        if timesteps is None:
            raise ValueError("SANA-WM denoising requires prepared timesteps.")
        timesteps = timesteps.to(device=device)

        latents = batch.latents.to(device=device, dtype=target_dtype)
        init_latents = latents.clone()
        condition_mask = torch.zeros_like(latents)
        condition_mask[:, :, :1] = 1

        pos_embeds = _to_device_dtype(
            _first_tensor(server_args.pipeline_config.get_pos_prompt_embeds(batch)),
            device=device,
            dtype=target_dtype,
        )
        pos_mask = _to_device_dtype(
            _first_tensor(batch.prompt_attention_mask), device=device
        )
        if pos_embeds is None:
            raise ValueError("SANA-WM denoising requires positive prompt embeds.")

        do_cfg = bool(batch.do_classifier_free_guidance)
        neg_embeds = None
        neg_mask = None
        if do_cfg:
            neg_embeds = _to_device_dtype(
                _first_tensor(server_args.pipeline_config.get_neg_prompt_embeds(batch)),
                device=device,
                dtype=target_dtype,
            )
            neg_mask = _to_device_dtype(
                _first_tensor(batch.negative_attention_mask), device=device
            )
            if neg_embeds is None:
                raise ValueError("SANA-WM CFG requires negative prompt embeds.")

            pos_embeds, neg_embeds, pos_mask, neg_mask = (
                _align_sana_wm_cfg_text_conditions(

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure the stage-1 Gemma-2 text encoding stage runs before denoising
  2. Verify the prompt is non-empty and embeds are attached to the batch
  3. Check for silent failures in the text encoder stage logs
Defensive patterns

Strategy: validation

Validate before calling

assert _first_tensor(batch.prompt_embeds) is not None

Type guard

def has_prompt_embeds(batch) -> bool:
    return getattr(batch, 'prompt_embeds', None) is not None

Prevention

When it happens

Trigger: Running denoising when batch prompt embeds (e.g. batch.prompt_embeds / equivalent) are missing, because the stage-1 text encoder stage did not run or failed to attach embeds.

Common situations: Text encoder stage skipped or run after denoising; prompt was empty and embeds were never generated; field name mismatch leaving embeds unset.

Related errors


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