{"record":{"id":"02ae815a95e11f06","repo":"vllm-project/vllm","slug":"unknown-dtype-dtype-r","errorCode":null,"errorMessage":"Unknown dtype: {dtype!r}","messagePattern":"Unknown dtype: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/model.py","lineNumber":2281,"sourceCode":"    config_format: str | ConfigFormat = \"hf\",\n) -> torch.dtype:\n    config_dtype = ModelArchConfigConvertorBase.get_torch_dtype(\n        config, model_id, revision=revision, config_format=config_format\n    )\n    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)","sourceCodeStart":2263,"sourceCodeEnd":2299,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/model.py#L2263-L2299","documentation":"_get_and_verify_dtype accepts dtype as a string only if it is a key of _STR_DTYPE_TO_TORCH_DTYPE. An unrecognized string (wrong case is handled, but unknown names are not) raises ValueError with the offending value.","triggerScenarios":"Passing dtype strings like 'fp16', 'bf16', 'half', or a typo ('float164') as --dtype or dtype= in engine args.","commonSituations":"Using shorthand dtype names common in other frameworks (fp16/bf16 from PyTorch conventions) instead of vLLM's full names (float16/bfloat16); config templating that injects an empty or malformed dtype string.","solutions":["Use a supported dtype name: 'float16', 'bfloat16', 'float32', 'auto' (and any others present in _STR_DTYPE_TO_TORCH_DTYPE).","Pass a torch.dtype object directly when using the Python API instead of a string alias."],"exampleFix":"# before\nvllm serve my-model --dtype fp16\n# after\nvllm serve my-model --dtype float16","handlingStrategy":"validation","validationCode":"from vllm.config.model import _STR_DTYPE_TO_TORCH_DTYPE\ndef is_valid_dtype_str(s: object) -> bool:\n    return isinstance(s, str) and s.lower() in _STR_DTYPE_TO_TORCH_DTYPE","typeGuard":"def is_valid_dtype_str(s: object) -> bool:\n    return isinstance(s, str) and s.lower() in _STR_DTYPE_TO_TORCH_DTYPE","tryCatchPattern":"except ValueError as e:\n    if 'Unknown dtype' in str(e):\n        fall back to dtype='auto' and log the rejected value","preventionTips":["Use canonical names float16/bfloat16/float32/auto — not fp16/bf16/half shorthands.","Validate dtype strings at your config boundary with _STR_DTYPE_TO_TORCH_DTYPE before constructing engine args.","Pass torch.dtype objects in Python code to sidestep string parsing entirely."],"tags":["dtype","config","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}