-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[MISC] Support multi node inference with Neuron #8692
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
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 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 do one of these:
🚀 |
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.
Thanks @sssrijan-amazon for contributing to multi-node support. Please try to reuse existing world size prediction logic, instead of introducing a new world_size argument explicitly.
examples/offline_inference_neuron.py
Outdated
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.
I'm confuse with world_size=1, while TP size=2. Isn't world_size predictable from number of nodes times local TP size?
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.
Compared to single node tensor parallel, multi-node tensor parallel shards the model weights in the same way but having mores cores across nodes. In the meantime, it requires each node’s model.forward() receives the exact same input, otherwise there would be unexpected behaviors (runtime failure, wrong output).
For Neuron multi node inference, we need to broadcast the API input params across all the nodes. So the world size for Neuron within the scope of Vllm is the number of nodes on which we perform inference instead of TP*PP as model parallelism is handled within the context of neuron (outside the scope of vllm)
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.
we can still reuse existing vLLM config argument to calculate world size, right? I'm trying to understand what blocker did you face in reusing the existing config arguments.
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.
If we use the existing flow of using world_size = TP*PP then it would come out to be 64 for a cluster of 2 trn1/trn1n instances. This causes the init_process_group to hang as we only initialize it with 2 ranks (0 and 1 from each node of the cluster) instead of all the ranks.
This was currently working for single node inference with TP=32 because we had hard coded the world size to 1 while initializing the process groups here instead of using world_size = TP*PP which would be 32.
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.
we can send fake input to init_process_group so that we won't get hang there, and send real inputs to where it actually matters.
examples/offline_inference_neuron.py
Outdated
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.
i think the consistency of user interface matters. it's hard to understand what to expect when we set default as TP=2, PP=1, world_size=1
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.
Done, refactored to keep interface consistent.
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.
i guess we don't need these local setup in the upstream.
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.
export NEURON_RT_ROOT_COMM_ID
export NEURON_RANK_ID
export NEURON_LOCAL_TP
export VLLM_HOST_IP
export VLLM_PORT
These are required for multi node inference using transformers-neuronx library. I can get rid of the RT install part.
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.
Does it make sense to refactor this + the base api_server.py so we have something we can deduplicate this and extend in the future?
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.
Done.
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.
let's rename to run_driver
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.
Done.
omrishiv
left a comment
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.
Can we add some documentation on the neuron side on how to run multi node inference?
vllm/executor/neuron_executor.py
Outdated
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.
Let's change to
rank=int(os.getenv("NEURON_RANK_ID", 0)),
local_rank=rank, # Make sure we explain this
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.
Local rank is not utilized with neuron multi instance flow. Using local rank as 0 given we have 1 process per node for neuron.
Added instructions for neuron cluster setup and details in the run script. |
omrishiv
left a comment
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.
Thanks @sssrijan-amazon for working through this! LGTM from a code perspective, but I'll defer to @liangfu for neuron compatibility.
@simon-mo we've talked internally about making the api_server more extensible. The change has helped dedupe code and should make it more reusable in the future. Hopefully that's ok?
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.
Thanks for the updates.
There seems to be some unnecessary complications here in the current design. My impression is that we should be able to follow existing practise in https://docs.vllm.ai/en/latest/serving/distributed_serving.html , and simply run multi-node with
vllm serve /path/to/the/model/in/the/container \
--tensor-parallel-size 128
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.
it would be better if we detect this with ray support for neuron, in order to convert this into a scalable design.
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.
i think there is room to simply this design, so that we don't need to introduce the dependency to either slurm or kubernetes.
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.
i would prefer to write these in the document, if this is the required setup for every time we run the follow python script.
if this is required purely for setup purpose, it will be better if we mention in the document and explain the reason.
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.
i think we can read these into the python script, to avoid the complication here. or is that even feasible ?
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.
can we follow the practise in https://docs.vllm.ai/en/latest/serving/distributed_serving.html , and simply run multi-node with
vllm serve /path/to/the/model/in/the/container \
--tensor-parallel-size 128
|
Sorry dumb question, why do we need a separate api server? |
FILL IN THE PR DESCRIPTION HERE
This change adds support for multi node tensor parallelism inference on neuron device using AWS Neuron Transformers Neuronx library. Refer multi-node inference guide here
Example to run meta llama 3.1 70B model on 2 node trn1n cluster with TP = 64
Pre-req to setup the cluster - https://awsdocs-neuron.readthedocs-hosted.com/en/latest/frameworks/torch/torch-neuronx/setup-trn1-multi-node-execution.html
offline_multi_node_inference_neuron.py
Node 1 command line:
NEURON_RT_ROOT_COMM_ID=10.1.201.64:63423 NEURON_RANK_ID=0 NEURON_LOCAL_TP=32 VLLM_HOST_IP=10.1.201.64 VLLM_PORT=8989 python3 offline_multi_node_inference_neuron.pyNode 2 command line:
NEURON_RT_ROOT_COMM_ID=10.1.201.64:63423 NEURON_RANK_ID=1 NEURON_LOCAL_TP=32 VLLM_HOST_IP=10.1.201.64 VLLM_PORT=8989 python3 offline_multi_node_inference_neuron.pyBEFORE 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,LLMclass, 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:
format.shto format your code.docs/source/if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Adding or changing kernels
Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.
Tensorsrequire meta-functions. Meta-functions should be implemented and registered in python so that dynamic dims can be handled automatically. See above documents for a description of meta-functions.torch.libary.opcheck()to test the function registration and meta-function for any registered ops. Seetests/kernelsfor examples.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-requiredand 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:
action-requiredlabel on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.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!