diff --git a/.github/workflows/nightly-test-amd-rocm720.yml b/.github/workflows/nightly-test-amd-rocm720.yml index fcd3da890..56df8ac26 100644 --- a/.github/workflows/nightly-test-amd-rocm720.yml +++ b/.github/workflows/nightly-test-amd-rocm720.yml @@ -82,6 +82,8 @@ on: - nightly-8-gpu-mi35x-glm51-rocm720 # 8-GPU GLM-5-MXFP4 (MI35x only) - nightly-8-gpu-mi35x-glm5-mxfp4-rocm720 + # 4-GPU MiniMax-M2.5 (MI35x) + - nightly-4-gpu-mi35x-minimax-m25-rocm720 # 8-GPU MiniMax-M2.7 (MI30x only) - nightly-8-gpu-minimax-m27-rocm720 # Diffusion (MI30x) @@ -1681,6 +1683,44 @@ jobs: echo "$(> $GITHUB_STEP_SUMMARY || true exit ${TEST_EXIT_CODE:-0} + # ============================================================================== + # 4-GPU MiniMax-M2.5 (MI35x) + # ============================================================================== + + nightly-4-gpu-mi35x-minimax-m25-rocm720: + if: (github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request') && (!(inputs.job_filter || inputs.job_select) || (inputs.job_filter || inputs.job_select) == 'all' || contains(format(',{0},', inputs.job_filter || inputs.job_select), ',nightly-4-gpu-mi35x-minimax-m25-rocm720,')) + runs-on: linux-mi35x-gpu-8 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.sha }} + + - name: Ensure VRAM is clear + run: bash scripts/ci/amd/ensure_vram_clear.sh rocm + + - name: Setup docker (ROCm 7.2) + run: | + touch github_summary.md + bash scripts/ci/amd/amd_ci_start_container.sh --rocm-version rocm720 + env: + GITHUB_WORKSPACE: ${{ github.workspace }} + + - name: Install dependencies + run: bash scripts/ci/amd/amd_ci_install_dependency.sh --skip-test-time-deps + + - name: Accuracy Test MI35x ROCm 7.2 (4-GPU MiniMax-M2.5) + timeout-minutes: 120 + run: | + > github_summary.md + bash scripts/ci/amd/amd_ci_exec.sh -w /sglang-checkout/test \ + -e SGLANG_USE_AITER=1 \ + -e SGLANG_USE_AITER_UNIFIED_ATTN=1 \ + -e GITHUB_STEP_SUMMARY="/sglang-checkout/github_summary.md" \ + python3 run_suite.py --hw amd --suite nightly-amd-4-gpu-mi35x-minimax-m25-tp4 --nightly --timeout-per-file 5400 ${{ (github.event_name == 'schedule' || inputs.continue_on_error) && '--continue-on-error' || '' }} || TEST_EXIT_CODE=$? + echo "$(> $GITHUB_STEP_SUMMARY || true + exit ${TEST_EXIT_CODE:-0} + # ============================================================================== # 8-GPU MiniMax-M2.7 (MI30x only) # ============================================================================== @@ -1831,6 +1871,8 @@ jobs: - nightly-8-gpu-mi35x-glm51-rocm720 # 8-GPU GLM-5-MXFP4 (MI35x only) - nightly-8-gpu-mi35x-glm5-mxfp4-rocm720 + # 4-GPU MiniMax-M2.5 (MI35x) + - nightly-4-gpu-mi35x-minimax-m25-rocm720 # 8-GPU MiniMax-M2.7 (MI30x only) - nightly-8-gpu-minimax-m27-rocm720 # Diffusion (MI30x) diff --git a/.github/workflows/nightly-test-amd.yml b/.github/workflows/nightly-test-amd.yml index 56d9a41f7..4b574901e 100644 --- a/.github/workflows/nightly-test-amd.yml +++ b/.github/workflows/nightly-test-amd.yml @@ -79,6 +79,8 @@ on: - nightly-8-gpu-mi35x-glm51 # 8-GPU GLM-5-MXFP4 (MI35x only) - nightly-8-gpu-mi35x-glm5-mxfp4 + # 4-GPU MiniMax-M2.5 (MI35x) + - nightly-4-gpu-mi35x-minimax-m25 # 8-GPU MiniMax-M2.7 (MI30x only) - nightly-8-gpu-minimax-m27 # Diffusion (MI30x) @@ -1612,6 +1614,44 @@ jobs: echo "$(> $GITHUB_STEP_SUMMARY || true exit ${TEST_EXIT_CODE:-0} + # ============================================================================== + # 4-GPU MiniMax-M2.5 (MI35x) + # ============================================================================== + + nightly-4-gpu-mi35x-minimax-m25: + if: (github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request') && (!(inputs.job_filter || inputs.job_select) || (inputs.job_filter || inputs.job_select) == 'all' || contains(format(',{0},', inputs.job_filter || inputs.job_select), ',nightly-4-gpu-mi35x-minimax-m25,')) + runs-on: linux-mi35x-gpu-8 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.sha }} + + - name: Ensure VRAM is clear + run: bash scripts/ci/amd/ensure_vram_clear.sh rocm + + - name: Setup docker (ROCm 7.0) + run: | + touch github_summary.md + bash scripts/ci/amd/amd_ci_start_container.sh + env: + GITHUB_WORKSPACE: ${{ github.workspace }} + + - name: Install dependencies + run: bash scripts/ci/amd/amd_ci_install_dependency.sh --skip-test-time-deps + + - name: Accuracy Test MI35x (4-GPU MiniMax-M2.5) + timeout-minutes: 120 + run: | + > github_summary.md + bash scripts/ci/amd/amd_ci_exec.sh -w /sglang-checkout/test \ + -e SGLANG_USE_AITER=1 \ + -e SGLANG_USE_AITER_UNIFIED_ATTN=1 \ + -e GITHUB_STEP_SUMMARY="/sglang-checkout/github_summary.md" \ + python3 run_suite.py --hw amd --suite nightly-amd-4-gpu-mi35x-minimax-m25-tp4 --nightly --timeout-per-file 5400 ${{ (github.event_name == 'schedule' || inputs.continue_on_error) && '--continue-on-error' || '' }} || TEST_EXIT_CODE=$? + echo "$(> $GITHUB_STEP_SUMMARY || true + exit ${TEST_EXIT_CODE:-0} + # ============================================================================== # 8-GPU MiniMax-M2.7 (MI30x only) # ============================================================================== @@ -1759,6 +1799,8 @@ jobs: - nightly-8-gpu-mi35x-glm51 # 8-GPU GLM-5-MXFP4 (MI35x only) - nightly-8-gpu-mi35x-glm5-mxfp4 + # 4-GPU MiniMax-M2.5 (MI35x) + - nightly-4-gpu-mi35x-minimax-m25 # 8-GPU MiniMax-M2.7 (MI30x only) - nightly-8-gpu-minimax-m27 # Diffusion (MI30x) diff --git a/test/registered/amd/accuracy/mi35x/test_minimax_m25_tp4_eval_mi35x.py b/test/registered/amd/accuracy/mi35x/test_minimax_m25_tp4_eval_mi35x.py new file mode 100644 index 000000000..95f76a138 --- /dev/null +++ b/test/registered/amd/accuracy/mi35x/test_minimax_m25_tp4_eval_mi35x.py @@ -0,0 +1,255 @@ +"""MI35x MiniMax-M2.5 GSM8K Completion Evaluation Test (4-GPU, TP=4) + +Tests MiniMax-M2.5 with TP=4 + EP=1 configuration using few-shot completion +benchmark on MI35x. This configuration uses unified attention with FP8 KV cache. + +Registry: nightly-amd-4-gpu-mi35x-minimax-m25-tp4 suite +""" + +import os +import re +import time +import unittest +from dataclasses import dataclass +from typing import List, Optional, Tuple + +import numpy as np + +from sglang.srt.utils import kill_process_tree +from sglang.test.ci.ci_register import register_amd_ci +from sglang.test.test_utils import ( + DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, + DEFAULT_URL_FOR_TEST, + is_in_ci, + popen_launch_server, + write_github_step_summary, +) +from sglang.utils import download_and_cache_file, read_jsonl + +register_amd_ci( + est_time=5400, + suite="nightly-amd-4-gpu-mi35x-minimax-m25-tp4", + nightly=True, +) + +INVALID = -9999999 + + +@dataclass +class ModelConfig: + """Configuration for a model to test.""" + + model_path: str + tp_size: int = 4 + accuracy_threshold: float = 0.93 + other_args: Optional[List[str]] = None + env_vars: Optional[dict] = None + timeout: Optional[int] = None + variant: Optional[str] = None + + def __post_init__(self): + if self.other_args is None: + self.other_args = [] + if self.env_vars is None: + self.env_vars = {} + + def get_display_name(self) -> str: + if self.variant: + return f"{self.model_path} ({self.variant})" + return self.model_path + + +MI35X_MINIMAX_M25_TP4_MODELS = [ + ModelConfig( + model_path="MiniMaxAI/MiniMax-M2.5", + tp_size=4, + accuracy_threshold=0.93, + timeout=5400, + variant="TP4+UnifiedAttn+FP8KV", + other_args=[ + "--ep-size", + "1", + "--dtype", + "bfloat16", + "--trust-remote-code", + "--attention-backend", + "aiter", + "--mem-fraction-static", + "0.85", + "--disable-radix-cache", + "--kv-cache-dtype", + "fp8_e4m3", + "--page-size", + "16", + "--watchdog-timeout", + "1200", + ], + env_vars={ + "SGLANG_USE_AITER": "1", + "SGLANG_USE_AITER_UNIFIED_ATTN": "1", + }, + ), +] + + +def get_one_example(lines, i, include_answer): + """Format a single GSM8K example.""" + ret = "Question: " + lines[i]["question"] + "\nAnswer:" + if include_answer: + ret += " " + lines[i]["answer"] + return ret + + +def get_few_shot_examples(lines, k): + """Get k few-shot examples for prompting.""" + ret = "" + for i in range(k): + ret += get_one_example(lines, i, True) + "\n\n" + return ret + + +def get_answer_value(answer_str): + """Extract numerical answer from response.""" + if not isinstance(answer_str, str): + return INVALID + answer_str = answer_str.replace(",", "") + numbers = re.findall(r"\d+", answer_str) + if not numbers: + return INVALID + try: + return int(numbers[-1]) + except ValueError: + return INVALID + + +def run_gsm8k_benchmark( + base_url: str, + num_questions: int = 200, + num_shots: int = 5, + parallel: int = 64, +) -> Tuple[float, float, float]: + """Run GSM8K few-shot completion benchmark.""" + import sglang as sgl + from sglang.lang.backend.runtime_endpoint import RuntimeEndpoint + + url = "https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/test.jsonl" + data_path = download_and_cache_file(url) + lines = list(read_jsonl(data_path)) + + few_shot_examples = get_few_shot_examples(lines, num_shots) + + questions = [] + labels = [] + for i in range(len(lines[:num_questions])): + questions.append(get_one_example(lines, i, False)) + labels.append(get_answer_value(lines[i]["answer"])) + assert all(l != INVALID for l in labels) + arguments = [{"question": q} for q in questions] + + @sgl.function + def few_shot_gsm8k(s, question): + s += few_shot_examples + question + s += sgl.gen( + "answer", max_tokens=512, stop=["Question", "Assistant:", "<|separator|>"] + ) + + backend = RuntimeEndpoint(base_url) + sgl.set_default_backend(backend) + + tic = time.perf_counter() + states = few_shot_gsm8k.run_batch( + arguments, temperature=0, num_threads=parallel, progress_bar=True + ) + latency = time.perf_counter() - tic + + preds = [get_answer_value(states[i]["answer"]) for i in range(len(states))] + acc = np.mean(np.array(preds) == np.array(labels)) + invalid = np.mean(np.array(preds) == INVALID) + + return float(acc), float(invalid), float(latency) + + +class TestMiniMaxM25TP4EvalMI35x(unittest.TestCase): + """MiniMax-M2.5 TP=4 GSM8K Completion Evaluation Test for AMD MI35x.""" + + @classmethod + def setUpClass(cls): + cls.models = MI35X_MINIMAX_M25_TP4_MODELS + cls.base_url = DEFAULT_URL_FOR_TEST + cls.num_questions = int(os.environ.get("GSM8K_NUM_QUESTIONS", "1319")) + + def test_minimax_m25_tp4_accuracy(self): + """Test MiniMax-M2.5 TP=4 with GSM8K completion benchmark.""" + all_results = [] + summary = "### MiniMax-M2.5 TP=4 (MI35x)\n\n" + summary += "| Model | Variant | TP | Accuracy | Threshold | Status |\n" + summary += "| ----- | ------- | -- | -------- | --------- | ------ |\n" + + for config in self.models: + display_name = config.get_display_name() + with self.subTest(model=display_name): + print(f"\n{'='*60}") + print(f"Testing: {display_name}") + print(f"{'='*60}") + + env = os.environ.copy() + for key, value in config.env_vars.items(): + env[key] = value + + other_args = list(config.other_args) + other_args.extend(["--tp", str(config.tp_size)]) + timeout = config.timeout or DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH + + try: + process = popen_launch_server( + model=config.model_path, + base_url=self.base_url, + timeout=timeout, + other_args=other_args, + env=env, + ) + + try: + acc, invalid, latency = run_gsm8k_benchmark( + self.base_url, num_questions=self.num_questions + ) + passed = acc >= config.accuracy_threshold + status = "PASS" if passed else "FAIL" + print( + f" accuracy={acc:.3f} threshold={config.accuracy_threshold} {status}" + ) + print(f" invalid={invalid:.3f} latency={latency:.1f}s") + + all_results.append( + { + "model": display_name, + "accuracy": acc, + "passed": passed, + } + ) + summary += f"| {config.model_path} | {config.variant or 'N/A'} | {config.tp_size} | {acc:.3f} | {config.accuracy_threshold} | {status} |\n" + + finally: + kill_process_tree(process.pid) + + except Exception as e: + summary += f"| {config.model_path} | {config.variant or 'N/A'} | {config.tp_size} | N/A | {config.accuracy_threshold} | ERROR |\n" + all_results.append( + { + "model": display_name, + "accuracy": None, + "passed": False, + "error": str(e), + } + ) + + if is_in_ci(): + write_github_step_summary(summary) + + failed = [r for r in all_results if not r["passed"]] + if failed: + raise AssertionError(f"Failed models: {[r['model'] for r in failed]}") + + +if __name__ == "__main__": + unittest.main()