2024-09-12 21:36:41 -07:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from sglang.test.test_utils import (
|
|
|
|
|
DEFAULT_MODEL_NAME_FOR_TEST,
|
|
|
|
|
DEFAULT_MOE_MODEL_NAME_FOR_TEST,
|
2025-03-26 07:53:12 +08:00
|
|
|
CustomTestCase,
|
2025-03-10 01:24:22 -07:00
|
|
|
get_bool_env_var,
|
2024-09-14 15:38:37 -07:00
|
|
|
is_in_ci,
|
2024-11-21 20:07:48 -08:00
|
|
|
run_bench_one_batch,
|
2025-01-21 02:55:14 -08:00
|
|
|
write_github_step_summary,
|
2024-09-12 21:36:41 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-03-26 07:53:12 +08:00
|
|
|
class TestBenchOneBatch(CustomTestCase):
|
2025-01-21 02:55:14 -08:00
|
|
|
def test_bs1(self):
|
2025-03-08 05:23:06 -08:00
|
|
|
output_throughput = run_bench_one_batch(
|
|
|
|
|
DEFAULT_MODEL_NAME_FOR_TEST, ["--cuda-graph-max-bs", "2"]
|
|
|
|
|
)
|
2024-09-12 21:36:41 -07:00
|
|
|
|
2024-09-14 15:38:37 -07:00
|
|
|
if is_in_ci():
|
2025-01-21 02:55:14 -08:00
|
|
|
write_github_step_summary(
|
|
|
|
|
f"### test_bs1\n"
|
|
|
|
|
f"output_throughput : {output_throughput:.2f} token/s\n"
|
|
|
|
|
)
|
2024-11-17 15:48:12 -08:00
|
|
|
self.assertGreater(output_throughput, 135)
|
2024-09-12 21:36:41 -07:00
|
|
|
|
2025-01-21 02:55:14 -08:00
|
|
|
def test_moe_tp2_bs1(self):
|
2024-11-21 20:07:48 -08:00
|
|
|
output_throughput = run_bench_one_batch(
|
2025-03-08 05:23:06 -08:00
|
|
|
DEFAULT_MOE_MODEL_NAME_FOR_TEST, ["--tp", "2", "--cuda-graph-max-bs", "2"]
|
2024-09-12 21:36:41 -07:00
|
|
|
)
|
|
|
|
|
|
2025-03-10 01:24:22 -07:00
|
|
|
use_vllm_custom_allreduce = get_bool_env_var(
|
2025-03-18 00:46:41 -07:00
|
|
|
"USE_VLLM_CUSTOM_ALLREDUCE", default="false"
|
2025-03-10 01:24:22 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-14 15:38:37 -07:00
|
|
|
if is_in_ci():
|
2025-01-21 02:55:14 -08:00
|
|
|
write_github_step_summary(
|
2025-03-10 01:24:22 -07:00
|
|
|
f"### test_moe_tp2_bs1 ({use_vllm_custom_allreduce=})\n"
|
2025-01-21 02:55:14 -08:00
|
|
|
f"output_throughput : {output_throughput:.2f} token/s\n"
|
|
|
|
|
)
|
2025-02-24 16:17:38 -08:00
|
|
|
self.assertGreater(output_throughput, 124)
|
2024-09-12 21:36:41 -07:00
|
|
|
|
2025-01-21 02:55:14 -08:00
|
|
|
def test_torch_compile_tp2_bs1(self):
|
|
|
|
|
output_throughput = run_bench_one_batch(
|
|
|
|
|
DEFAULT_MODEL_NAME_FOR_TEST,
|
|
|
|
|
["--tp", "2", "--enable-torch-compile", "--cuda-graph-max-bs", "2"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if is_in_ci():
|
|
|
|
|
write_github_step_summary(
|
|
|
|
|
f"### test_torch_compile_tp2_bs1\n"
|
|
|
|
|
f"output_throughput : {output_throughput:.2f} token/s\n"
|
|
|
|
|
)
|
2025-02-24 16:17:38 -08:00
|
|
|
self.assertGreater(output_throughput, 235)
|
2025-01-21 02:55:14 -08:00
|
|
|
|
2024-09-12 21:36:41 -07:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|