Skip to content

Conversation

@jonathanc-n
Copy link
Contributor

@jonathanc-n jonathanc-n commented Oct 22, 2025

Purpose

Part of #26900

  • vllm.utils.cuda_is_initialized ⇒ vllm.utils.hardware_utils.cuda_is_initialized
  • vllm.utils.xpu_is_initialized ⇒ vllm.utils.hardware_utils.xpu_is_initialized
  • vllm.utils.cuda_get_device_properties ⇒ vllm.utils.hardware_utils.cuda_get_device_properties
  • vllm.utils.is_pin_memory_available ⇒ vllm.utils.hardware_utils.is_pin_memory_available
  • vllm.utils.is_uva_available ⇒ vllm.utils.hardware_utils.is_uva_available

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: Jonathan <chenleejonathan@gmail.com>
@jonathanc-n
Copy link
Contributor Author

cc @DarkLight1337

@mergify mergify bot added qwen Related to Qwen models speculative-decoding v1 tpu Related to Google TPUs labels Oct 22, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively refactors hardware-related utility functions from vllm.utils into a new, dedicated module vllm.utils.hardware_utils. The changes are clean and improve code organization by grouping related functionalities. I've identified one area for improvement regarding multiprocessing context creation to enhance portability and consistency, which I've detailed in a specific comment. Overall, this is a good step towards better code structure.

return tuple(getattr(props, name) for name in names)

# Run in subprocess to avoid initializing CUDA as a side effect.
mp_ctx = multiprocessing.get_context("fork")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Hardcoding the multiprocessing start method to "fork" is not portable and can cause issues on platforms like macOS or Windows where fork is unavailable or unsafe. It's better to use the centralized get_mp_context utility for consistency and safety.

To avoid a circular dependency (since vllm.utils imports this file), I recommend moving get_mp_context and its helper _maybe_force_spawn from vllm/utils/__init__.py to this file (vllm/utils/hardware_utils.py). This change aligns with the goal of this PR to centralize hardware-related utilities.

After moving the functions, you can change this line to use get_mp_context(). You'll also need to:

  1. Add the necessary imports (os, vllm.envs, vllm.logger, vllm.ray.lazy_utils) to vllm/utils/hardware_utils.py.
  2. Update vllm/utils/__init__.py to import get_mp_context from its new location.
Suggested change
mp_ctx = multiprocessing.get_context("fork")
mp_ctx = get_mp_context()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think get_mp_context and maybe_force_spawn are hardware utility functions. I think I can do a follow up to move these into their own multiprocessor.py util file and have that import the hardware_util functions

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this to platform_utils? Since most of these utils depend on which platform is used

Signed-off-by: Jonathan <chenleejonathan@gmail.com>
@DarkLight1337 DarkLight1337 changed the title [Chore] Separate out vllm.utils.hardware_utils.py [Chore] Separate out vllm.utils.platform_utils.py Oct 23, 2025
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM now

@DarkLight1337
Copy link
Member

Please fix pre-commit though

Signed-off-by: Jonathan <chenleejonathan@gmail.com>
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) October 23, 2025 16:01
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 23, 2025
@DarkLight1337 DarkLight1337 merged commit ca76486 into vllm-project:main Oct 23, 2025
66 checks passed
albertoperdomo2 pushed a commit to albertoperdomo2/vllm that referenced this pull request Oct 23, 2025
Signed-off-by: Jonathan <chenleejonathan@gmail.com>
Signed-off-by: Alberto Perdomo <aperdomo@redhat.com>
kingsmad pushed a commit to kingsmad/vllm that referenced this pull request Oct 25, 2025
Signed-off-by: Jonathan <chenleejonathan@gmail.com>
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
Signed-off-by: Jonathan <chenleejonathan@gmail.com>
Signed-off-by: 0xrushi <6279035+0xrushi@users.noreply.github.com>
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
Signed-off-by: Jonathan <chenleejonathan@gmail.com>
Signed-off-by: 0xrushi <6279035+0xrushi@users.noreply.github.com>
wangxiyuan pushed a commit to vllm-project/vllm-ascend that referenced this pull request Oct 28, 2025
### What this PR does / why we need it?

vllm-project/vllm@c9461e0

Fix ```spec decode rejection sampler```, caused by
vllm-project/vllm#26060
Fix some ```import```, caused by
vllm-project/vllm#27374
Fix ```scheduler_config.send_delta_data```, caused by
#3719
Fix ```init_with_cudagraph_sizes```, caused by
vllm-project/vllm#26016
Fix ```vl model```of replacing PatchEmbed's conv3d to linear layer,
caused by vllm-project/vllm#27418

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with new added/existing test.


- vLLM version: v0.11.0rc3
- vLLM main:
vllm-project/vllm@c9461e0

---------

Signed-off-by: Icey <1790571317@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding tpu Related to Google TPUs v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants