sgl-project/sglang · error · ValueError
SANA-WM stage-1 expects exactly one Gemma-2 text encoder.
Error message
SANA-WM stage-1 expects exactly one Gemma-2 text encoder.
What it means
Raised by the stage-1 forward when self.text_encoders does not contain exactly one entry. SANA-WM's first stage is hardwired to a single Gemma-2 text encoder for prompt embedding.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:691
dim=0,
)
index[seq_dim] = select
return tensor[tuple(index)]
@staticmethod
def _seq_lens_from_masks(masks: list[torch.Tensor | None]) -> list[list[int]]:
seq_lens = []
for mask in masks:
if mask is None:
seq_lens.append([])
else:
seq_lens.append([int(x) for x in mask.long().sum(dim=-1).tolist()])
return seq_lens
@torch.no_grad()
def forward(self, batch: Req, server_args: ServerArgs) -> Req:
if len(self.text_encoders) != 1:
raise ValueError(
"SANA-WM stage-1 expects exactly one Gemma-2 text encoder."
)
assert batch.prompt is not None
max_length = self._text_encoder_max_length(server_args)
chi_prompt = self._chi_prompt(server_args)
prompt_text = batch.prompt
if isinstance(prompt_text, str):
prompt_text = [prompt_text]
else:
prompt_text = list(prompt_text)
tokenizer = self.tokenizers[0]
if chi_prompt:
prompt_text = [chi_prompt + text for text in prompt_text]
max_length_all = len(tokenizer.encode(chi_prompt)) + max_length - 2
else:
max_length_all = max_lengthView on GitHub (pinned to 0132848349)
Solutions
- Ensure exactly one Gemma-2 text encoder is loaded/registered for the stage
- Check encoder loading logs for silent failures leaving the list empty
- Fix the model config to include only the Gemma-2 text encoder for stage 1
Defensive patterns
Strategy: validation
Validate before calling
assert len(stage.text_encoders) == 1, f'got {len(stage.text_encoders)} text encoders' Prevention
- Assert encoder count during pipeline init, not per request
- Log which encoders registered at startup
When it happens
Trigger: Configuring the pipeline with zero text encoders (missing/failed model load) or multiple text encoders, then running a request through the SANA-WM stage-1 forward.
Common situations: Model config lists multiple encoders (e.g. adding a second text tower) or the Gemma-2 encoder failed to register during init; misconfigured encoder list in server args.
Related errors
- SANA-WM refiner text encoder must return per-layer hidden_st
- Helion KDA decode requires power-of-two key and value head d
- `A_log` must have {HV} elements (got {A_log.numel()}).
- `dt_bias` must have {HV * K} elements (got {dt_bias.numel()}
- Unsupported text encoder output: expected `hidden_states`.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/1bd558501bbd1b8a.
Report an issue: GitHub.