{"record":{"id":"7bdc04d49461a610","repo":"sgl-project/sglang","slug":"raw-action-dim-must-be-in-1-action-dim-got","errorCode":null,"errorMessage":"raw_action_dim must be in [1, {action_dim}], got {raw_action_dim}","messagePattern":"raw_action_dim must be in \\[1, (.+?)\\], got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py","lineNumber":734,"sourceCode":"                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\n        noise = torch.randn(\n            batch_dim,\n            action_chunk_size,\n            action_dim,\n            generator=generator,\n            device=device,\n            dtype=dtype,","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py#L716-L752","documentation":"Cosmos3 validates that --raw-action-dim lies in (0, action_dim], where action_dim is the model's internal action latent dimension. A value of 0, negative, or larger than action_dim breaks the projection from raw action space into latents, so it is rejected with a ValueError before tensor allocation.","triggerScenarios":"Passing --raw-action-dim 0, a negative number, or a value exceeding the model's action_dim to the server, then issuing any action request that reaches _prepare_action_latents.","commonSituations":"Typo in the flag value; using an embodiment's joint count (e.g. 32) against a model whose action_dim is smaller; forgetting that raw dims are padded up to action_dim and assuming larger is fine.","solutions":["Check the model's action_dim (config) and set --raw-action-dim to a value in [1, action_dim]","Use get_raw_action_dim(embodiment) from cosmos3_action.py to look up the correct value for your embodiment","Log/int the parsed flag value to catch CLI parsing mistakes like scientific notation or float strings"],"exampleFix":"# before\n--raw-action-dim 0\n# after\n--raw-action-dim 7  # franka-panda gripper+arm dims, must be <= action_dim","handlingStrategy":"validation","validationCode":"assert 0 < int(raw_action_dim) <= action_dim, f\"raw_action_dim must be in [1, {action_dim}]\"","typeGuard":"def valid_raw_action_dim(v: int, action_dim: int) -> bool:\n    return isinstance(v, int) and 0 < v <= action_dim","tryCatchPattern":null,"preventionTips":["Derive raw_action_dim via get_raw_action_dim(embodiment) instead of hand-typing numbers","Log the effective action_dim alongside raw_action_dim at startup","Unit-test the flag parsing in your launch scripts"],"tags":["cosmos3","validation","range-check","action-dim"],"backgroundTag":"argument-out-of-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}