sgl-project/sglang · error · ValueError

fl2va Qwen preparation requires one or two ordered images wi

Error message

fl2va Qwen preparation requires one or two ordered images with a supported semantic_frame_indices signature, got {frame_indices!r}

What it means

For fl2va keyframe encoding, prepared['semantic_frame_indices'] must be one of the supported signatures AND the number of prepared images must equal len(frame_indices). This ValueError catches malformed keyframe preparation — mismatched image/index counts or unsupported index tuples.

Source

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

        *,
        prompt: str,
    ) -> dict:
        from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minimax_h3.canvas import (
            minimax_h3_prepared_keyframes,
        )
        from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minimax_h3.presentation import (
            minimax_h3_multi_image_presentation,
        )

        # The SAME prepared target-canvas images feed
        # Qwen and the visual-condition tokenizer; preparation is cached per request.
        prepared = minimax_h3_prepared_keyframes(batch, plan)
        images = [item["image"] for item in prepared["images"]]
        frame_indices = tuple(prepared.get("semantic_frame_indices") or ())
        if frame_indices not in MINIMAX_H3_FL2VA_KEYFRAME_SIGNATURES or len(
            images
        ) != len(frame_indices):
            raise ValueError(
                "fl2va Qwen preparation requires one or two ordered images with "
                "a supported semantic_frame_indices signature, got "
                f"{frame_indices!r}"
            )
        processor = self.processor
        vision = processor.image_processor(images=images, return_tensors="pt")
        pixel_values = vision["pixel_values"]
        image_grid_thw = vision["image_grid_thw"]
        if int(image_grid_thw.shape[0]) != len(images):
            raise ValueError(
                f"expected {len(images)} image grids, got {list(image_grid_thw.shape)}"
            )
        merge = int(processor.image_processor.merge_size) ** 2
        image_token_counts = [
            int(image_grid_thw[i].prod().item()) // merge for i in range(len(images))
        ]
        pos_ids, pos_tags = minimax_h3_multi_image_presentation(
            self.tokenizer,

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure the request's keyframes produce a supported signature (e.g. (0,) or (0, last)) with exactly matching image count
  2. Check the output of minimax_h3_prepared_keyframes for the failing request and fix index propagation upstream
  3. Rebuild the request through the canonical fl2va request builder
Defensive patterns

Strategy: validation

Validate before calling

prepared = minimax_h3_prepared_keyframes(batch, plan)
idx = tuple(prepared.get("semantic_frame_indices") or ())
assert idx in MINIMAX_H3_FL2VA_KEYFRAME_SIGNATURES and len(prepared["images"]) == len(idx), idx

Type guard

def prepared_keyframes_valid(prepared) -> bool:
    idx = tuple(prepared.get("semantic_frame_indices") or ())
    return idx in MINIMAX_H3_FL2VA_KEYFRAME_SIGNATURES and len(prepared["images"]) == len(idx)

Prevention

When it happens

Trigger: _encode_fl2va_keyframes gets a prepared dict where semantic_frame_indices is empty/unsupported, or images length differs from the indices length (e.g. 2 images with one index, or indices () with 1 image).

Common situations: minimax_h3_prepared_keyframes returning inconsistent structures for edge-case requests (single image with no indices), upstream preparation bugs, or hand-built prepared dicts in tests.

Related errors


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