forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MISC] Introduce pipeline parallelism partition strategies (vllm-proj…
…ect#6920) Co-authored-by: youkaichao <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from vllm.distributed.utils import get_pp_indices | ||
|
||
|
||
def test_custom_layer_partition(): | ||
|
||
def _verify(partition_str, num_layers, pp_size, goldens): | ||
bak = os.environ.get("VLLM_PP_LAYER_PARTITION", None) | ||
os.environ["VLLM_PP_LAYER_PARTITION"] = partition_str | ||
for pp_rank, golden in enumerate(goldens): | ||
assert get_pp_indices(num_layers, pp_rank, pp_size) == golden | ||
if bak is not None: | ||
os.environ["VLLM_PP_LAYER_PARTITION"] = bak | ||
|
||
# Even partition | ||
_verify("5,5,5,5", 20, 4, [(0, 5), (5, 10), (10, 15), (15, 20)]) | ||
# Balanced partition | ||
_verify("4,6,6,4", 20, 4, [(0, 4), (4, 10), (10, 16), (16, 20)]) | ||
# Put reminder somewhere | ||
_verify("5,6,5,6", 22, 4, [(0, 5), (5, 11), (11, 16), (16, 22)]) | ||
# Invalid partition strings | ||
with pytest.raises(ValueError): | ||
_verify("5,5,5,5,", 20, 4, [(0, 5), (5, 10), (10, 15), (15, 20)]) | ||
with pytest.raises(ValueError): | ||
_verify("5,5,5,a", 20, 4, [(0, 5), (5, 10), (10, 15), (15, 20)]) | ||
# Wrong number of partitions | ||
with pytest.raises(ValueError): | ||
_verify("5,5,5", 20, 4, [(0, 5), (5, 10), (10, 15), (15, 20)]) | ||
# Wrong number of layers | ||
with pytest.raises(ValueError): | ||
_verify("5,5,5,5", 21, 4, [(0, 5), (5, 10), (10, 15), (15, 20)]) |
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