{"record":{"id":"65bf22c1f2b88d19","repo":"sgl-project/sglang","slug":"pi05-state-dim-must-be-self-config-state-dim","errorCode":null,"errorMessage":"Pi05 state dim must be <= {self.config.state_dim}, got {state_tensor.shape[-1]}","messagePattern":"Pi05 state dim must be <= (.+?), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/pi05_preprocess.py","lineNumber":187,"sourceCode":"                tensor = _preprocess_image(value, self.config.image_size)\n            else:\n                channels = 3\n                height, width = self.config.image_size\n                tensor = torch.ones(channels, height, width, dtype=torch.float32) * -1.0\n\n            images[key] = tensor.unsqueeze(0)\n            image_masks[key] = torch.tensor([is_present], dtype=torch.bool)\n\n        state = raw_observation.get(\"state\")\n        state_tensor = None\n        if state is not None:\n            state_tensor = torch.as_tensor(state, dtype=torch.float32)\n            if state_tensor.ndim == 1:\n                state_tensor = state_tensor.unsqueeze(0)\n            if state_tensor.shape[0] != 1:\n                raise ValueError(\"Pi05 v1 expects one state vector per request\")\n            if state_tensor.shape[-1] > self.config.state_dim:\n                raise ValueError(\n                    f\"Pi05 state dim must be <= {self.config.state_dim}, \"\n                    f\"got {state_tensor.shape[-1]}\"\n                )\n\n        noise = raw_observation.get(\"noise\")\n        noise_tensor = None\n        if noise is not None:\n            noise_tensor = torch.as_tensor(noise, dtype=torch.float32)\n            if noise_tensor.ndim == 2:\n                noise_tensor = noise_tensor.unsqueeze(0)\n            expected = (1, self.config.action_horizon, self.config.action_dim)\n            if tuple(noise_tensor.shape) != expected:\n                raise ValueError(\n                    f\"Pi05 noise must have shape {expected}, \"\n                    f\"got {tuple(noise_tensor.shape)}\"\n                )\n\n        tokens = raw_observation.get(\"tokens\")","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/pi05_preprocess.py#L169-L205","documentation":"The Pi05 model has a fixed robot state dimensionality (config.state_dim). The preprocessing stage accepts state vectors whose last dimension is at most state_dim (smaller vectors are presumably zero-padded downstream), but raises when the provided vector exceeds the configured dimension.","triggerScenarios":"Passing a state tensor whose shape[-1] > self.config.state_dim, e.g. a 32-dim proprioceptive vector when the loaded Pi05 checkpoint was configured with state_dim=24 (or whatever the config says).","commonSituations":"Switching robot embodiments or adding extra joints/sensors without updating the model config; loading a fine-tuned checkpoint with a different state_dim than the data pipeline emits; mismatch between the config used at checkpoint save time and inference time.","solutions":["Check self.config.state_dim (from the model config/checkpoint) and truncate or re-project your state vector to that dimension.","If the extra dims are meaningful, use a Pi05 config/checkpoint whose state_dim matches your robot (re-fine-tune if needed).","Inspect for accidentally concatenated state components (e.g. state + gripper appended twice)."],"exampleFix":"# before\nstate = torch.randn(1, 40)  # robot emits 40 dims\n\n# after\nstate = torch.randn(1, 40)[:, :cfg.state_dim]  # or retrain with state_dim=40","handlingStrategy":"validation","validationCode":"import torch\nd = torch.as_tensor(state).shape[-1]\nassert d <= cfg.state_dim, f\"state dim {d} > configured {cfg.state_dim}\"","typeGuard":"def state_fits_config(state, cfg) -> bool:\n    return torch.as_tensor(state).shape[-1] <= cfg.state_dim","tryCatchPattern":null,"preventionTips":["Print/validate config.state_dim at pipeline startup against your robot's proprioception size.","Pin the model config alongside the checkpoint you deploy."],"tags":["pi05","vla","state-dim","config-mismatch","torch"],"backgroundTag":"model-config-dimension-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}