sgl-project/sglang · error · ValueError

Unsupported action_mode=

Error message

Unsupported action_mode={sp.action_mode!r}; expected one of {sorted(ACTION_MODES)}

What it means

_prepare_action_latents normalizes action_mode (strip+lower) and checks membership in the ACTION_MODES set, which contains 'policy', 'inverse_dynamics', and 'forward_dynamics'. Anything else, including typos or unnormalized variants that still fail, is rejected with the sorted valid list.

Solutions

  1. Use one of the exact modes from the error message (e.g. 'policy', 'forward_dynamics', 'inverse_dynamics')
  2. Check for casing/whitespace; the code lowercases and strips, so only the name itself matters
  3. If action generation isn't wanted, remove action_mode entirely

Example fix

# before
sp.action_mode = 'ForwardDynamics'

# after
sp.action_mode = 'forward_dynamics'
Defensive patterns

Strategy: validation

Validate before calling

from ... import ACTION_MODES
assert str(sp.action_mode).strip().lower() in ACTION_MODES

Type guard

def is_valid_action_mode(mode: str, modes: set) -> bool:
    return mode.strip().lower() in modes

Prevention

When it happens

Trigger: Passing sampling_params.action_mode not in ACTION_MODES, e.g. 'Prediction', 'fd', or 'policy_v2'.

Common situations: Guessing mode names from another library, casing/typo issues, or stale names after an API rename.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

        device: torch.device,
        dtype: torch.dtype,
    ) -> None:
        """Prepare action latents and conditioning, writing them onto ``batch``.

        Action tokens run at frame rate (no temporal compression), so the chunk
        length is ``num_frames - 1`` with ``start_frame_offset=1`` so each action
        aligns with the frame it drives.

        Three modes:
        - ``forward_dynamics``: the user supplies the action; all tokens are
          clean conditioning (velocity mask 0) and the model predicts video.
        - ``policy`` / ``inverse_dynamics``: actions are denoised from noise
          (velocity mask 1); ``raw_action_dim`` is required.
        """
        sp = batch.sampling_params
        mode = str(sp.action_mode).strip().lower()
        if mode not in ACTION_MODES:
            raise ValueError(
                f"Unsupported action_mode={sp.action_mode!r}; "
                f"expected one of {sorted(ACTION_MODES)}"
            )
        action_dim = self.transformer.action_dim
        num_frames = batch.num_frames

        action_chunk_size = num_frames - 1 if num_frames > 1 else 1
        action_offset = 1 if action_chunk_size == num_frames - 1 else 0

        domain_id = self._resolve_domain_id(batch)
        batch_dim = (
            int(batch.raw_latent_shape[0])
            if getattr(batch, "raw_latent_shape", None)
            else 1
        )
        raw_action_dim = getattr(sp, "raw_action_dim", None)
        if raw_action_dim is None:
            embodiment = getattr(sp, "domain_name", None)

View on GitHub (pinned to 0132848349)