sgl-project/sglang · error · TypeError

MiniMax H3 text_encoder component must expose callable encod

Error message

MiniMax H3 text_encoder component must expose callable encode_ids(...) for direct encode (MiniMaxH3Qwen3VLEncoder)

What it means

The direct encode path calls text_encoder.encode_ids(...); if the loaded text_encoder object does not expose a callable encode_ids attribute, this TypeError fires. It guards against wrong encoder classes being installed under the text_encoder slot.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/text_encoding.py:281

                raise ValueError(
                    "MiniMax H3 text encoding requires an ordered keyframe signature "
                    f"in {MINIMAX_H3_FL2VA_KEYFRAME_SIGNATURES!r}, got "
                    f"{frame_indices!r}"
                )
        elif keyframes:
            raise ValueError(
                f"task {plan.task!r} cannot carry image.target_canvas materials"
            )
        if MINIMAX_H3_TEXT_EMBEDDINGS_EXTRA_KEY in batch.extra:
            return
        if self.text_encoder is None:
            raise ValueError(
                "MiniMaxH3TextEncodingStage direct encode requires a text_encoder "
                "component"
            )
        encode_ids = getattr(self.text_encoder, "encode_ids", None)
        if not callable(encode_ids):
            raise TypeError(
                "MiniMax H3 text_encoder component must expose callable "
                "encode_ids(...) for direct encode (MiniMaxH3Qwen3VLEncoder)"
            )
        if self.tokenizer is None:
            raise ValueError(
                "MiniMaxH3TextEncodingStage direct encode requires a tokenizer component"
            )
        with set_forward_context(current_timestep=0, attn_metadata=None):
            if plan.task == "ref2va":
                embeddings = self._encode_ref2va(
                    batch,
                    plan,
                    encode_ids,
                    include_video_token_mask=include_video_token_mask,
                )
            elif keyframes:
                embeddings = self._encode_fl2va_keyframes(
                    batch,

View on GitHub (pinned to 0132848349)

Solutions

  1. Use MiniMaxH3Qwen3VLEncoder (which exposes encode_ids) as the text_encoder component
  2. Upgrade/downgrade to a consistent sglang version where the encoder wrapper matches this stage
  3. For tests, provide a stub with a callable encode_ids
Defensive patterns

Strategy: type-guard

Validate before calling

if not callable(getattr(text_encoder, "encode_ids", None)):
    raise TypeError("need MiniMaxH3Qwen3VLEncoder, got " + type(text_encoder).__name__)

Type guard

def is_qwen3vl_direct_encoder(enc) -> bool:
    return callable(getattr(enc, "encode_ids", None))

Prevention

When it happens

Trigger: _encode_from_plan does getattr(self.text_encoder, 'encode_ids', None) and the result is not callable — e.g. a plain Qwen3VLModel or a wrapper lacking the MiniMaxH3Qwen3VLEncoder.encode_ids API was used as the component.

Common situations: Swapping in a vanilla transformers Qwen3VL encoder instead of the MiniMax H3 wrapper, version skew where encode_ids was renamed, or a mock/stub component in tests.

Related errors


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