import unittest

from sglang.test.accuracy_test_runner import AccuracyTestParams
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.performance_test_runner import PerformanceTestParams
from sglang.test.run_combined_tests import run_combined_tests
from sglang.test.test_utils import ModelLaunchSettings

# Runs on both H200 and B200 via nightly-8-gpu-common suite
register_cuda_ci(est_time=1800, suite="nightly-8-gpu-common", nightly=True)

MINIMAX_M25_MODEL_PATH = "MiniMaxAI/MiniMax-M2.5"


class TestMiniMaxM25(unittest.TestCase):
    """Unified test class for MiniMax-M2.5 performance and accuracy.

    Single variant with TP=8 + EP=8 configuration.
    Runs BOTH:
    - Performance test (using NightlyBenchmarkRunner with extra_bench_args)
    - Accuracy test (using run_eval with gsm8k)
    """

    def test_minimax_m25(self):
        """Run performance and accuracy for MiniMax-M2.5."""
        base_args = [
            "--trust-remote-code",
            "--ep=8",
            "--mem-fraction-static=0.85",
            "--reasoning-parser=minimax-append-think",
        ]
        dp_attn_args = base_args + [
            "--enable-dp-attention",
            "--dp=8",
        ]

        variants = [
            ModelLaunchSettings(
                MINIMAX_M25_MODEL_PATH,
                tp_size=8,
                extra_args=base_args,
                variant="TP8+EP8",
            ),
            ModelLaunchSettings(
                MINIMAX_M25_MODEL_PATH,
                tp_size=8,
                extra_args=dp_attn_args,
                variant="TP8+DP8+EP8+DPAttn",
            ),
        ]

        run_combined_tests(
            models=variants,
            test_name="MiniMax-M2.5",
            accuracy_params=AccuracyTestParams(dataset="gsm8k", baseline_accuracy=0.80),
            performance_params=PerformanceTestParams(
                result_dir="performance_results_minimax_m25",
            ),
        )


if __name__ == "__main__":
    unittest.main()
