{"record":{"id":"4cd47489c27ad494","repo":"OpenBMB/VoxCPM","slug":"unsupported-dtype-dtype","errorCode":null,"errorMessage":"Unsupported dtype: {dtype}","messagePattern":"Unsupported dtype: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/voxcpm/model/utils.py","lineNumber":155,"sourceCode":"\n    return CharTokenizerWrapper(tokenizer)\n\n\ndef get_dtype(dtype: str):\n    if dtype == \"bfloat16\":\n        return torch.bfloat16\n    elif dtype == \"bf16\":\n        return torch.bfloat16\n    elif dtype == \"float16\":\n        return torch.float16\n    elif dtype == \"fp16\":\n        return torch.float16\n    elif dtype == \"float32\":\n        return torch.float32\n    elif dtype == \"fp32\":\n        return torch.float32\n    else:\n        raise ValueError(f\"Unsupported dtype: {dtype}\")\n\n\ndef _has_mps() -> bool:\n    return hasattr(torch.backends, \"mps\") and torch.backends.mps.is_available()\n\n\ndef pick_runtime_dtype(device: str, configured_dtype: str) -> str:\n    \"\"\"Pick a safe runtime dtype for the resolved device.\n\n    On Apple Silicon (MPS), bfloat16/float16 produce enough numerical drift\n    in the diffusion AR loop that the output is glitched and the model's\n    badcase detector triggers infinite retries. float32 is the only stable\n    option today. CUDA and CPU keep whatever the checkpoint was trained with.\n\n    Users can override with ``VOXCPM_MPS_DTYPE`` (e.g. ``bfloat16``) when\n    they want to test future MPS improvements.\n    \"\"\"\n    if device != \"mps\":","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/model/utils.py#L137-L173","documentation":"get_dtype maps dtype strings to torch types and only accepts bfloat16/float32/fp32 (plus the fp16/bf16 branches above). Anything else raises ValueError.","triggerScenarios":"Passing dtype='float16' spelled as 'fp16' is fine but 'float64', 'int8', 'fp8', or a torch.dtype object instead of a string raises this.","commonSituations":"Copy-pasting dtype names from other libraries, passing torch.float16 (the object) rather than 'float16', or a typo like 'f32'.","solutions":["Use one of the supported strings: 'bfloat16','float16','fp16','float32','fp32'","If you hold a torch.dtype, map it to its string name first","Check the current supported list in get_dtype"],"exampleFix":"# before\nmodel = VoxCPM(..., dtype=torch.float16)\n# after\nmodel = VoxCPM(..., dtype=\"float16\")","handlingStrategy":"validation","validationCode":"VALID = {\"bfloat16\",\"bf16\",\"float16\",\"fp16\",\"float32\",\"fp32\"}\ndtype = dtype if dtype in VALID else \"float32\"","typeGuard":"def is_valid_dtype(s) -> bool:\n    return isinstance(s, str) and s in {\"bfloat16\",\"bf16\",\"float16\",\"fp16\",\"float32\",\"fp32\"}","tryCatchPattern":null,"preventionTips":["Pass dtype as a lowercase string, never a torch.dtype object","Centralize dtype config in one place"],"tags":["dtype","configuration","value-error"],"backgroundTag":"unsupported-enum-value","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}