-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[Core] remove cupy dependency #3625
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
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
24868ee
update CMakeLists.txt
youkaichao 0af327b
import file from huge PR
youkaichao d3439b9
isort
youkaichao 37fd9fd
support amd rccl
youkaichao 9ec0b67
leave todo
youkaichao 4904b72
add pynccl into test
youkaichao 53e2ca3
linter
youkaichao 5cdeb59
update and merge from vllm/worker/model_runner.py in main
youkaichao af94dc6
fix isort
youkaichao af8e254
restore and merge vllm/worker/worker.py
youkaichao db3044a
fix hip condition
youkaichao f078110
fix cuda condition
youkaichao 18c9437
add error message when libnccl cannot be found
youkaichao 3f1db02
fix test
youkaichao 6c7082d
fix lint
youkaichao 80eec0b
restore test of model and llava
youkaichao efb52bf
try to clean up cupy
youkaichao e6fb64d
lint
youkaichao 5eb972e
unify init_method
youkaichao 915213c
further cleanup cupy
youkaichao 9b4d6fc
do not know why, but this fixes ray test
youkaichao 983243e
merge distributed tests
youkaichao d2c9b4b
update comment for allreduce graph capture
youkaichao cefae38
explain why delete CUDA_VISIBLE_DEVICES
youkaichao da58b34
explain update_env
youkaichao 850eca1
move successful load message to debug level
youkaichao 0ed6527
fix lint
youkaichao 0361127
restore CMakeLists.txt
youkaichao 6d18496
leave a todo for __del__
youkaichao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import multiprocessing | ||
| import os | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from vllm.model_executor.parallel_utils.pynccl import (NCCLCommunicator, | ||
| ncclGetUniqueId) | ||
|
|
||
|
|
||
| def distributed_run(fn, world_size): | ||
| number_of_processes = world_size | ||
| processes = [] | ||
| for i in range(number_of_processes): | ||
| env = os.environ.copy() | ||
| env['RANK'] = str(i) | ||
| env['WORLD_SIZE'] = str(number_of_processes) | ||
| env['MASTER_ADDR'] = 'localhost' | ||
| env['MASTER_PORT'] = '12345' | ||
| p = multiprocessing.Process(target=fn, args=(env, )) | ||
| processes.append(p) | ||
| p.start() | ||
|
|
||
| for p in processes: | ||
| p.join() | ||
|
|
||
|
|
||
| def update_env(fn): | ||
youkaichao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # `multiprocessing.Process` cannot accept environment variables directly | ||
| # so we need to pass the environment variables as arguments | ||
| # and update the environment variables in the function | ||
| def wrapper(env): | ||
| import os | ||
| os.environ.update(env) | ||
| fn() | ||
|
|
||
| return wrapper | ||
|
|
||
|
|
||
| @update_env | ||
| def worker_fn(): | ||
| comm = NCCLCommunicator() | ||
| tensor = torch.ones(16, 1024, 1024, dtype=torch.float32).cuda(comm.rank) | ||
| comm.all_reduce(tensor) | ||
| result = tensor.mean().cpu().item() | ||
| assert result == comm.world_size | ||
|
|
||
|
|
||
| @pytest.mark.skipif(torch.cuda.device_count() < 2, | ||
| reason="Need at least 2 GPUs to run the test.") | ||
| def test_pynccl(): | ||
| distributed_run(worker_fn, 2) | ||
|
|
||
|
|
||
| @update_env | ||
| def worker_fn_with_cudagraph(): | ||
| with torch.no_grad(): | ||
| graph = torch.cuda.CUDAGraph() | ||
| comm = NCCLCommunicator() | ||
| # run something in the default stream to initialize torch engine | ||
| a = torch.ones((4, 4), device=f'cuda:{comm.rank}') | ||
| torch.cuda.synchronize() | ||
| with torch.cuda.graph(graph, stream=comm.stream): | ||
| # operation during the graph capture is recorded but not executed | ||
| # see https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#creating-a-graph-using-stream-capture # noqa | ||
| comm.all_reduce(a) | ||
| comm.stream.synchronize() | ||
| assert a.mean().cpu().item() == comm.world_size**0 | ||
| graph.replay() | ||
| comm.stream.synchronize() | ||
| assert a.mean().cpu().item() == comm.world_size**1 | ||
|
|
||
|
|
||
| @pytest.mark.skipif(torch.cuda.device_count() < 2, | ||
| reason="Need at least 2 GPUs to run the test.") | ||
| def test_pynccl_with_cudagraph(): | ||
| distributed_run(worker_fn_with_cudagraph, 2) | ||
|
|
||
|
|
||
| def test_ncclGetUniqueId(): | ||
| unique_id = ncclGetUniqueId() | ||
| # `list(unique_id.internal)` is something like this: | ||
| # [34, -16, 23, 83, 109, -19, 59, 95, 2, 0, -86, 55, 10, -128, 0, 29, 0, | ||
| # 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| # 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| # 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| # 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| # 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
| # as long as the function doesn't raise an exception, we're good | ||
| assert unique_id is not None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.