Skip to content

[Platform][Dist] Make torch distributed process group extendable #18763

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

Merged
merged 2 commits into from
May 28, 2025

Conversation

MengqingCao
Copy link
Contributor

@MengqingCao MengqingCao commented May 27, 2025

part of #11162

Starting from torch 2.6.0, the arg options in ProcessGroup.__init__ has been removed, and ProcessGroup._set_default_backend has been introduced. Howerver, torch 2.5.1 is still be maintained in vllm-ascend. Thus we keep the compatiblity with torch < 2.6 in this pr and make stateless_init_torch_distributed_process_group extendable by platform module.

Mainly changes:

  1. Make torch distributed process group extandable
  2. Make process group initialization for gloo backend compatible with torch < 2.6

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.

🚀

@DarkLight1337 DarkLight1337 changed the title [Platform][Dist] Make torch distributed process group extandable [Platform][Dist] Make torch distributed process group extendable May 27, 2025
Comment on lines 471 to 475
pg: ProcessGroup = ProcessGroup(
prefix_store,
group_rank,
group_size,
)
Copy link
Member

Choose a reason for hiding this comment

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

Why not pass ProcessGroup itself into stateless_init_device_torch_dist_pg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows the platform to customize the specific details when creating pg, for example, in vllm-ascend due to torch version (2.5) compatibility issues, it is necessary to pass in the arg options when creating pg.

Copy link
Member

@DarkLight1337 DarkLight1337 May 27, 2025

Choose a reason for hiding this comment

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

Perhaps we can factor this out into another method like init_process_group

Copy link
Member

Choose a reason for hiding this comment

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

Also, is gloo compatible with all the backends?

Copy link
Contributor Author

@MengqingCao MengqingCao May 27, 2025

Choose a reason for hiding this comment

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

Perhaps we can factor this out into another method like init_process_group

Do you mean refactor this compatibility solution in init_process_group

Also, is gloo compatible with all the backends?

Acctually gloo is a communication backend for cpu, I think it won't be conflicted with the chips like GPU and NPU. I keep it here to make sure all platforms could create process group with gloo backend. But you remind me that I lose the torch compatibility here.

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean refactor this compatibility solution in init_process_group?

Yes. It would also make other backends compatible with gloo in case they need custom initialization of process group

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks! I'll fix it tomorrow :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It would also make other backends compatible with gloo in case they need custom initialization of process group

This has been done now, PTAL

@njhill njhill requested a review from youkaichao May 27, 2025 20:25
Comment on lines +428 to +441
if is_torch_equal_or_newer("2.6"):
pg = ProcessGroup(
prefix_store,
group_rank,
group_size,
)
else:
options = ProcessGroup.Options(backend=backend)
pg = ProcessGroup(
prefix_store,
group_rank,
group_size,
options,
)
Copy link
Member

Choose a reason for hiding this comment

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

Is this code not applicable to all platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, but there still exists diference at ProcessGroup._set_default_backend. Thus I think it's cleaner to create and return a complete process group. And this make the extracted function more complete, rather than doing some preparation for the process group

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.

Alright, thanks for the explanation!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) May 28, 2025 08:21
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 28, 2025
@MengqingCao
Copy link
Contributor Author

Alright, thanks for the explanation!

Thanks for your review 👍

@DarkLight1337 DarkLight1337 merged commit d781930 into vllm-project:main May 28, 2025
72 of 74 checks passed
@MengqingCao MengqingCao deleted the dist branch May 29, 2025 01:05
amitm02 pushed a commit to amitm02/vllm that referenced this pull request Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants