Skip to content
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

[Core][ROCm][AMD] Add optional torchrun multi GPU executor #3691

Closed
wants to merge 6 commits into from

Conversation

gshtras
Copy link
Contributor

@gshtras gshtras commented Mar 28, 2024

Adding a new multi GPU executor based on torchrun parallel execution for ROCm runs.
This can be overridden by explicitly passing the existing worker_use_ray flag.
The goal is to address the latency issues on TP>1 when using ray on ROCm
The new executor is based on the existing GPUExecutor, except in the torchrun model since the entire main module is run multiple times in parallel, we'll have multiple instances of it.
The concept of having a driver worker and a pool of supplementary workers is preserved, as well as how the model is sliced between them.
The rank, the device ordeal and whether the current executor holds the driver worker is defined by environment variables set by torchrun.

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


PR Checklist (Click to Expand)

Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Model] for adding a new model or improving an existing model. Model name should appear in the title.
  • [Frontend] For changes on the vLLM frontend (e.g., OpenAI API server, LLM class, etc.)
  • [Kernel] for changes affecting CUDA kernels or other compute kernels.
  • [Core] for changes in the core vLLM logic (e.g., LLMEngine, AsyncLLMEngine, Scheduler, etc.)
  • [Hardware][Vendor] for hardware-specific changes. Vendor name should appear in the prefix (e.g., [Hardware][AMD]).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • We adhere to Google Python style guide and Google C++ style guide.
  • Pass all linter checks. Please use format.sh to format your code.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Include sufficient tests to ensure the project to stay correct and robust. This includes both unit tests and integration tests.
  • Please add documentation to docs/source/ if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.

Notes for Large Changes

Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with rfc-required and might not go through the PR.

What to Expect for the Reviews

The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:

  • After the PR is submitted, the PR will be assigned to a reviewer. Every reviewer will pick up the PRs based on their expertise and availability.
  • After the PR is assigned, the reviewer will provide status update every 2-3 days. If the PR is not reviewed within 7 days, please feel free to ping the reviewer or the vLLM team.
  • After the review, the reviewer will put an action-required label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.
  • Please respond to all comments within a reasonable time frame. If a comment isn't clear or you disagree with a suggestion, feel free to ask for clarification or discuss the suggestion.

Thank You

Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!

@gshtras gshtras changed the title [Core] Add optional torchrun multi GPU executor [Core][ROCm] Add optional torchrun multi GPU executor Mar 28, 2024
@gshtras gshtras changed the title [Core][ROCm] Add optional torchrun multi GPU executor [Core][ROCm][AMD] Add optional torchrun multi GPU executor Mar 28, 2024
@WoosukKwon
Copy link
Collaborator

@zhuohan123 Could you please take a look at this? This PR is pretty interesting.

@WoosukKwon WoosukKwon requested a review from zhuohan123 March 29, 2024 22:30
@WoosukKwon
Copy link
Collaborator

@njhill I believe this can be related to #3466 ? Could you also take a look?

@njhill
Copy link
Member

njhill commented Mar 30, 2024

@gshtras correct me if I'm wrong but I think this will only work for launching self-contained offline batch jobs?

For interactive cases including deploying as an API server, additional coordination would be needed to distribute new requests and cancellations in a fully synchronized manner. So some kind of separate front-end and RPC setup would be needed, and may defeat the purpose of what you're trying to achieve here.

The goal is to address the latency issues on TP>1 when using ray on ROCm

Are these issues somehow unique to the combination of ROCm and ray? I'm a bit confused about how this would be a ROCm-specific thing.

I do have an idea of what the problem is and actually am working on another change that should hopefully help. But it's more about how the TP coordination is done in general and not specific to ROCm.

Perhaps you could try out #3466 in the meantime? (we're keen to get that merged soon!). I don't expect it will address the TP latency issues you're seeing by itself, but may be interesting to check just in case.

@njhill
Copy link
Member

njhill commented Mar 31, 2024

Perhaps you could try out #3466 in the meantime? (we're keen to get that merged soon!). I don't expect it will address the TP latency issues you're seeing by itself, but may be interesting to check just in case.

@gshtras actually I now expect that PR may give some TP latency benefit, see comment.

@njhill
Copy link
Member

njhill commented Apr 2, 2024

For interactive cases including deploying as an API server, additional coordination would be needed to distribute new requests and cancellations in a fully synchronized manner. So some kind of separate front-end and RPC setup would be needed, and may defeat the purpose of what you're trying to achieve here.

Just to elaborate on this a bit. AFAIK the entrypoint for torchrun is the same for every process. So there would need to be a check to only start the api server if rank==0, the other procs should just enter a loop similar to this. But then there's nothing to signal them to restart the loop when new requests arrive (they would have to just wait on the nccl broadcast which will freeze the process and fatally timeout), or to handle other tasks like adding/removing lora adapters.

One possibility that would take #3763 further is to have the workers in fact wait on the broadcast operation but for the driver worker to wake them up every few seconds when idle to avoid NCCL timeout. This could avoid the need for any additional RPC mechanism...

@gshtras
Copy link
Contributor Author

gshtras commented Apr 2, 2024

API server

That is a good point, this mode wasn't taken into consideration. Since as you mention there doesn't seem to be an obvious easy way of syncing things, I think it's best to restrict the new executor from being used in the interactive mode.

Perhaps you could try out #3466 in the meantime?

Will take a look, thanks

@gshtras
Copy link
Contributor Author

gshtras commented Jul 18, 2024

Lately mp executor shows even better number. So this one is no longer required

@gshtras gshtras closed this Jul 18, 2024
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.

3 participants