OpenBMB/VoxCPM · error · ValueError

VOXCPM_MPS_DTYPE='{override}' is not one of {sorted(_VALID_D

Error message

VOXCPM_MPS_DTYPE='{override}' is not one of {sorted(_VALID_DTYPE_OVERRIDES)}

What it means

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.

Source

Thrown at src/voxcpm/model/utils.py:179

def pick_runtime_dtype(device: str, configured_dtype: str) -> str:
    """Pick a safe runtime dtype for the resolved device.

    On Apple Silicon (MPS), bfloat16/float16 produce enough numerical drift
    in the diffusion AR loop that the output is glitched and the model's
    badcase detector triggers infinite retries. float32 is the only stable
    option today. CUDA and CPU keep whatever the checkpoint was trained with.

    Users can override with ``VOXCPM_MPS_DTYPE`` (e.g. ``bfloat16``) when
    they want to test future MPS improvements.
    """
    if device != "mps":
        return configured_dtype

    override = os.environ.get("VOXCPM_MPS_DTYPE", "").strip().lower()
    if override:
        if override not in _VALID_DTYPE_OVERRIDES:
            raise ValueError(f"VOXCPM_MPS_DTYPE='{override}' is not one of " f"{sorted(_VALID_DTYPE_OVERRIDES)}")
        return override

    if (configured_dtype or "").lower() in _LOW_PRECISION_DTYPES:
        return "float32"
    return configured_dtype


def auto_select_device(preferred_device: Optional[str] = "cuda") -> str:
    """
    Choose a runtime device automatically.

    Preference order:
    - if the preferred device is available, use it
    - otherwise fall back to CUDA -> MPS -> CPU
    """
    preferred = (preferred_device or "cuda").strip().lower()

    if preferred.startswith("cuda") and torch.cuda.is_available():

View on GitHub (pinned to f5a1c6a6b9)

Solutions

  1. Set VOXCPM_MPS_DTYPE to a valid value (commonly 'float32') per _VALID_DTYPE_OVERRIDES
  2. Unset the variable to use the automatic low-precision-to-float32 fallback on MPS
  3. Upgrade torch if you need a dtype currently unsupported on MPS

Example fix

# before
export VOXCPM_MPS_DTYPE=bfloat16
# after
export VOXCPM_MPS_DTYPE=float32
Defensive patterns

Strategy: validation

Validate before calling

import os
v = os.environ.get("VOXCPM_MPS_DTYPE", "").strip().lower()
VALID = {"float32", "float16"}  # mirror _VALID_DTYPE_OVERRIDES
if v and v not in VALID:
    del os.environ["VOXCPM_MPS_DTYPE"]

Prevention

When it happens

Trigger: Setting VOXCPM_MPS_DTYPE=bfloat16 (unsupported on many MPS torch builds), 'fp8', or a typo while running with device='mps'.

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

Related errors


AI-assisted analysis of OpenBMB/VoxCPM@f5a1c6a6b9 (2026-08-27). Data as JSON: /api/errors/1468c7fd32f20645. Report an issue: GitHub.