[AMD] Add AMD CI registration (1-gpu unit test) to nightly CI. (#16941)
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
"""MI35x Nightly performance benchmark for DeepSeek-R1-MXFP4 model.
|
||||
|
||||
This test benchmarks the DeepSeek-R1-MXFP4 quantized model on MI35x with 8 GPUs.
|
||||
|
||||
The model path can be configured via DEEPSEEK_R1_MXFP4_MODEL_PATH environment variable.
|
||||
|
||||
Registry: nightly-perf-8-gpu-mi35x-deepseek-r1-mxfp4 suite
|
||||
|
||||
Example usage:
|
||||
DEEPSEEK_R1_MXFP4_MODEL_PATH=/data2/models/amd-DeepSeek-R1-MXFP4-Preview python -m pytest test_deepseek_r1_mxfp4_perf_mi35x.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Set HF cache to /data2/models/ for MI35x so HF models download there
|
||||
os.environ.setdefault("HF_HOME", "/data2/models/huggingface")
|
||||
os.environ.setdefault("HF_HUB_CACHE", "/data2/models/huggingface/hub")
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - DeepSeek-R1-MXFP4 benchmark on MI35x (~300 min)
|
||||
register_amd_ci(
|
||||
est_time=18000, suite="nightly-perf-8-gpu-mi35x-deepseek-r1-mxfp4", nightly=True
|
||||
)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "MI35x")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model path configuration for MI35x DeepSeek-R1-MXFP4
|
||||
# Priority: 1) env var, 2) local path, 3) HuggingFace model ID
|
||||
DEEPSEEK_R1_MXFP4_LOCAL_PATH = "/data2/models/amd-DeepSeek-R1-MXFP4-Preview"
|
||||
DEEPSEEK_R1_MXFP4_HF_MODEL_ID = "amd/DeepSeek-R1-MXFP4-Preview"
|
||||
PROFILE_DIR = "performance_profiles_deepseek_r1_mxfp4_mi35x"
|
||||
|
||||
|
||||
def get_model_path() -> str:
|
||||
"""Get effective model path: env var > local path > HF model ID."""
|
||||
# Check env var first
|
||||
env_path = os.environ.get("DEEPSEEK_R1_MXFP4_MODEL_PATH")
|
||||
if env_path:
|
||||
return env_path
|
||||
# Check local path
|
||||
if os.path.exists(DEEPSEEK_R1_MXFP4_LOCAL_PATH):
|
||||
return DEEPSEEK_R1_MXFP4_LOCAL_PATH
|
||||
# Fall back to HF model ID
|
||||
return DEEPSEEK_R1_MXFP4_HF_MODEL_ID
|
||||
|
||||
|
||||
class TestDeepseekR1MXFP4PerfMI35x(unittest.TestCase):
|
||||
"""MI35x Nightly performance benchmark for DeepSeek-R1-MXFP4 model.
|
||||
|
||||
Tests the DeepSeek-R1-MXFP4 quantized model on TP=8 with DP=8.
|
||||
Uses local path if available, otherwise downloads from HuggingFace.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = get_model_path()
|
||||
print(f"Using model path: {cls.model}")
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "4096"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
# Define variant configurations for DeepSeek-R1-MXFP4 on MI35x
|
||||
# Only run basic variant for perf (DP/TC/MTP covered in accuracy tests)
|
||||
cls.variants = [
|
||||
{
|
||||
"name": "basic",
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--chunked-prefill-size",
|
||||
"131072",
|
||||
"--disable-radix-cache",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
# Override full_report to remove traces help text
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_one_batch(self):
|
||||
"""Run benchmark across all configured variants."""
|
||||
failed_variants = []
|
||||
|
||||
# For local paths, check if exists. HF model IDs will download automatically.
|
||||
is_local_path = self.model.startswith("/")
|
||||
if is_local_path and not os.path.exists(self.model):
|
||||
print(f"\n⏭️ SKIPPING: Local model not found at {self.model}")
|
||||
self.runner.full_report += (
|
||||
f"\n⏭️ Test skipped: Local model not found at {self.model}\n"
|
||||
)
|
||||
self.runner.write_final_report()
|
||||
return
|
||||
|
||||
# Log model source
|
||||
if is_local_path:
|
||||
print(f"📁 Using local model: {self.model}")
|
||||
else:
|
||||
print(
|
||||
f"📥 Using HuggingFace model: {self.model} (will download if not cached)"
|
||||
)
|
||||
|
||||
try:
|
||||
for variant_config in self.variants:
|
||||
with self.subTest(variant=variant_config["name"]):
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model,
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=variant_config["other_args"],
|
||||
variant=variant_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if not success:
|
||||
failed_variants.append(variant_config["name"])
|
||||
|
||||
# Use simplified report format without traces
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
finally:
|
||||
self.runner.write_final_report()
|
||||
|
||||
if failed_variants:
|
||||
raise AssertionError(
|
||||
f"Benchmark failed for {self.model} with the following variants: "
|
||||
f"{', '.join(failed_variants)}"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,126 @@
|
||||
"""MI35x Nightly performance benchmark for Grok-1 INT4 (W4A8KV8).
|
||||
|
||||
This test benchmarks Grok-1 (314B MOE) with INT4 weight quantization on 8 GPUs.
|
||||
|
||||
Registry: nightly-perf-8-gpu-mi35x-grok1-int4 suite
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - Grok-1 INT4 benchmark on MI35x (~25 min)
|
||||
register_amd_ci(
|
||||
est_time=1500, suite="nightly-perf-8-gpu-mi35x-grok1-int4", nightly=True
|
||||
)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "MI35x")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model and tokenizer paths can be overridden via environment variables
|
||||
GROK1_MODEL_PATH = os.environ.get("GROK1_MODEL_PATH", "amd/grok-1-W4A8KV8")
|
||||
GROK1_TOKENIZER_PATH = os.environ.get("GROK1_TOKENIZER_PATH", "Xenova/grok-1-tokenizer")
|
||||
PROFILE_DIR = "performance_profiles_grok1_int4_mi35x"
|
||||
|
||||
|
||||
class TestGrok1INT4PerfMI35x(unittest.TestCase):
|
||||
"""Test suite for Grok-1 INT4 performance benchmarks on MI35x."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "1024"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
cls.model_config = {
|
||||
"name": "grok1-int4-mi35x",
|
||||
"model_path": GROK1_MODEL_PATH,
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--quantization",
|
||||
"fp8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--tokenizer-path",
|
||||
GROK1_TOKENIZER_PATH,
|
||||
"--attention-backend",
|
||||
"aiter",
|
||||
],
|
||||
"env_vars": {
|
||||
"RCCL_MSCCL_ENABLE": "0",
|
||||
"SGLANG_USE_AITER": "1",
|
||||
"SGLANG_INT4_WEIGHT": "1",
|
||||
},
|
||||
}
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_grok1_int4_perf(self):
|
||||
"""Run Grok-1 INT4 performance benchmark on MI35x."""
|
||||
# Set environment variables
|
||||
old_env = {}
|
||||
for key, value in self.model_config.get("env_vars", {}).items():
|
||||
old_env[key] = os.environ.get(key)
|
||||
os.environ[key] = value
|
||||
print(f"Setting env: {key}={value}")
|
||||
|
||||
try:
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model_config["model_path"],
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=self.model_config["other_args"],
|
||||
variant=self.model_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
|
||||
self.assertTrue(success, "Benchmark failed for Grok-1 INT4 on MI35x")
|
||||
finally:
|
||||
# Restore original environment
|
||||
for key, value in old_env.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
self.runner.write_final_report()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,126 @@
|
||||
"""MI35x Nightly performance benchmark for Grok-2.
|
||||
|
||||
This test benchmarks Grok-2 with FP8 quantization on 8 GPUs.
|
||||
|
||||
Registry: nightly-perf-8-gpu-mi35x-grok2 suite
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - Grok-2 benchmark on MI35x (~25 min)
|
||||
register_amd_ci(est_time=1500, suite="nightly-perf-8-gpu-mi35x-grok2", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "MI35x")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model and tokenizer paths can be overridden via environment variables
|
||||
GROK2_MODEL_PATH = os.environ.get("GROK2_MODEL_PATH", "xai-org/grok-2")
|
||||
GROK2_TOKENIZER_PATH = os.environ.get(
|
||||
"GROK2_TOKENIZER_PATH", "alvarobartt/grok-2-tokenizer"
|
||||
)
|
||||
PROFILE_DIR = "performance_profiles_grok2_mi35x"
|
||||
|
||||
|
||||
class TestGrok2PerfMI35x(unittest.TestCase):
|
||||
"""Test suite for Grok-2 performance benchmarks on MI35x."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "1024"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
cls.model_config = {
|
||||
"name": "grok2-mi35x",
|
||||
"model_path": GROK2_MODEL_PATH,
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--quantization",
|
||||
"fp8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--tokenizer-path",
|
||||
GROK2_TOKENIZER_PATH,
|
||||
"--attention-backend",
|
||||
"aiter",
|
||||
],
|
||||
"env_vars": {
|
||||
"RCCL_MSCCL_ENABLE": "0",
|
||||
"SGLANG_USE_AITER": "1",
|
||||
"SGLANG_INT4_WEIGHT": "0",
|
||||
},
|
||||
}
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_grok2_perf(self):
|
||||
"""Run Grok-2 performance benchmark on MI35x."""
|
||||
# Set environment variables
|
||||
old_env = {}
|
||||
for key, value in self.model_config.get("env_vars", {}).items():
|
||||
old_env[key] = os.environ.get(key)
|
||||
os.environ[key] = value
|
||||
print(f"Setting env: {key}={value}")
|
||||
|
||||
try:
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model_config["model_path"],
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=self.model_config["other_args"],
|
||||
variant=self.model_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
|
||||
self.assertTrue(success, "Benchmark failed for Grok-2 on MI35x")
|
||||
finally:
|
||||
# Restore original environment
|
||||
for key, value in old_env.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
self.runner.write_final_report()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,145 @@
|
||||
"""Nightly performance benchmark for DeepSeek-V3.1 model.
|
||||
|
||||
This test benchmarks the DeepSeek-V3.1 model with basic and MTP configurations on 8 GPUs.
|
||||
|
||||
The model path can be configured via DEEPSEEK_V31_MODEL_PATH environment variable.
|
||||
|
||||
Example usage:
|
||||
DEEPSEEK_V31_MODEL_PATH=deepseek-ai/DeepSeek-V3.1 python -m pytest test_deepseek_v31_perf.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - DeepSeek-V3.1 benchmark (basic + MTP, ~300 min)
|
||||
register_amd_ci(est_time=18000, suite="nightly-perf-8-gpu-deepseek-v31", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model path can be overridden via environment variable
|
||||
DEEPSEEK_V31_MODEL_PATH = os.environ.get(
|
||||
"DEEPSEEK_V31_MODEL_PATH", "deepseek-ai/DeepSeek-V3.1"
|
||||
)
|
||||
PROFILE_DIR = "performance_profiles_deepseek_v31"
|
||||
|
||||
|
||||
class TestNightlyDeepseekV31Performance(unittest.TestCase):
|
||||
"""Nightly performance benchmark for DeepSeek-V3.1 model.
|
||||
|
||||
Tests the DeepSeek-V3.1 model with both basic and MTP configurations on TP=8.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = DEEPSEEK_V31_MODEL_PATH
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "4096"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
# Define variant configurations for DeepSeek-V3.1
|
||||
cls.variants = [
|
||||
{
|
||||
"name": "basic",
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--model-loader-extra-config",
|
||||
'{"enable_multithread_load": true}',
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "mtp",
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--speculative-algorithm",
|
||||
"EAGLE",
|
||||
"--speculative-num-steps",
|
||||
"3",
|
||||
"--speculative-eagle-topk",
|
||||
"1",
|
||||
"--speculative-num-draft-tokens",
|
||||
"4",
|
||||
"--mem-fraction-static",
|
||||
"0.7",
|
||||
"--model-loader-extra-config",
|
||||
'{"enable_multithread_load": true}',
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
# Override full_report to remove traces help text
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_one_batch(self):
|
||||
"""Run benchmark across all configured variants."""
|
||||
failed_variants = []
|
||||
|
||||
try:
|
||||
for variant_config in self.variants:
|
||||
with self.subTest(variant=variant_config["name"]):
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model,
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=variant_config["other_args"],
|
||||
variant=variant_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if not success:
|
||||
failed_variants.append(variant_config["name"])
|
||||
|
||||
# Use simplified report format without traces
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
finally:
|
||||
self.runner.write_final_report()
|
||||
|
||||
if failed_variants:
|
||||
raise AssertionError(
|
||||
f"Benchmark failed for {self.model} with the following variants: "
|
||||
f"{', '.join(failed_variants)}"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,145 @@
|
||||
"""Nightly performance benchmark for DeepSeek-V3 model.
|
||||
|
||||
This test benchmarks the DeepSeek-V3 model with basic and MTP configurations on 8 GPUs.
|
||||
|
||||
The model path can be configured via DEEPSEEK_V3_MODEL_PATH environment variable.
|
||||
|
||||
Example usage:
|
||||
DEEPSEEK_V3_MODEL_PATH=deepseek-ai/DeepSeek-V3-0324 python -m pytest test_deepseek_v3_perf.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - DeepSeek-V3 benchmark (basic + MTP, ~300 min)
|
||||
register_amd_ci(est_time=18000, suite="nightly-perf-8-gpu-deepseek-v3", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model path can be overridden via environment variable
|
||||
DEEPSEEK_V3_MODEL_PATH = os.environ.get(
|
||||
"DEEPSEEK_V3_MODEL_PATH", "deepseek-ai/DeepSeek-V3-0324"
|
||||
)
|
||||
PROFILE_DIR = "performance_profiles_deepseek_v3"
|
||||
|
||||
|
||||
class TestNightlyDeepseekV3Performance(unittest.TestCase):
|
||||
"""Nightly performance benchmark for DeepSeek-V3 model.
|
||||
|
||||
Tests the DeepSeek-V3 model with both basic and MTP configurations on TP=8.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = DEEPSEEK_V3_MODEL_PATH
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "4096"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
# Define variant configurations for DeepSeek-V3
|
||||
cls.variants = [
|
||||
{
|
||||
"name": "basic",
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--model-loader-extra-config",
|
||||
'{"enable_multithread_load": true}',
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "mtp",
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--speculative-algorithm",
|
||||
"EAGLE",
|
||||
"--speculative-num-steps",
|
||||
"3",
|
||||
"--speculative-eagle-topk",
|
||||
"1",
|
||||
"--speculative-num-draft-tokens",
|
||||
"4",
|
||||
"--mem-fraction-static",
|
||||
"0.7",
|
||||
"--model-loader-extra-config",
|
||||
'{"enable_multithread_load": true}',
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
# Override full_report to remove traces help text
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_one_batch(self):
|
||||
"""Run benchmark across all configured variants."""
|
||||
failed_variants = []
|
||||
|
||||
try:
|
||||
for variant_config in self.variants:
|
||||
with self.subTest(variant=variant_config["name"]):
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model,
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=variant_config["other_args"],
|
||||
variant=variant_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if not success:
|
||||
failed_variants.append(variant_config["name"])
|
||||
|
||||
# Use simplified report format without traces
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
finally:
|
||||
self.runner.write_final_report()
|
||||
|
||||
if failed_variants:
|
||||
raise AssertionError(
|
||||
f"Benchmark failed for {self.model} with the following variants: "
|
||||
f"{', '.join(failed_variants)}"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Nightly performance benchmark for Grok-1 FP8.
|
||||
|
||||
This test benchmarks Grok-1 (314B MOE) with FP8 quantization on 8 GPUs.
|
||||
|
||||
Model paths can be configured via environment variables:
|
||||
- GROK1_MODEL_PATH: Path to Grok-1 model (default: lmzheng/grok-1)
|
||||
- GROK1_TOKENIZER_PATH: Path to Grok-1 tokenizer (default: Xenova/grok-1-tokenizer)
|
||||
|
||||
Example usage:
|
||||
python -m pytest test_grok1_fp8_perf.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - Grok-1 FP8 benchmark (~25 min)
|
||||
register_amd_ci(est_time=1500, suite="nightly-perf-8-gpu-grok1-fp8", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model and tokenizer paths can be overridden via environment variables
|
||||
GROK1_MODEL_PATH = os.environ.get("GROK1_MODEL_PATH", "lmzheng/grok-1")
|
||||
GROK1_TOKENIZER_PATH = os.environ.get("GROK1_TOKENIZER_PATH", "Xenova/grok-1-tokenizer")
|
||||
PROFILE_DIR = "performance_profiles_grok1_fp8"
|
||||
|
||||
|
||||
class TestNightlyGrok1FP8Performance(unittest.TestCase):
|
||||
"""Nightly performance benchmark for Grok-1 FP8.
|
||||
|
||||
Tests Grok-1 (314B MOE) with FP8 quantization on TP=8.
|
||||
Runtime: ~25 minutes
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "1024"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
cls.model_config = {
|
||||
"name": "grok1-fp8",
|
||||
"model_path": GROK1_MODEL_PATH,
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--quantization",
|
||||
"fp8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--tokenizer-path",
|
||||
GROK1_TOKENIZER_PATH,
|
||||
"--attention-backend",
|
||||
"aiter",
|
||||
],
|
||||
"env_vars": {
|
||||
"RCCL_MSCCL_ENABLE": "0",
|
||||
"SGLANG_USE_AITER": "1",
|
||||
"SGLANG_INT4_WEIGHT": "0",
|
||||
},
|
||||
}
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_grok1_fp8(self):
|
||||
"""Run benchmark for Grok-1 FP8."""
|
||||
# Set environment variables
|
||||
old_env = {}
|
||||
for key, value in self.model_config.get("env_vars", {}).items():
|
||||
old_env[key] = os.environ.get(key)
|
||||
os.environ[key] = value
|
||||
print(f"Setting env: {key}={value}")
|
||||
|
||||
try:
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model_config["model_path"],
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=self.model_config["other_args"],
|
||||
variant=self.model_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
|
||||
self.assertTrue(success, "Benchmark failed for Grok-1 FP8")
|
||||
finally:
|
||||
# Restore original environment
|
||||
for key, value in old_env.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
self.runner.write_final_report()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Nightly performance benchmark for Grok-1 INT4 (W4A8KV8).
|
||||
|
||||
This test benchmarks Grok-1 (314B MOE) with INT4 weight quantization on 8 GPUs.
|
||||
|
||||
Model paths can be configured via environment variables:
|
||||
- GROK1_MODEL_PATH: Path to Grok-1 INT4 model (default: amd/grok-1-W4A8KV8)
|
||||
- GROK1_TOKENIZER_PATH: Path to Grok-1 tokenizer (default: Xenova/grok-1-tokenizer)
|
||||
|
||||
Example usage:
|
||||
python -m pytest test_grok1_int4_perf.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - Grok-1 INT4 benchmark (~25 min)
|
||||
register_amd_ci(est_time=1500, suite="nightly-perf-8-gpu-grok1-int4", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model and tokenizer paths can be overridden via environment variables
|
||||
GROK1_MODEL_PATH = os.environ.get("GROK1_MODEL_PATH", "amd/grok-1-W4A8KV8")
|
||||
GROK1_TOKENIZER_PATH = os.environ.get("GROK1_TOKENIZER_PATH", "Xenova/grok-1-tokenizer")
|
||||
PROFILE_DIR = "performance_profiles_grok1_int4"
|
||||
|
||||
|
||||
class TestNightlyGrok1INT4Performance(unittest.TestCase):
|
||||
"""Nightly performance benchmark for Grok-1 INT4 (W4A8KV8).
|
||||
|
||||
Tests Grok-1 (314B MOE) with INT4 weight quantization on TP=8.
|
||||
Runtime: ~25 minutes
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "1024"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
cls.model_config = {
|
||||
"name": "grok1-int4",
|
||||
"model_path": GROK1_MODEL_PATH,
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--quantization",
|
||||
"fp8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--tokenizer-path",
|
||||
GROK1_TOKENIZER_PATH,
|
||||
"--attention-backend",
|
||||
"aiter",
|
||||
],
|
||||
"env_vars": {
|
||||
"RCCL_MSCCL_ENABLE": "0",
|
||||
"SGLANG_USE_AITER": "1",
|
||||
"SGLANG_INT4_WEIGHT": "1",
|
||||
},
|
||||
}
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_grok1_int4(self):
|
||||
"""Run benchmark for Grok-1 INT4."""
|
||||
# Set environment variables
|
||||
old_env = {}
|
||||
for key, value in self.model_config.get("env_vars", {}).items():
|
||||
old_env[key] = os.environ.get(key)
|
||||
os.environ[key] = value
|
||||
print(f"Setting env: {key}={value}")
|
||||
|
||||
try:
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model_config["model_path"],
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=self.model_config["other_args"],
|
||||
variant=self.model_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
|
||||
self.assertTrue(success, "Benchmark failed for Grok-1 INT4")
|
||||
finally:
|
||||
# Restore original environment
|
||||
for key, value in old_env.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
self.runner.write_final_report()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,135 @@
|
||||
"""Nightly performance benchmark for Grok-2.
|
||||
|
||||
This test benchmarks Grok-2 with FP8 quantization on 8 GPUs.
|
||||
|
||||
Model paths can be configured via environment variables:
|
||||
- GROK2_MODEL_PATH: Path to Grok-2 model (default: xai-org/grok-2)
|
||||
- GROK2_TOKENIZER_PATH: Path to Grok-2 tokenizer (default: alvarobartt/grok-2-tokenizer)
|
||||
|
||||
Example usage:
|
||||
python -m pytest test_grok2_perf.py -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from typing import List
|
||||
|
||||
from sglang.test.ci.ci_register import register_amd_ci
|
||||
from sglang.test.nightly_bench_utils import BenchmarkResult
|
||||
from sglang.test.nightly_utils import NightlyBenchmarkRunner
|
||||
from sglang.test.test_utils import DEFAULT_URL_FOR_TEST, _parse_int_list_env
|
||||
|
||||
# Register for AMD CI - Grok-2 benchmark (~25 min)
|
||||
register_amd_ci(est_time=1500, suite="nightly-perf-8-gpu-grok2", nightly=True)
|
||||
|
||||
|
||||
def generate_simple_markdown_report(results: List[BenchmarkResult]) -> str:
|
||||
"""Generate a simplified markdown report without traces and cost columns."""
|
||||
model_header = results[0].model_path
|
||||
if results[0].run_name and results[0].run_name != "default":
|
||||
model_header += f" ({results[0].run_name})"
|
||||
|
||||
gpu_config = os.getenv("GPU_CONFIG", "")
|
||||
if gpu_config:
|
||||
model_header += f" [{gpu_config}]"
|
||||
|
||||
summary = f"### {model_header}\n"
|
||||
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | ITL (ms) |\n"
|
||||
summary += "| ---------- | --------- | ----------- | ------------------------ | ------------------------- | -------- |\n"
|
||||
|
||||
for result in results:
|
||||
itl = 1 / (result.output_throughput / result.batch_size) * 1000
|
||||
summary += f"| {result.batch_size} | {result.input_len} | {result.latency:.2f} | {result.input_throughput:.2f} | {result.output_throughput:.2f} | {itl:.2f} |\n"
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
# Model and tokenizer paths can be overridden via environment variables
|
||||
GROK2_MODEL_PATH = os.environ.get("GROK2_MODEL_PATH", "xai-org/grok-2")
|
||||
GROK2_TOKENIZER_PATH = os.environ.get(
|
||||
"GROK2_TOKENIZER_PATH", "alvarobartt/grok-2-tokenizer"
|
||||
)
|
||||
PROFILE_DIR = "performance_profiles_grok2"
|
||||
|
||||
|
||||
class TestNightlyGrok2Performance(unittest.TestCase):
|
||||
"""Nightly performance benchmark for Grok-2.
|
||||
|
||||
Tests Grok-2 with FP8 quantization on TP=8.
|
||||
Runtime: ~25 minutes
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.batch_sizes = [1, 1, 8, 16, 64]
|
||||
cls.input_lens = tuple(_parse_int_list_env("NIGHTLY_INPUT_LENS", "1024"))
|
||||
cls.output_lens = tuple(_parse_int_list_env("NIGHTLY_OUTPUT_LENS", "512"))
|
||||
|
||||
cls.model_config = {
|
||||
"name": "grok2",
|
||||
"model_path": GROK2_MODEL_PATH,
|
||||
"other_args": [
|
||||
"--trust-remote-code",
|
||||
"--tp",
|
||||
"8",
|
||||
"--quantization",
|
||||
"fp8",
|
||||
"--mem-fraction-static",
|
||||
"0.85",
|
||||
"--tokenizer-path",
|
||||
GROK2_TOKENIZER_PATH,
|
||||
"--attention-backend",
|
||||
"aiter",
|
||||
],
|
||||
"env_vars": {
|
||||
"RCCL_MSCCL_ENABLE": "0",
|
||||
"SGLANG_USE_AITER": "1",
|
||||
"SGLANG_INT4_WEIGHT": "0",
|
||||
},
|
||||
}
|
||||
|
||||
cls.runner = NightlyBenchmarkRunner(PROFILE_DIR, cls.__name__, cls.base_url)
|
||||
cls.runner.setup_profile_directory()
|
||||
cls.runner.full_report = f"## {cls.__name__}\n"
|
||||
|
||||
def test_bench_grok2(self):
|
||||
"""Run benchmark for Grok-2."""
|
||||
# Set environment variables
|
||||
old_env = {}
|
||||
for key, value in self.model_config.get("env_vars", {}).items():
|
||||
old_env[key] = os.environ.get(key)
|
||||
os.environ[key] = value
|
||||
print(f"Setting env: {key}={value}")
|
||||
|
||||
try:
|
||||
result_tuple = self.runner.run_benchmark_for_model(
|
||||
model_path=self.model_config["model_path"],
|
||||
batch_sizes=self.batch_sizes,
|
||||
input_lens=self.input_lens,
|
||||
output_lens=self.output_lens,
|
||||
other_args=self.model_config["other_args"],
|
||||
variant=self.model_config["name"],
|
||||
extra_bench_args=["--trust-remote-code"],
|
||||
)
|
||||
results = result_tuple[0]
|
||||
success = result_tuple[1]
|
||||
|
||||
if results:
|
||||
self.runner.full_report += (
|
||||
generate_simple_markdown_report(results) + "\n"
|
||||
)
|
||||
|
||||
self.assertTrue(success, "Benchmark failed for Grok-2")
|
||||
finally:
|
||||
# Restore original environment
|
||||
for key, value in old_env.items():
|
||||
if value is None:
|
||||
os.environ.pop(key, None)
|
||||
else:
|
||||
os.environ[key] = value
|
||||
self.runner.write_final_report()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user