sgl-project/sglang · error · ValueError

Pi05 state dim must be <= {self.config.state_dim}, got {stat

Error message

Pi05 state dim must be <= {self.config.state_dim}, got {state_tensor.shape[-1]}

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/pi05_preprocess.py:187

                tensor = _preprocess_image(value, self.config.image_size)
            else:
                channels = 3
                height, width = self.config.image_size
                tensor = torch.ones(channels, height, width, dtype=torch.float32) * -1.0

            images[key] = tensor.unsqueeze(0)
            image_masks[key] = torch.tensor([is_present], dtype=torch.bool)

        state = raw_observation.get("state")
        state_tensor = None
        if state is not None:
            state_tensor = torch.as_tensor(state, dtype=torch.float32)
            if state_tensor.ndim == 1:
                state_tensor = state_tensor.unsqueeze(0)
            if state_tensor.shape[0] != 1:
                raise ValueError("Pi05 v1 expects one state vector per request")
            if state_tensor.shape[-1] > self.config.state_dim:
                raise ValueError(
                    f"Pi05 state dim must be <= {self.config.state_dim}, "
                    f"got {state_tensor.shape[-1]}"
                )

        noise = raw_observation.get("noise")
        noise_tensor = None
        if noise is not None:
            noise_tensor = torch.as_tensor(noise, dtype=torch.float32)
            if noise_tensor.ndim == 2:
                noise_tensor = noise_tensor.unsqueeze(0)
            expected = (1, self.config.action_horizon, self.config.action_dim)
            if tuple(noise_tensor.shape) != expected:
                raise ValueError(
                    f"Pi05 noise must have shape {expected}, "
                    f"got {tuple(noise_tensor.shape)}"
                )

        tokens = raw_observation.get("tokens")

View on GitHub (pinned to 0132848349)

Solutions

  1. Check self.config.state_dim (from the model config/checkpoint) and truncate or re-project your state vector to that dimension.
  2. If the extra dims are meaningful, use a Pi05 config/checkpoint whose state_dim matches your robot (re-fine-tune if needed).
  3. Inspect for accidentally concatenated state components (e.g. state + gripper appended twice).

Example fix

# before
state = torch.randn(1, 40)  # robot emits 40 dims

# after
state = torch.randn(1, 40)[:, :cfg.state_dim]  # or retrain with state_dim=40
Defensive patterns

Strategy: validation

Validate before calling

import torch
d = torch.as_tensor(state).shape[-1]
assert d <= cfg.state_dim, f"state dim {d} > configured {cfg.state_dim}"

Type guard

def state_fits_config(state, cfg) -> bool:
    return torch.as_tensor(state).shape[-1] <= cfg.state_dim

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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