Skip to content

Commit 86e414c

Browse files
authored
Merge branch 'main' into hybrid-cache-groups
2 parents d419f0f + 76afe4e commit 86e414c

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

vllm/entrypoints/cli/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from __future__ import annotations
99

1010
import importlib.metadata
11+
import sys
12+
13+
from vllm.logger import init_logger
14+
15+
logger = init_logger(__name__)
1116

1217

1318
def main():
@@ -29,6 +34,22 @@ def main():
2934

3035
cli_env_setup()
3136

37+
# For 'vllm bench *': use CPU instead of UnspecifiedPlatform by default
38+
if len(sys.argv) > 1 and sys.argv[1] == "bench":
39+
logger.debug(
40+
"Bench command detected, must ensure current platform is not "
41+
"UnspecifiedPlatform to avoid device type inference error"
42+
)
43+
from vllm import platforms
44+
45+
if platforms.current_platform.is_unspecified():
46+
from vllm.platforms.cpu import CpuPlatform
47+
48+
platforms.current_platform = CpuPlatform()
49+
logger.info(
50+
"Unspecified platform detected, switching to CPU Platform instead."
51+
)
52+
3253
parser = FlexibleArgumentParser(
3354
description="vLLM CLI",
3455
epilog=VLLM_SUBCMD_PARSER_EPILOG.format(subcmd="[subcommand]"),

vllm/platforms/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,14 @@ def __getattr__(name: str):
261261
raise AttributeError(f"No attribute named '{name}' exists in {__name__}.")
262262

263263

264+
def __setattr__(name: str, value):
265+
if name == "current_platform":
266+
global _current_platform
267+
_current_platform = value
268+
elif name in globals():
269+
globals()[name] = value
270+
else:
271+
raise AttributeError(f"No attribute named '{name}' exists in {__name__}.")
272+
273+
264274
__all__ = ["Platform", "PlatformEnum", "current_platform", "CpuArchEnum", "_init_trace"]

vllm/platforms/interface.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ def is_cpu(self) -> bool:
141141
def is_out_of_tree(self) -> bool:
142142
return self._enum == PlatformEnum.OOT
143143

144+
def is_unspecified(self) -> bool:
145+
return self._enum == PlatformEnum.UNSPECIFIED
146+
144147
def get_max_output_tokens(self, prompt_len: int) -> int:
145148
return sys.maxsize
146149

0 commit comments

Comments
 (0)