sgl-project/sglang · error · ValueError

Cosmos3 accepts either --image-path (I2V) or --video-path (V

Error message

Cosmos3 accepts either --image-path (I2V) or --video-path (V2V), not both

What it means

The Cosmos3 stage accepts exactly one conditioning modality: an image for image-to-video (I2V) or a video for video-to-video (V2V). Supplying both image_path and video_path is ambiguous, so the stage rejects the request up front.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py:171

    def verify_input(self, batch: Req, server_args: ServerArgs) -> VerificationResult:
        return VerificationResult()

    def forward(self, batch: Req, server_args: ServerArgs) -> Req:
        image_path = batch.image_path
        video_path = batch.video_path
        is_action_policy = (
            batch.data_type == DataType.ACTION
            and getattr(batch.sampling_params, "action_mode", None)
            == ACTION_MODE_POLICY
        )
        if isinstance(image_path, list) and not is_action_policy:
            image_path = image_path[0] if image_path else None
        if isinstance(video_path, list):
            video_path = video_path[0] if video_path else None

        if image_path and video_path:
            raise ValueError(
                "Cosmos3 accepts either --image-path (I2V) or --video-path "
                "(V2V), not both"
            )

        target_h, target_w = batch.height, batch.width

        if image_path is not None:
            image_sources = (
                list(image_path)
                if isinstance(image_path, (list, tuple))
                else [image_path]
            )
            if not image_sources:
                raise ValueError("Cosmos3 I2V image list is empty")
            tensors: list[torch.Tensor] = []
            for src in image_sources:
                image = load_image(src)
                image = _resize_crop_pil(image, target_w, target_h)

View on GitHub (pinned to 0132848349)

Solutions

  1. Send only image_path for I2V, or only video_path for V2V
  2. In shared client code, gate the fields: set video_path=None when doing I2V and vice versa
  3. Add a client-side assert that at most one of the two is non-None

Example fix

# before
req = {"image_path": "cat.jpg", "video_path": "cat.mp4", "prompt": "..."}
# after
req = {"image_path": "cat.jpg", "video_path": None, "prompt": "..."}  # I2V
Defensive patterns

Strategy: validation

Validate before calling

assert not (req.get("image_path") and req.get("video_path")), "pass image_path XOR video_path"

Type guard

def single_conditioning(req) -> bool:
    return bool(req.get("image_path")) != bool(req.get("video_path"))

Prevention

When it happens

Trigger: A request where both image_path and video_path resolve to truthy values after list-normalization (each list is reduced to its first element) in Cosmos3 preprocessing — e.g. a client template that always populates both fields.

Common situations: A generic multimodal client that sets both image and video placeholders; stale request payloads from a previous experiment; passing a video with a thumbnail/first-frame image expecting them to be combined.

Related errors


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