sgl-project/sglang · error · ValueError
MiniMax H3 text payload positive.text_len must match the hid
Error message
MiniMax H3 text payload positive.text_len must match the hidden-state sequence dimension
What it means
The payload's positive.text_len must be an int equal to hidden_states.shape[0] (the sequence dimension). This check keeps prompt_seq_lens consistent with the embeddings actually published to batch.prompt_embeds; any mismatch means the payload is internally inconsistent.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/text_encoding.py:231
H3 keeps token tags and presentation metadata in ``Req.extra``, but
the shared TextEncodingStage contract still owns ``prompt_embeds``.
Publishing the same tensor there preserves native verification,
grouped-request deduplication, and downstream memory accounting
without duplicating the embedding storage.
"""
payload = batch.extra.get(MINIMAX_H3_TEXT_EMBEDDINGS_EXTRA_KEY)
positive = payload.get("positive") if isinstance(payload, dict) else None
hidden_states = (
positive.get("hidden_states") if isinstance(positive, dict) else None
)
text_len = positive.get("text_len") if isinstance(positive, dict) else None
if not isinstance(hidden_states, torch.Tensor) or hidden_states.ndim < 2:
raise ValueError(
"MiniMax H3 text payload must contain positive.hidden_states "
"with at least two dimensions"
)
if not isinstance(text_len, int) or text_len != int(hidden_states.shape[0]):
raise ValueError(
"MiniMax H3 text payload positive.text_len must match the "
"hidden-state sequence dimension"
)
batch.prompt_embeds = [hidden_states]
batch.prompt_seq_lens = [[text_len]]
def _encode_from_plan(
self,
batch: Req,
plan,
*,
include_video_token_mask: bool = False,
) -> None:
"""Encode the positive Qwen3VL presentation into layer-50 states.
MiniMax H3 only supports the CFG-distilled model path, so every task
emits exactly one positive embedding payload. ComponentManager owns
residency/offload, while every folded-TP rank enters the encoderView on GitHub (pinned to 0132848349)
Solutions
- Recompute text_len from the final tensor: int(hidden_states.shape[0]) and set it in the payload
- Convert tensor/float text_len values to int before publishing
- Avoid mutating hidden_states after the encoder computed text_len
Example fix
// before payload["positive"]["text_len"] = old_len # before truncation // after hs = payload["positive"]["hidden_states"] payload["positive"]["text_len"] = int(hs.shape[0])
Defensive patterns
Strategy: validation
Validate before calling
hs = payload["positive"]["hidden_states"] payload["positive"]["text_len"] = int(hs.shape[0]) # keep consistent before publish
Type guard
def text_len_matches(payload) -> bool:
pos = payload.get("positive", {})
tl, hs = pos.get("text_len"), pos.get("hidden_states")
return isinstance(tl, int) and isinstance(hs, torch.Tensor) and tl == hs.shape[0] Prevention
- Recompute text_len after any slicing/padding of embeddings
- Store text_len as a Python int, not a tensor
When it happens
Trigger: _publish_native_text_conditioning finds text_len missing (None), a non-int (e.g. tensor or float), or an int different from hidden_states.shape[0] — e.g. embeddings truncated/padded after text_len was computed.
Common situations: Post-processing embeddings (slicing, pooling, padding) without updating text_len; encoders returning text_len as a 0-d tensor instead of int; chunked encodes appending tokens after length was recorded.
Related errors
- prompt must be non-empty
- MiniMax H3 text encode produced no native payload
- MiniMax H3 text encode failed on rank {owner}: {owner_error}
- MiniMax H3 text payload must contain positive.hidden_states
- MiniMaxH3TextEncodingStage direct encode requires a text_enc
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/02bcd076690fe2c9.
Report an issue: GitHub.