Skip to content

Commit 6e9cc73

Browse files
authored
[MISC] correct DeviceConfig device field static type analysis (#19699)
Signed-off-by: Andy Xie <andy.xning@gmail.com>
1 parent c53711b commit 6e9cc73

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

vllm/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ def is_multi_step(self) -> bool:
22852285
class DeviceConfig:
22862286
"""Configuration for the device to use for vLLM execution."""
22872287

2288-
device: SkipValidation[Union[Device, torch.device]] = "auto"
2288+
device: SkipValidation[Optional[Union[Device, torch.device]]] = "auto"
22892289
"""Device type for vLLM execution.
22902290
This parameter is deprecated and will be
22912291
removed in a future release.
@@ -2327,7 +2327,10 @@ def __post_init__(self):
23272327
"to turn on verbose logging to help debug the issue.")
23282328
else:
23292329
# Device type is assigned explicitly
2330-
self.device_type = self.device
2330+
if isinstance(self.device, str):
2331+
self.device_type = self.device
2332+
elif isinstance(self.device, torch.device):
2333+
self.device_type = self.device.type
23312334

23322335
# Some device types require processing inputs on CPU
23332336
if self.device_type in ["neuron"]:

vllm/engine/arg_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ def create_engine_config(
10181018
from vllm.platforms import current_platform
10191019
current_platform.pre_register_and_update()
10201020

1021-
device_config = DeviceConfig(device=current_platform.device_type)
1021+
device_config = DeviceConfig(
1022+
device=cast(Device, current_platform.device_type))
10221023
model_config = self.create_model_config()
10231024

10241025
# * If VLLM_USE_V1 is unset, we enable V1 for "supported features"

0 commit comments

Comments
 (0)