sgl-project/sglang · error · ValueError
SANA-WM CFG requires negative prompt embeds.
Error message
SANA-WM CFG requires negative prompt embeds.
What it means
Raised by the SANA-WM denoising forward when classifier-free guidance is enabled (batch.do_classifier_free_guidance) but negative prompt embeds are None. CFG needs both positive and negative text conditions.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:876
_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(
pos_embeds, neg_embeds, pos_mask, neg_mask
)
)
extra = batch.extra or {}
diffusers_kwargs = extra.get("diffusers_kwargs", {})
if not isinstance(diffusers_kwargs, dict):
diffusers_kwargs = {}
chunk_kwargs = {}
for key in ("chunk_index", "chunk_size", "chunk_split_strategy"):
value = extra.get(key, diffusers_kwargs.get(key))
if value is not None:
chunk_kwargs[key] = value
camera_conditions = _to_device_dtype(
extra.get("camera_conditions"), device=device, dtype=target_dtypeView on GitHub (pinned to 0132848349)
Solutions
- Provide a negative prompt (even a plain '' encoded through the text encoder) so embeds exist
- Or disable CFG: set do_classifier_free_guidance=False on the request
- Ensure the text stage encodes both positive and negative prompts when CFG is on
Example fix
# before request.do_classifier_free_guidance = True # no negative prompt set # after request.negative_prompt = request.negative_prompt or '' request.do_classifier_free_guidance = bool(request.negative_prompt)
Defensive patterns
Strategy: validation
Validate before calling
if batch.do_classifier_free_guidance:
assert _first_tensor(batch.negative_prompt_embeds) is not None Type guard
def cfg_ready(batch) -> bool:
return not batch.do_classifier_free_guidance or getattr(batch, 'negative_prompt_embeds', None) is not None Prevention
- Auto-disable CFG when no negative prompt is supplied
- Always encode an empty-string negative prompt when CFG is on
When it happens
Trigger: Enabling CFG on a request that has no negative prompt, or where the negative prompt embeds were not computed/attached by the text stage.
Common situations: do_classifier_free_guidance defaults true while negative_prompt is empty; negative-prompt encoding branch skipped; field name mismatch for negative embeds.
Related errors
- SANA-WM streaming CFG requires negative prompt embeds.
- For classifier-free guidance, either `negative_prompt` or `n
- SANA-WM height/width must be divisible by the LTX-2 spatial
- SANA-WM plucker_embedder is not initialized.
- plucker_emb token count {plucker_emb.shape[1]} != latent tok
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/490c3a63bcf1b819.
Report an issue: GitHub.