{"record":{"id":"1468c7fd32f20645","repo":"OpenBMB/VoxCPM","slug":"voxcpm-mps-dtype-override-is-not-one-of-sorte","errorCode":null,"errorMessage":"VOXCPM_MPS_DTYPE='{override}' is not one of {sorted(_VALID_DTYPE_OVERRIDES)}","messagePattern":"VOXCPM_MPS_DTYPE='(.+?)' is not one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/voxcpm/model/utils.py","lineNumber":179,"sourceCode":"\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\":\n        return configured_dtype\n\n    override = os.environ.get(\"VOXCPM_MPS_DTYPE\", \"\").strip().lower()\n    if override:\n        if override not in _VALID_DTYPE_OVERRIDES:\n            raise ValueError(f\"VOXCPM_MPS_DTYPE='{override}' is not one of \" f\"{sorted(_VALID_DTYPE_OVERRIDES)}\")\n        return override\n\n    if (configured_dtype or \"\").lower() in _LOW_PRECISION_DTYPES:\n        return \"float32\"\n    return configured_dtype\n\n\ndef auto_select_device(preferred_device: Optional[str] = \"cuda\") -> str:\n    \"\"\"\n    Choose a runtime device automatically.\n\n    Preference order:\n    - if the preferred device is available, use it\n    - otherwise fall back to CUDA -> MPS -> CPU\n    \"\"\"\n    preferred = (preferred_device or \"cuda\").strip().lower()\n\n    if preferred.startswith(\"cuda\") and torch.cuda.is_available():","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/model/utils.py#L161-L197","documentation":"On MPS devices, the VOXCPM_MPS_DTYPE env var can override the configured dtype, but only with values in _VALID_DTYPE_OVERRIDES. An invalid value raises ValueError at model init.","triggerScenarios":"Setting VOXCPM_MPS_DTYPE=bfloat16 (unsupported on many MPS torch builds), 'fp8', or a typo while running with device='mps'.","commonSituations":"Copying Linux/CUDA-oriented env config to a Mac; older torch versions where bf16 MPS kernels are missing, prompting manual overrides that then use an invalid name.","solutions":["Set VOXCPM_MPS_DTYPE to a valid value (commonly 'float32') per _VALID_DTYPE_OVERRIDES","Unset the variable to use the automatic low-precision-to-float32 fallback on MPS","Upgrade torch if you need a dtype currently unsupported on MPS"],"exampleFix":"# before\nexport VOXCPM_MPS_DTYPE=bfloat16\n# after\nexport VOXCPM_MPS_DTYPE=float32","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"VOXCPM_MPS_DTYPE\", \"\").strip().lower()\nVALID = {\"float32\", \"float16\"}  # mirror _VALID_DTYPE_OVERRIDES\nif v and v not in VALID:\n    del os.environ[\"VOXCPM_MPS_DTYPE\"]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep per-platform env configs separate","Document valid override values next to where you set them"],"tags":["mps","dtype","environment-variable","macos"],"backgroundTag":"invalid-env-var-value","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}