sgl-project/sglang · error · ValueError

Unsupported Pi05 dtype: {dtype_name}

Error message

Unsupported Pi05 dtype: {dtype_name}

What it means

_dtype_from_config in pi05_policy.py parses the dtype string from a checkpoint's config into a torch dtype, recognizing only bf16/bfloat16, fp16/float16/half, and fp32/float32. Any other string (or a config where the dtype key is None or a novel quantization name) raises 'Unsupported Pi05 dtype'. Called during from_pretrained.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/vlas/pi05_policy.py:454

        )
        return cls(
            config,
            model_path=local_path,
            device=device,
            dtype=dtype,
            manifest=manifest,
        )

    @staticmethod
    def _dtype_from_config(dtype_name: str) -> torch.dtype:
        name = (dtype_name or "bf16").lower()
        if name in ("bf16", "bfloat16"):
            return torch.bfloat16
        if name in ("fp16", "float16", "half"):
            return torch.float16
        if name in ("fp32", "float32"):
            return torch.float32
        raise ValueError(f"Unsupported Pi05 dtype: {dtype_name}")

    @staticmethod
    def _apply_checkpoint_config(
        model_path: str,
        config: Pi05PipelineConfig,
    ) -> None:
        config_path = Path(model_path) / "config.json"
        if not config_path.exists():
            return
        with open(config_path, encoding="utf-8") as f:
            payload = json.load(f)

        config.paligemma_variant = payload.get(
            "paligemma_variant", config.paligemma_variant
        )
        config.action_expert_variant = payload.get(
            "action_expert_variant", config.action_expert_variant
        )

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the exception for the exact dtype_name, then edit the checkpoint config to one of: bf16, bfloat16, fp16, float16, half, fp32, float32
  2. If the checkpoint is genuinely quantized (fp8), dequantize/convert it to bf16 before loading
  3. Normalize strings like 'torch.bfloat16' or 'auto' to 'bfloat16' in your loader before from_pretrained
  4. Upgrade sglang in case newer dtype aliases were added

Example fix

# before
# config.json: {"dtype": "fp8"}
policy = Pi05Policy.from_pretrained("./ckpt")

# after
# config.json: {"dtype": "bfloat16"}
policy = Pi05Policy.from_pretrained("./ckpt")
Defensive patterns

Strategy: validation

Validate before calling

import json
_ALIASES = {"bf16": "bfloat16", "bfloat16": "bfloat16", "fp16": "fp16",
           "float16": "fp16", "half": "fp16", "fp32": "fp32", "float32": "fp32"}
name = json.load(open(f"{model_path}/config.json")).get("dtype")
name = str(name).replace("torch.", "").lower() if name else "bfloat16"
assert name in _ALIASES, f"unsupported checkpoint dtype {name!r}"

Type guard

def is_supported_pi05_dtype(name: object) -> bool:
    return isinstance(name, str) and name.replace("torch.", "").lower() in {
        "bf16", "bfloat16", "fp16", "float16", "half", "fp32", "float32"}

Try / catch

try:
    policy = Pi05Policy.from_pretrained(path)
except ValueError as e:
    if "Unsupported Pi05 dtype" in str(e):
        cfgp = f"{path}/config.json"
        cfg = json.load(open(cfgp)); cfg["dtype"] = "bfloat16"
        json.dump(cfg, open(cfgp, "w"))
        policy = Pi05Policy.from_pretrained(path)
    else:
        raise

Prevention

When it happens

Trigger: Loading a Pi05 checkpoint whose config declares a dtype like 'fp8', 'bfloat8', 'auto', 'float64', or an empty/None dtype_name; also case-sensitive variants like 'BF16' will miss if not handled upstream.

Common situations: Loading a community checkpoint saved with a newer/quantized dtype; hand-edited config.json; checkpoint exported from another framework that writes torch.str or 'torch.bfloat16'-style strings.

Related errors


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