{"record":{"id":"bfae13986e6a7151","repo":"vllm-project/vllm","slug":"invalid-device-in-mm-processor-kwargs-device-r","errorCode":null,"errorMessage":"Invalid \"device\" in mm_processor_kwargs: {device!r}. Expected a torch device such as \"cpu\", \"cuda\" or \"cuda:0\".","messagePattern":"Invalid \"device\" in mm_processor_kwargs: (.+?)\\. Expected a torch device such as \"cpu\", \"cuda\" or \"cuda:0\"\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/multimodal.py","lineNumber":409,"sourceCode":"        accepts -- `\"cuda\"`, `\"cuda:1\"`, `torch.device(...)`, or a bare index.\n        Normalising through torch rather than parsing the string keeps the\n        non-string forms from slipping past a caller's comparison.\n\n        Returns:\n            The device type, or None when no device is requested.\n\n        Raises:\n            ValueError: If `device` is not something `torch.device` accepts.\n                `validate_mm_processor_device` is what surfaces this during\n                startup, so the value is only parsed once.\n        \"\"\"\n        device = (self.mm_processor_kwargs or {}).get(\"device\")\n        if device is None:\n            return None\n        try:\n            return torch.device(device).type  # type: ignore[arg-type]\n        except (RuntimeError, TypeError, ValueError):\n            raise ValueError(\n                f'Invalid \"device\" in mm_processor_kwargs: {device!r}. Expected a '\n                'torch device such as \"cpu\", \"cuda\" or \"cuda:0\".'\n            ) from None\n\n    def validate_mm_processor_device(self, ec_config: ECTransferConfig | None) -> None:\n        \"\"\"Check `mm_processor_kwargs[\"device\"]` for this deployment.\n\n        The only place the requested device is validated, so it runs even on a\n        CPU-only platform: the value is parsed before any early return.\n\n        Args:\n            ec_config: The deployment's EC config, or None when it is not an\n                encode/prefill/decode deployment. Passed in because it is not\n                reachable from here, and because a field assigned after\n                construction would not re-trigger this config's validators.\n\n        Raises:\n            ValueError: If the requested device is not a torch device, or if it","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/multimodal.py#L391-L427","documentation":"MultiModalConfig.get_mm_processor_device_type() parses mm_processor_kwargs['device'] with torch.device(); any string torch.device() rejects (RuntimeError/TypeError/ValueError) is re-raised as a ValueError telling you to use a torch device spec like 'cpu', 'cuda', 'cuda:0'. This is the single parse point — validate_mm_processor_device() surfaces it during startup.","triggerScenarios":"Passing --mm-processor-kwargs '{\"device\": \"gpu\"}' or \"device=CPU!\" or a non-string type like {\"device\": 0}; any value for which torch.device(value) throws.","commonSituations":"Confusing torch device names with accelerator labels ('gpu', 'npu' misspelled, 'device:0' CUDA-style syntax); malformed JSON on the CLI producing an int; copy-pasting device strings from other frameworks (e.g. JAX or TensorFlow device specs).","solutions":["Use a valid torch device string: 'cpu', 'cuda', or a concrete index like 'cuda:0'.","Validate the JSON passed to --mm-processor-kwargs (jq or python -m json.tool) so device stays a string.","Prefer the dedicated convenience flag --mm-processor-device cpu instead of embedding 'device' in the kwargs dict."],"exampleFix":"# before\nvllm serve model --mm-processor-kwargs '{\"device\": \"gpu\"}'\n\n# after\nvllm serve model --mm-processor-kwargs '{\"device\": \"cuda:0\"}'\n# or simply\nvllm serve model --mm-processor-device cpu","handlingStrategy":"type-guard","validationCode":"import torch\n\ndef normalize_device(kwargs: dict) -> dict:\n    dev = kwargs.get(\"device\")\n    if dev is not None:\n        torch.device(dev)  # raises here with a clear traceback if invalid\n    return kwargs","typeGuard":"def is_valid_torch_device(dev) -> bool:\n    if not isinstance(dev, str):\n        return False\n    try:\n        torch.device(dev)\n        return True\n    except (RuntimeError, TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Validate --mm-processor-kwargs JSON with jq before launch.","Prefer the dedicated --mm-processor-device flag over embedding 'device' in the kwargs dict."],"tags":["vllm","config","multimodal","device","torch","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}