{"record":{"id":"0a4c04c4819f8cf6","repo":"sgl-project/sglang","slug":"action-mode-mode-r-requires-raw-action-dim","errorCode":null,"errorMessage":"action_mode={mode!r} requires --raw-action-dim.","messagePattern":"action_mode=(.+?) requires --raw-action-dim\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py","lineNumber":727,"sourceCode":"                )\n            if action.shape[0] < action_chunk_size:\n                pad = action[-1:].repeat(action_chunk_size - action.shape[0], 1)\n                action = torch.cat([action, pad], dim=0)\n            elif action.shape[0] > action_chunk_size:\n                action = action[:action_chunk_size]\n            if raw_action_dim is None:\n                raw_action_dim = int(action.shape[-1])\n            stats_path = getattr(sp, \"action_stats_path\", None)\n            if stats_path is not None:\n                method = getattr(sp, \"action_normalization\", \"quantile\")\n                action = normalize_action(action, method, load_action_stats(stats_path))\n            if action.shape[-1] < action_dim:\n                pad = torch.zeros(action.shape[0], action_dim - action.shape[-1])\n                action = torch.cat([action, pad], dim=-1)\n            clean_action = action.to(device=device, dtype=dtype).unsqueeze(0)\n        else:\n            if raw_action_dim is None:\n                raise ValueError(f\"action_mode={mode!r} requires --raw-action-dim.\")\n            clean_action = torch.zeros(\n                batch_dim, action_chunk_size, action_dim, device=device, dtype=dtype\n            )\n\n        raw_action_dim = int(raw_action_dim)\n        if not 0 < raw_action_dim <= action_dim:\n            raise ValueError(\n                f\"raw_action_dim must be in [1, {action_dim}], got {raw_action_dim}\"\n            )\n\n        # condition_mask marks clean (given) action tokens. forward_dynamics\n        # conditions on the whole action sequence; the others denoise it fully.\n        condition_mask = torch.zeros(\n            batch_dim, action_chunk_size, 1, device=device, dtype=dtype\n        )\n        if mode == ACTION_MODE_FORWARD_DYNAMICS:\n            condition_mask[:] = 1.0\n","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py#L709-L745","documentation":"Raised by Cosmos3's _prepare_action_latents when an action-mode request (e.g. action-dynamics) carries no inline action tensor, so the stage must synthesize a placeholder clean-action tensor, but no --raw-action-dim was supplied. The raw action dim is needed to size the zero-filled action chunk. It is a configuration error: the CLI/server args omitted a required flag for the chosen action_mode.","triggerScenarios":"Sending a request whose action_mode implies generated/clean actions without an input action array, while launching the server without --raw-action-dim; _prepare_action_latents takes the else-branch that builds torch.zeros(batch, chunk, action_dim).","commonSituations":"Switching a Cosmos3 world-model pipeline from video-only to action-conditioned generation without adding the new CLI flag; copying an old launch script after upgrading to an action-aware sglang version.","solutions":["Add --raw-action-dim <N> to the server launch args, matching your embodiment's action dimension (see EMBODIMENT_TO_RAW_ACTION_DIM in cosmos3_action.py)","Or pass an explicit action tensor in the request so the padding branch is used instead","Verify server_args.pipeline_config actually propagates the flag to the stage"],"exampleFix":"# before\npython -m sglang.launch_server --model cosmos3 --action-mode dynamics\n# after\npython -m sglang.launch_server --model cosmos3 --action-mode dynamics --raw-action-dim 7","handlingStrategy":"validation","validationCode":"from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.cosmos3_action import get_raw_action_dim\nassert server_args.raw_action_dim is not None or request_has_inline_actions(req), \"--raw-action-dim required for this action_mode\"","typeGuard":"def has_raw_action_dim(args) -> bool:\n    return getattr(args, \"raw_action_dim\", None) is not None","tryCatchPattern":null,"preventionTips":["Keep a launch-arg checklist per modality: action requests need --raw-action-dim","Prefer sending explicit action tensors when the client already has them","Add a startup sanity check that fails fast when action_mode is set without raw_action_dim"],"tags":["cosmos3","action-conditioning","server-args","configuration"],"backgroundTag":"missing-required-config-option","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}