{"record":{"id":"266a257091acf514","repo":"sgl-project/sglang","slug":"invalid-pi05-precision-precision","errorCode":null,"errorMessage":"Invalid Pi05 precision: {precision}","messagePattern":"Invalid Pi05 precision: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/vlas/pi05_core.py","lineNumber":1041,"sourceCode":"                use_bidirectional_attention=True,\n                adarms_cond_dim=(action_expert_config.width if use_adarms[1] else None),\n            )\n            self.gemma_expert = PiGemmaForCausalLM(\n                config=action_config_hf,\n                tensor_parallel=False,\n            )\n            self.gemma_expert.lm_head = None\n            self.gemma_expert.model.embed_tokens = None\n        self.to_selected_dtype(precision)\n\n    def to_selected_dtype(\n        self, precision: Literal[\"bfloat16\", \"float32\"] = \"bfloat16\"\n    ) -> None:\n        if precision == \"float32\":\n            self.to(dtype=torch.float32)\n            return\n        if precision != \"bfloat16\":\n            raise ValueError(f\"Invalid Pi05 precision: {precision}\")\n        self.to(dtype=torch.bfloat16)\n        keep_fp32 = [\n            \"vision_tower.embeddings.patch_embedding.weight\",\n            \"vision_tower.embeddings.patch_embedding.bias\",\n            \"vision_tower.embeddings.position_embedding.weight\",\n            \"vision_tower.vision_model.embeddings.patch_embedding.weight\",\n            \"vision_tower.vision_model.embeddings.patch_embedding.bias\",\n            \"vision_tower.vision_model.embeddings.position_embedding.weight\",\n            \"input_layernorm\",\n            \"post_attention_layernorm\",\n            \"model.norm\",\n        ]\n        for name, param in self.named_parameters():\n            if any(selector in name for selector in keep_fp32):\n                param.data = param.data.to(dtype=torch.float32)\n\n    def set_prefix_output_device(self, device: torch.device) -> None:\n        self.prefix_output_device = torch.device(device)","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/vlas/pi05_core.py#L1023-L1059","documentation":"to_selected_dtype moves the Pi05 policy model to a chosen dtype, accepting only 'bfloat16' or 'float32' (bf16 is the default; some vision-tower weights are deliberately kept in fp32 via the keep_fp32 list). Any other precision string raises. It runs from model __init__, so the bad value comes from a config/CLI argument.","triggerScenarios":"Constructing the Pi05 policy with precision set to anything except 'bfloat16' or 'float32' — e.g. 'fp16', 'float16', 'fp8', 'bf16', or a torch dtype object instead of a string.","commonSituations":"Copying a vLLM/sglang server flag like --dtype fp16 or half into the Pi05 policy config; passing a torch.bfloat16 object where the Literal string is expected; mixing up naming conventions between checkpoints ('bf16' vs 'bfloat16').","solutions":["Set precision to 'bfloat16' (default) or 'float32' exactly as a string","If you passed a torch dtype, convert: precision='bfloat16' instead of torch.bfloat16","fp16/fp8 are unsupported for this policy — retrain/quantize elsewhere or keep fp32","Normalize user-facing dtype names to the two accepted literals before constructing the model"],"exampleFix":"# before\npolicy = Pi05Policy.from_pretrained(path, precision=\"fp16\")\n\n# after\npolicy = Pi05Policy.from_pretrained(path, precision=\"float32\")","handlingStrategy":"validation","validationCode":"from typing import Literal, get_args\nPi05Precision = Literal[\"bfloat16\", \"float32\"]\nassert precision in get_args(Pi05Precision), f\"precision must be one of {get_args(Pi05Precision)}\"","typeGuard":"from typing import Literal, get_args\nPi05Precision = Literal[\"bfloat16\", \"float32\"]\n\ndef is_valid_pi05_precision(p: object) -> bool:\n    return isinstance(p, str) and p in get_args(Pi05Precision)","tryCatchPattern":"try:\n    policy = Pi05Policy.from_pretrained(path, precision=precision)\nexcept ValueError as e:\n    if \"Invalid Pi05 precision\" in str(e):\n        policy = Pi05Policy.from_pretrained(path, precision=\"bfloat16\")  # safe default\n    else:\n        raise","preventionTips":["Expose only a Literal-typed precision parameter in your own wrappers so mypy catches bad values","Map user-facing dtype names (fp16/half/auto) to the two accepted literals at your config boundary"],"tags":["pi05","dtype","precision","config"],"backgroundTag":"unsupported-dtype","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}