test_pipeline_parallel.py 2.2 KB
Newer Older
1
2
import os

3
4
import pytest

5
from ..utils import compare_two_settings
6

7
8
VLLM_MULTI_NODE = os.getenv("VLLM_MULTI_NODE", "0") == "1"

9

10
@pytest.mark.parametrize(
11
12
13
14
15
16
17
18
19
20
21
22
    "TP_SIZE, PP_SIZE, EAGER_MODE, CHUNKED_PREFILL, MODEL_NAME, DIST_BACKEND",
    [
        (2, 2, 0, 1, "meta-llama/Meta-Llama-3-8B", "ray"),
        (2, 2, 1, 0, "meta-llama/Meta-Llama-3-8B", "ray"),
        (1, 3, 0, 0, "meta-llama/Meta-Llama-3-8B", "ray"),
        (1, 4, 0, 1, "meta-llama/Meta-Llama-3-8B", "ray"),
        (1, 4, 1, 0, "meta-llama/Meta-Llama-3-8B", "ray"),
        (2, 2, 0, 1, "meta-llama/Meta-Llama-3-8B", "mp"),
        (2, 2, 1, 0, "meta-llama/Meta-Llama-3-8B", "mp"),
        (1, 3, 0, 0, "meta-llama/Meta-Llama-3-8B", "mp"),
        (1, 4, 0, 1, "meta-llama/Meta-Llama-3-8B", "mp"),
        (1, 4, 1, 0, "meta-llama/Meta-Llama-3-8B", "mp"),
23
    ])
24
25
26
27
28
def test_compare_tp(TP_SIZE, PP_SIZE, EAGER_MODE, CHUNKED_PREFILL, MODEL_NAME,
                    DIST_BACKEND):
    if VLLM_MULTI_NODE and DIST_BACKEND == "mp":
        pytest.skip("Skipping multi-node pipeline parallel test for "
                    "multiprocessing distributed backend")
29

30
    pp_args = [
31
32
        # use half precision for speed and memory savings in CI environment
        "--dtype",
33
        "float16",
34
35
36
37
38
        "--pipeline-parallel-size",
        str(PP_SIZE),
        "--tensor-parallel-size",
        str(TP_SIZE),
        "--distributed-executor-backend",
39
        DIST_BACKEND,
40
    ]
41
42
43
44
45
46
47
48
49
50
51

    # compare without pipeline parallelism
    # NOTE: use mp backend for TP
    # PP tests might involve multiple nodes, and ray might
    #  schedule all workers in a node other than the head node,
    #  which can cause the test to fail.
    tp_args = [
        # use half precision for speed and memory savings in CI environment
        "--dtype",
        "bfloat16",
        "--tensor-parallel-size",
52
        str(max(TP_SIZE, 2)),  # We only use 2 GPUs in the CI.
53
54
55
        "--distributed-executor-backend",
        "mp",
    ]
56
    if CHUNKED_PREFILL:
57
58
        pp_args.append("--enable-chunked-prefill")
        tp_args.append("--enable-chunked-prefill")
59
    if EAGER_MODE:
60
61
62
        pp_args.append("--enforce-eager")
        tp_args.append("--enforce-eager")

63
    compare_two_settings(MODEL_NAME, pp_args, tp_args)