{"record":{"id":"4e3b03e38aafb2b9","repo":"vllm-project/vllm","slug":"unknown-dtype-dtype","errorCode":null,"errorMessage":"Unknown dtype: {dtype}","messagePattern":"Unknown dtype: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/model.py","lineNumber":2286,"sourceCode":"    model_type = config.model_type\n\n    if isinstance(dtype, str):\n        dtype = dtype.lower()\n        if dtype == \"auto\":\n            # Set default dtype from model config\n            torch_dtype = _resolve_auto_dtype(\n                model_type,\n                config_dtype,\n                is_pooling_model=is_pooling_model,\n            )\n        else:\n            if dtype not in _STR_DTYPE_TO_TORCH_DTYPE:\n                raise ValueError(f\"Unknown dtype: {dtype!r}\")\n            torch_dtype = _STR_DTYPE_TO_TORCH_DTYPE[dtype]\n    elif isinstance(dtype, torch.dtype):\n        torch_dtype = dtype\n    else:\n        raise ValueError(f\"Unknown dtype: {dtype}\")\n\n    _check_valid_dtype(model_type, torch_dtype)\n\n    if torch_dtype != config_dtype:\n        if torch_dtype == torch.float32:\n            # Upcasting to float32 is allowed.\n            logger.info(\"Upcasting %s to %s.\", config_dtype, torch_dtype)\n        elif config_dtype == torch.float32:\n            # Downcasting from float32 to float16 or bfloat16 is allowed.\n            logger.info(\"Downcasting %s to %s.\", config_dtype, torch_dtype)\n        else:\n            # Casting between float16 and bfloat16 is allowed with a warning.\n            logger.warning(\"Casting %s to %s.\", config_dtype, torch_dtype)\n\n    return torch_dtype\n\n\ndef _get_head_dtype(","sourceCodeStart":2268,"sourceCodeEnd":2304,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/model.py#L2268-L2304","documentation":"The else-branch of _get_and_verify_dtype: dtype is neither a str nor a torch.dtype (e.g. None slipping through, an int, or a numpy dtype), so it cannot be interpreted. Note this path formats with {dtype} (no !r), unlike the string branch.","triggerScenarios":"Calling the dtype resolution path with a non-str, non-torch.dtype object — for example a numpy dtype, a Python None from a misconfigured default, or a custom enum.","commonSituations":"Programmatic construction of EngineArgs where dtype comes from unvalidated user input or a config file (YAML parses 'float16' fine but a typo'd key yields None); wrapping vLLM in another framework that passes numpy dtypes.","solutions":["Normalize dtype to a str or torch.dtype before constructing engine/model config (validate at your config boundary).","Map numpy dtypes to torch dtypes (e.g. numpy.float16 -> torch.float16) if that is the source."],"exampleFix":"# before\nllm = LLM(model='my-model', dtype=np.float16)\n# after\nimport torch\nllm = LLM(model='my-model', dtype=torch.float16)","handlingStrategy":"type-guard","validationCode":"import torch\ndef normalize_dtype(d):\n    if isinstance(d, str):\n        return d.lower()\n    if isinstance(d, torch.dtype):\n        return d\n    raise TypeError(f'dtype must be str or torch.dtype, got {type(d)!r}')","typeGuard":"import torch\ndef is_resolvable_dtype(d: object) -> bool:\n    return isinstance(d, (str, torch.dtype))","tryCatchPattern":"except ValueError as e:\n    if 'Unknown dtype' in str(e):\n        coerce numpy dtypes to torch (np.float16 -> torch.float16) and retry once","preventionTips":["Validate that dtype comes from a str or torch.dtype before passing it into engine config.","Never let None or arbitrary config-file values reach dtype; default explicitly to 'auto'.","Map numpy dtypes at the framework boundary if you wrap vLLM."],"tags":["dtype","type-error","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}