forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] allow callable in collective_rpc (vllm-project#12151)
Signed-off-by: youkaichao <[email protected]> Signed-off-by: Isotr0py <[email protected]>
- Loading branch information
1 parent
72c4266
commit d7d1f20
Showing
13 changed files
with
147 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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,36 @@ | ||
import pytest | ||
|
||
from vllm import LLM | ||
|
||
from ...utils import fork_new_process_for_each_test | ||
|
||
|
||
@pytest.mark.parametrize("tp_size", [1, 2]) | ||
@pytest.mark.parametrize("backend", ["mp", "ray"]) | ||
@fork_new_process_for_each_test | ||
def test_collective_rpc(tp_size, backend): | ||
if tp_size == 1 and backend == "ray": | ||
pytest.skip("Skip duplicate test case") | ||
if tp_size == 1: | ||
backend = None | ||
|
||
# intentionally define the method and class in the test function, | ||
# to test if they can be serialized and sent to the workers | ||
def echo_rank(self): | ||
return self.rank | ||
|
||
from vllm.worker.worker import Worker | ||
|
||
class MyWorker(Worker): | ||
|
||
def echo_rank(self): | ||
return self.rank | ||
|
||
llm = LLM(model="meta-llama/Llama-3.2-1B-Instruct", | ||
enforce_eager=True, | ||
load_format="dummy", | ||
tensor_parallel_size=tp_size, | ||
distributed_executor_backend=backend, | ||
worker_cls=MyWorker) | ||
for method in ["echo_rank", echo_rank]: | ||
assert llm.collective_rpc(method) == list(range(tp_size)) |
This file contains 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 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 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 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 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 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 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.