sgl-project/sglang · error · ValueError

No raw action dim for Cosmos3 embodiment {embodiment!r}. Exp

Error message

No raw action dim for Cosmos3 embodiment {embodiment!r}. Expected one of {sorted(EMBODIMENT_TO_RAW_ACTION_DIM)}.

What it means

get_raw_action_dim maps an embodiment name (robot) to its raw action dimension via the EMBODIMENT_TO_RAW_ACTION_DIM table. Unknown or misspelled embodiment strings raise a ValueError listing all supported keys (compared after lower().strip()).

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_action.py:104

        "16,9": (1280, 720),
        "9,16": (720, 1280),
    },
}

VIEWPOINT_TEMPLATES: dict[str, str] = {
    "ego_view": "This video is captured from a first-person perspective looking at the scene.",
    "third_person_view": "This video is captured from a third-person perspective looking towards the agent from the front.",
    "wrist_view": "This video is captured from a wrist-mounted camera.",
    "concat_view": "This video contains concatenated views from multiple camera perspectives.",
}

_STAT_KEYS = {"mean", "std", "min", "max", "q01", "q99"}


def get_raw_action_dim(embodiment: str) -> int:
    key = embodiment.lower().strip()
    if key not in EMBODIMENT_TO_RAW_ACTION_DIM:
        raise ValueError(
            f"No raw action dim for Cosmos3 embodiment {embodiment!r}. Expected one "
            f"of {sorted(EMBODIMENT_TO_RAW_ACTION_DIM)}."
        )
    return EMBODIMENT_TO_RAW_ACTION_DIM[key]


def canonical_aspect_ratio(width: int, height: int) -> str:
    """Canonical ``"W,H"`` aspect string for the action caption."""
    for sizes in VIDEO_RES_SIZE_INFO.values():
        for aspect, (cand_w, cand_h) in sizes.items():
            if width == cand_w and height == cand_h:
                return aspect
    divisor = math.gcd(width, height)
    if divisor == 0:
        raise ValueError(
            f"width and height must be non-zero, got width={width}, height={height}."
        )
    return f"{width // divisor},{height // divisor}"

View on GitHub (pinned to 0132848349)

Solutions

  1. Use an embodiment string exactly matching a key in EMBODIMENT_TO_RAW_ACTION_DIM (inspect the table or the error's sorted list)
  2. If a new robot, add its entry to EMBODIMENT_TO_RAW_ACTION_DIM in cosmos3_action.py and pass --raw-action-dim explicitly to bypass lookup
  3. Validate/normalize embodiment names at the request boundary

Example fix

# before
embodiment = "Franka Panda"
# after
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.cosmos3_action import EMBODIMENT_TO_RAW_ACTION_DIM
embodiment = next(iter(EMBODIMENT_TO_RAW_ACTION_DIM))  # a valid key, e.g. 'franka-panda'
Defensive patterns

Strategy: type-guard

Validate before calling

from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.cosmos3_action import EMBODIMENT_TO_RAW_ACTION_DIM
embodiment = embodiment.lower().strip()
assert embodiment in EMBODIMENT_TO_RAW_ACTION_DIM, f"unknown embodiment; valid: {sorted(EMBODIMENT_TO_RAW_ACTION_DIM)}"

Type guard

def is_known_embodiment(name: str) -> bool:
    from ...cosmos3_action import EMBODIMENT_TO_RAW_ACTION_DIM
    return name.lower().strip() in EMBODIMENT_TO_RAW_ACTION_DIM

Try / catch

try:
    dim = get_raw_action_dim(embodiment)
except ValueError:
    dim = fallback_dim  # e.g. from --raw-action-dim

Prevention

When it happens

Trigger: Calling a Cosmos3 action request with embodiment='FrankaPanda ' or any string not in EMBODIMENT_TO_RAW_ACTION_DIM; the stage calls get_raw_action_dim during _prepare_action_latents.

Common situations: Typos or casing/whitespace variants that survive lower().strip() (e.g. 'franka_panda' vs 'franka-panda'); adding a new robot without registering its dimension in the table; API users guessing embodiment names.

Related errors


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