-
-
Notifications
You must be signed in to change notification settings - Fork 20.5k
[XPU][CI] enhance xpu test support #20652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
aa9e94d
1eba73d
cb0b3dc
6dba0f3
d833eed
200dba9
a84337e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -730,6 +730,11 @@ def fork_new_process_for_each_test( | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @functools.wraps(f) | ||||||||||||||||||||||||
| def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> None: | ||||||||||||||||||||||||
| # To use XPU with multiprocessing, must use the 'spawn' start method via 'VLLM_WORKER_MULTIPROC_METHOD=spawn' | ||||||||||||||||||||||||
| if current_platform.is_xpu(): | ||||||||||||||||||||||||
| f(*args, **kwargs) | ||||||||||||||||||||||||
| return | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To use XPU with multiprocessing, the start method must be 'spawn'. If
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Make the process the leader of its own process group | ||||||||||||||||||||||||
| # to avoid sending SIGTERM to the parent process | ||||||||||||||||||||||||
| os.setpgrp() | ||||||||||||||||||||||||
|
|
@@ -817,7 +822,7 @@ def create_new_process_for_each_test( | |||||||||||||||||||||||
| """Creates a decorator that runs each test function in a new process. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||
| method: The process creation method. Can be either "spawn" or "fork". | ||||||||||||||||||||||||
| method: The process creation method. Can be either "spawn" or "fork". | ||||||||||||||||||||||||
| If not specified, | ||||||||||||||||||||||||
| it defaults to "spawn" on ROCm platforms and "fork" otherwise. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,8 @@ def __init__( | |
|
|
||
| if current_platform.is_cuda_alike(): | ||
| self.device = torch.device(f"cuda:{local_rank}") | ||
| elif current_platform.is_xpu(): | ||
| self.device = torch.device(f"xpu:{local_rank}") | ||
|
Comment on lines
+243
to
+244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| elif current_platform.is_out_of_tree(): | ||
| self.device = torch.device( | ||
| f"{current_platform.device_name}:{local_rank}") | ||
|
|
@@ -1317,13 +1319,13 @@ def in_the_same_node_as(pg: Union[ProcessGroup, StatelessProcessGroup], | |
|
|
||
| def is_global_first_rank() -> bool: | ||
| """ | ||
| Check if the current process is the first rank globally across all | ||
| Check if the current process is the first rank globally across all | ||
| parallelism strategies (PP, TP, DP, EP, etc.). | ||
|
|
||
| Unlike group-specific checks like `get_tensor_model_parallel_rank() == 0` | ||
| or `get_pp_group().is_first_rank`, this function checks the global rank | ||
| across all parallelism dimensions. | ||
|
|
||
| Returns: | ||
| bool: True if this is the global first rank (rank 0), False otherwise. | ||
| Returns True if distributed is not initialized (single process). | ||
|
|
@@ -1352,7 +1354,7 @@ def _node_count(pg: Union[ProcessGroup, StatelessProcessGroup]) -> int: | |
|
|
||
| Args: | ||
| pg: The process group to analyze | ||
|
|
||
| Returns: | ||
| int: The total number of nodes | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,6 +78,14 @@ def check_and_update_config(cls, vllm_config: VllmConfig) -> None: | |||||||||||||||||||||||
| if cache_config and cache_config.block_size is None: | ||||||||||||||||||||||||
| cache_config.block_size = 64 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # FIXME: Temporarily forcing eager mode | ||||||||||||||||||||||||
| # remove after t.compile support stabilizes. | ||||||||||||||||||||||||
| if envs.VLLM_USE_V1 and vllm_config.model_config is not None and \ | ||||||||||||||||||||||||
| not vllm_config.model_config.enforce_eager: | ||||||||||||||||||||||||
| from vllm.config import CompilationLevel | ||||||||||||||||||||||||
| vllm_config.compilation_config.level = \ | ||||||||||||||||||||||||
| CompilationLevel.NO_COMPILATION | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider wrapping the long conditional statement in parentheses for better readability and adherence to PEP 8 style guidelines.
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Instances created using VllmConfig() typically have model_config as | ||||||||||||||||||||||||
| # None by default. The modification involves adding a check to prevent | ||||||||||||||||||||||||
| # potential null exceptions check and update model config. | ||||||||||||||||||||||||
|
|
@@ -93,9 +101,6 @@ def check_and_update_config(cls, vllm_config: VllmConfig) -> None: | |||||||||||||||||||||||
| "mode.") | ||||||||||||||||||||||||
| model_config.enforce_eager = True | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if vllm_config.device_config is not None: | ||||||||||||||||||||||||
| assert vllm_config.device_config.device_type == "xpu" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # check and update parallel config | ||||||||||||||||||||||||
| parallel_config = vllm_config.parallel_config | ||||||||||||||||||||||||
| parallel_config.worker_cls = "vllm.v1.worker.xpu_worker.XPUWorker" | ||||||||||||||||||||||||
|
|
@@ -114,7 +119,8 @@ def check_and_update_config(cls, vllm_config: VllmConfig) -> None: | |||||||||||||||||||||||
| logger.warning( | ||||||||||||||||||||||||
| "Please use spawn as start method if you want to use mp.") | ||||||||||||||||||||||||
| elif parallel_config.distributed_executor_backend != "ray" and \ | ||||||||||||||||||||||||
| parallel_config.distributed_executor_backend != "uni": | ||||||||||||||||||||||||
| parallel_config.distributed_executor_backend != "uni" and \ | ||||||||||||||||||||||||
| parallel_config.distributed_executor_backend != "external_launcher": | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider wrapping the long conditional statement in parentheses for better readability and adherence to PEP 8 style guidelines.
Suggested change
|
||||||||||||||||||||||||
| logger.warning( | ||||||||||||||||||||||||
| "%s is not supported on XPU, fallback to ray distributed" | ||||||||||||||||||||||||
| " executor backend.", | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ def __init__( | |
| self.cascade_attn_enabled = False | ||
|
|
||
| def _init_device_properties(self) -> None: | ||
| pass | ||
| self.num_sms = None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On top of this change, may I suggest an improvement to move these customization to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually these function was in gpu_model_runner.py originally and move to different device model_runner for cleaner readness. So I think we could follow this design. |
||
|
|
||
| def _sync_device(self) -> None: | ||
| torch.xpu.synchronize() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved robustness, it's better to check for XPU availability using
torch.xpu.is_available()in addition tohasattr(torch, 'xpu'). This ensures that the XPU device is not only supported but also ready for use.