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

[Bugfix] Fix custom all reduce nvlink check on multi node #4903

Closed
wants to merge 4 commits into from

Conversation

esmeetu
Copy link
Collaborator

@esmeetu esmeetu commented May 19, 2024

pynvml.nvmlDeviceGetHandleByIndex will throw error when index is larger than the node's max device count index.

For example. Serving using two nodes:
node1: [0,1,2,3]
node2: [0,1]
and the final physical_device_ids will be [0,1,2,3,0,1]. Node 2 will throw error when it encounter 2 and 3 which is larger than its max device index(1).

Another example:
node1: [0,1]
node2: [0,1]
the final physical_device_ids will be [0,1,0,1]. So the NVLINK status will be repeatedly checked.

I think it is unnecessary to using all_gather to get physical_device_ids where we can get that from device_ids directly. Correct me if i miss anything. @youkaichao


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!

@esmeetu esmeetu requested a review from youkaichao May 19, 2024 02:44
# test nvlink first, this will filter out most of the cases
# where custom allreduce is not supported
# this checks hardware and driver support for NVLink
full_nvlink = _is_full_nvlink(physical_device_ids)
full_nvlink = _is_full_nvlink(device_ids)
Copy link
Member

Choose a reason for hiding this comment

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

This is not true. Sometimes, e.g. in the testing code, we manually remove cuda visible devices variables, and the process can see all device ids. However, we only need to check nvlink topology within several gpus, rather than all.

@youkaichao
Copy link
Member

What is your intended usecase? I think no one uses a TP group that crosses machine boundary. The designed use case is to use TP inside a node.

@esmeetu
Copy link
Collaborator Author

esmeetu commented May 19, 2024

@youkaichao I want to serve a big model across multi nodes by using tensor parallelism. One node's memory cannot afford a model.

The designed use case is to use TP inside a node.

Do you mean custom all reduce feature? If so, we should check if using tp inside a node before nvlink status check.

@youkaichao
Copy link
Member

we should check if using tp inside a node before nvlink status check

I would vote for this. maybe with another all_gather to get all host ips, and disable custom allreduce when we have multiple host ips.

@esmeetu
Copy link
Collaborator Author

esmeetu commented May 19, 2024

@youkaichao I revert changes and check device_ids length with word_size to identify if serving on multi nodes before nvlink status check. Is that ok?

Comment on lines 141 to 146
if len(device_ids) < world_size:
logger.warning(
"Custom allreduce is disabled because this feature is "
"not intended for multi node use case.")
return

Copy link
Member

Choose a reason for hiding this comment

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

This might be wrong. We cannot assume CUDA_VISIBLE_DEVICES is always set. If not set, device_ids will be all devices (e.g. 8), but we should be able to use custom allreduce with world_size 2 or 4.

@esmeetu
Copy link
Collaborator Author

esmeetu commented May 19, 2024

@youkaichao Please take a look again.

Comment on lines +152 to +158
# 3 nodes will be like [0,1,2,3,0,1,0,1]
if sorted(physical_device_ids)[-1] + 1 != world_size:
logger.warning(
"Custom allreduce is disabled because this feature is "
"not intended for multi node use case.")
return

Copy link
Member

Choose a reason for hiding this comment

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

This is still not safe. It is possible, that one node uses gpu 0, 1 , while the other node uses 2, 3, and the world size is 4. In this case, we cannot use custom allreduce. However, this code will not capture it.

@youkaichao
Copy link
Member

we should check if using tp inside a node before nvlink status check

If you want to detect whether a tp group spans across a node, all_gather to get all host ips is a feasible and sound idea. Why do you try so many ways to approximate it?

@esmeetu
Copy link
Collaborator Author

esmeetu commented May 20, 2024

@youkaichao I think i was not clear about this part code. Your suggestion is good. Thanks for your careful review!

@youkaichao
Copy link
Member

close as #5369 is a better alternative.

@youkaichao youkaichao closed this Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants