Skip to content

Commit 37afd29

Browse files
authored
Eager resolution for vllm.current_platform when running Pathways (#1150)
Signed-off-by: Richard Liu <ricliu@google.com>
1 parent 9dbeb64 commit 37afd29

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tpu_inference/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,29 @@
1212
logger.info("Running vLLM on TPU via Pathways proxy.")
1313
# Must run pathwaysutils.initialize() before any JAX operations
1414
try:
15+
import traceback
16+
1517
import pathwaysutils
18+
import vllm
19+
from vllm.platforms import (resolve_current_platform_cls_qualname,
20+
resolve_obj_by_qualname)
1621
pathwaysutils.initialize()
1722
logger.info("Module pathwaysutils is imported.")
23+
24+
# Pathways requires eager resolution of vllm.current_platform instead of
25+
# lazy resolution in the normal code path. Since this part involves
26+
# global topology discovery across multiple hosts, the platform
27+
# resolution must happen before other components are loaded.
28+
logger.info("Eagerly resolving vLLM current_platform for Pathways.")
29+
platform_cls_qualname = resolve_current_platform_cls_qualname()
30+
resolved_platform_instance = resolve_obj_by_qualname(
31+
platform_cls_qualname)()
32+
vllm.platforms._current_platform = resolved_platform_instance
33+
vllm.platforms._init_trace = "".join(traceback.format_stack())
34+
logger.info(
35+
f"vLLM platform resolved to: {resolved_platform_instance.__class__.__name__}"
36+
)
37+
1838
except Exception as e:
1939
logger.error(
2040
f"Error occurred while importing pathwaysutils or logging TPU info: {e}"

0 commit comments

Comments
 (0)