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
SANA-WM stage-1 expects exactly one Gemma-2 text encoder in the pipeline. Fix the encoder configuration.
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…
- A GGUF encoder checkpoint cannot be combined with a second…
- `A_log` must have elements (got ).
- A quantized checkpoint requires an in-tree native encoder…
- A quantized checkpoint requires an in-tree native encoder…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/1bd558501bbd1b8a.
Report an issue: GitHub.
Appendix: 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)