Skip to content

Conversation

chaojun-zhang
Copy link
Contributor

@chaojun-zhang chaojun-zhang commented Jul 16, 2025

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.

Purpose

torchrun pre-initializes the distributed environment, binding the default group to the Gloo backend, will cause the all_reduce with xpu tensor won't work. fix by specifying the group as the device group referred to by get_world_group

Test Plan

export VLLM_WORKER_MULTIPROC_METHOD=spawn
cd tests/
torchrun --nproc-per-node=4 distributed/test_torchrun_example.py

Test Result

(Optional) Documentation Update

Signed-off-by: chzhang <chaojun.zhang@intel.com>
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 enables torchrun for XPU workers by specifying the correct process group for the all_reduce warmup call. The change is correct for multi-GPU scenarios. However, I've identified a critical issue where this could lead to a crash in single-GPU environments. I've provided a suggestion to make the all_reduce call conditional on the world size to ensure robustness.

Comment on lines +159 to +160
torch.distributed.all_reduce(torch.zeros(1).xpu(),
group=get_world_group().device_group)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This all_reduce call for warming up oneCCL is necessary for multi-GPU setups, but it will likely fail in a single-GPU environment (world_size=1), especially if torch.distributed is not initialized. The warmup is not needed for a single device.

To prevent crashes in single-GPU deployments, this operation should be conditional on self.parallel_config.world_size > 1.

Suggested change
torch.distributed.all_reduce(torch.zeros(1).xpu(),
group=get_world_group().device_group)
if self.parallel_config.world_size > 1:
torch.distributed.all_reduce(torch.zeros(1).xpu(),
group=get_world_group().device_group)

Copy link
Collaborator

Choose a reason for hiding this comment

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

the reason we introduce this is there are know hang issue in previous oneccl/torch-ccl. This should be fixed in recent low level updates, confirmed that torch 2.8 should be fixed.
So I think we can keep this for now. and we should remove this trick when upgrade to torch 2.8.

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@jikunshang
Copy link
Collaborator

LGTM. cc @ys950902 Please take a look.

@xuechendi
Copy link
Contributor

@simon-mo @DarkLight1337 , may you help to review this PR?

@vllm-bot vllm-bot merged commit 25d585a into vllm-project:main Jul 22, 2025
13 of 15 checks passed
zixi-qi pushed a commit to zixi-qi/vllm that referenced this pull request Jul 23, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: qizixi <qizixi@meta.com>
LyrisZhong pushed a commit to LyrisZhong/vllm that referenced this pull request Jul 23, 2025
avigny pushed a commit to avigny/vllm that referenced this pull request Jul 31, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: avigny <47987522+avigny@users.noreply.github.com>
wenscarl pushed a commit to wenscarl/vllm that referenced this pull request Aug 4, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: shuw <shuw@nvidia.com>
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: x22x22 <wadeking@qq.com>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
taneem-ibrahim pushed a commit to taneem-ibrahim/vllm that referenced this pull request Aug 14, 2025
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
…llm-project#21021)

Signed-off-by: chzhang <chaojun.zhang@intel.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 27, 2025
googlercolin pushed a commit to googlercolin/vllm that referenced this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants