sgl-project/sglang · error · ValueError

action_mode='forward_dynamics' requires an 'action' array (l

Error message

action_mode='forward_dynamics' requires an 'action' array (list[list[float]] of shape [T, D]).

What it means

forward_dynamics mode conditions action generation on a supplied action trajectory. If sampling_params.action is None (absent), the stage cannot build action latents and raises before tensor conversion.

Source

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

        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)
            if embodiment:
                raw_action_dim = get_raw_action_dim(embodiment)

        if mode == ACTION_MODE_FORWARD_DYNAMICS:
            raw = getattr(sp, "action", None)
            if raw is None:
                raise ValueError(
                    "action_mode='forward_dynamics' requires an 'action' array "
                    "(list[list[float]] of shape [T, D])."
                )
            if isinstance(raw, str):
                raw = json.loads(raw)
            action = torch.as_tensor(np.asarray(raw), dtype=torch.float32)
            if action.ndim == 3 and action.shape[0] == 1:
                action = action.squeeze(0)
            if action.ndim != 2:
                raise ValueError(
                    f"action must have shape [T, D], got {tuple(action.shape)}"
                )
            if action.shape[0] < action_chunk_size:
                pad = action[-1:].repeat(action_chunk_size - action.shape[0], 1)
                action = torch.cat([action, pad], dim=0)
            elif action.shape[0] > action_chunk_size:
                action = action[:action_chunk_size]
            if raw_action_dim is None:

View on GitHub (pinned to 0132848349)

Solutions

  1. Provide sp.action as a [T, D] float array (or JSON string of it)
  2. Switch to a mode that doesn't need actions, e.g. 'policy' or 'inverse_dynamics'
  3. Ensure your request schema makes 'action' required when mode is forward_dynamics

Example fix

# before
sp.action_mode = 'forward_dynamics'

# after
sp.action_mode = 'forward_dynamics'
sp.action = [[0.0, 1.0, 0.0]] * 16  # [T, D]
Defensive patterns

Strategy: validation

Validate before calling

if str(sp.action_mode).strip().lower() == 'forward_dynamics':
    assert getattr(sp, 'action', None) is not None, 'forward_dynamics requires sp.action'

Type guard

def has_action_payload(sp) -> bool:
    return getattr(sp, 'action', None) is not None

Prevention

When it happens

Trigger: Setting action_mode='forward_dynamics' without providing sp.action (a list[list[float]] of shape [T, D], possibly JSON-encoded).

Common situations: Porting from a mode that didn't need actions (e.g. 'policy'), or forgetting to attach the recorded trajectory from a robot rollout.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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