2024-07-02 10:58:08 -07:00
|
|
|
import pytest
|
|
|
|
|
2024-07-18 16:41:06 -07:00
|
|
|
from ..utils import compare_two_settings
|
2024-07-02 10:58:08 -07:00
|
|
|
|
|
|
|
|
2024-07-16 15:44:22 -07:00
|
|
|
@pytest.mark.parametrize(
|
2024-07-17 04:25:10 -04:00
|
|
|
"TP_SIZE, PP_SIZE, EAGER_MODE, CHUNKED_PREFILL, MODEL_NAME", [
|
2024-07-16 15:44:22 -07:00
|
|
|
(2, 2, 0, 1, "meta-llama/Meta-Llama-3-8B"),
|
|
|
|
(2, 2, 1, 0, "meta-llama/Meta-Llama-3-8B"),
|
|
|
|
(1, 3, 0, 0, "meta-llama/Meta-Llama-3-8B"),
|
2024-07-17 04:25:10 -04:00
|
|
|
(1, 4, 0, 1, "meta-llama/Meta-Llama-3-8B"),
|
|
|
|
(1, 4, 1, 0, "meta-llama/Meta-Llama-3-8B"),
|
2024-07-16 15:44:22 -07:00
|
|
|
])
|
|
|
|
def test_compare_tp(TP_SIZE, PP_SIZE, EAGER_MODE, CHUNKED_PREFILL, MODEL_NAME):
|
2024-07-17 19:26:04 -07:00
|
|
|
|
2024-07-16 15:44:22 -07:00
|
|
|
pp_args = [
|
2024-07-02 10:58:08 -07:00
|
|
|
# use half precision for speed and memory savings in CI environment
|
|
|
|
"--dtype",
|
|
|
|
"bfloat16",
|
|
|
|
"--pipeline-parallel-size",
|
|
|
|
str(PP_SIZE),
|
|
|
|
"--tensor-parallel-size",
|
|
|
|
str(TP_SIZE),
|
|
|
|
"--distributed-executor-backend",
|
|
|
|
"ray",
|
|
|
|
]
|
2024-07-16 15:44:22 -07:00
|
|
|
|
|
|
|
# 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",
|
2024-07-17 19:26:04 -07:00
|
|
|
str(max(TP_SIZE, 2)), # We only use 2 GPUs in the CI.
|
2024-07-16 15:44:22 -07:00
|
|
|
"--distributed-executor-backend",
|
|
|
|
"mp",
|
|
|
|
]
|
2024-07-02 10:58:08 -07:00
|
|
|
if CHUNKED_PREFILL:
|
2024-07-16 15:44:22 -07:00
|
|
|
pp_args.append("--enable-chunked-prefill")
|
|
|
|
tp_args.append("--enable-chunked-prefill")
|
2024-07-02 10:58:08 -07:00
|
|
|
if EAGER_MODE:
|
2024-07-16 15:44:22 -07:00
|
|
|
pp_args.append("--enforce-eager")
|
|
|
|
tp_args.append("--enforce-eager")
|
|
|
|
|
2024-07-18 16:41:06 -07:00
|
|
|
compare_two_settings(MODEL_NAME, pp_args, tp_args)
|