-
Notifications
You must be signed in to change notification settings - Fork 9.1k
[AMD][CI] Add Gemma 4 nightly accuracy tests for MI30x and MI35x #22201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc8468d
[AMD][CI] Add Gemma 4 nightly accuracy test for MI30x
michaelzhang-ai 9844cfa
Merge branch 'main' into add-gemma4-amd-accuracy-test
michaelzhang-ai cad962f
Merge branch 'main' into add-gemma4-amd-accuracy-test
michaelzhang-ai 2f23a76
Merge branch 'main' into add-gemma4-amd-accuracy-test
michaelzhang-ai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
test/registered/amd/accuracy/mi30x/test_gemma4_eval_amd.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| """AMD Gemma 4 mgsm_en Evaluation Test (2-GPU) | ||
|
|
||
| Tests Gemma 4 instruction-tuned models on mgsm_en benchmark using chat completions | ||
| on MI325/MI300X. All Gemma 4 models require the Triton attention backend for | ||
| bidirectional image-token attention on AMD GPUs. | ||
|
|
||
| Ref: https://www.amd.com/en/developer/resources/technical-articles/2026/day-0-support-for-gemma-4-on-amd-processors-and-gpus.html | ||
| Model support: https://github.com/sgl-project/sglang/pull/21952 | ||
|
|
||
| Registry: nightly-amd-accuracy-2-gpu-gemma4 suite | ||
| """ | ||
|
|
||
| import os | ||
| import time | ||
| import unittest | ||
| from dataclasses import dataclass, field | ||
| from typing import List, Optional | ||
|
|
||
| from sglang.srt.utils import kill_process_tree | ||
| from sglang.test.ci.ci_register import register_amd_ci | ||
| from sglang.test.run_eval import run_eval | ||
| from sglang.test.test_utils import ( | ||
| DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, | ||
| DEFAULT_URL_FOR_TEST, | ||
| CustomTestCase, | ||
| is_in_ci, | ||
| popen_launch_server, | ||
| write_github_step_summary, | ||
| ) | ||
|
|
||
| register_amd_ci( | ||
| est_time=3600, | ||
| suite="nightly-amd-accuracy-2-gpu-gemma4", | ||
| nightly=True, | ||
| ) | ||
|
|
||
|
|
||
| @dataclass | ||
| class ModelConfig: | ||
| model_path: str | ||
| tp_size: int = 1 | ||
| accuracy_threshold: float = 0.50 | ||
| other_args: List[str] = field(default_factory=list) | ||
| env_vars: dict = field(default_factory=dict) | ||
| timeout: Optional[int] = None | ||
|
|
||
|
|
||
| GEMMA4_MODELS = [ | ||
| ModelConfig( | ||
| model_path="google/gemma-4-31B-it", | ||
| tp_size=1, | ||
| accuracy_threshold=0.90, | ||
| timeout=1800, | ||
| other_args=[ | ||
| "--attention-backend", | ||
| "triton", | ||
| "--watchdog-timeout", | ||
| "1200", | ||
| ], | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
| class TestGemma4EvalAMD(CustomTestCase): | ||
| """Gemma 4 mgsm_en Evaluation Test for AMD MI325/MI300X.""" | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): | ||
| cls.models = GEMMA4_MODELS | ||
| cls.base_url = DEFAULT_URL_FOR_TEST | ||
| cls.num_threads = 1024 | ||
|
|
||
| def test_gemma4_accuracy(self): | ||
| """Test Gemma 4 models with mgsm_en chat completions benchmark.""" | ||
| all_results = [] | ||
| summary = "### Gemma 4 Models (MI325)\n\n" | ||
| summary += "| Model | TP | Accuracy | Threshold | Status |\n" | ||
| summary += "| ----- | -- | -------- | --------- | ------ |\n" | ||
|
|
||
| for config in self.models: | ||
| with self.subTest(model=config.model_path): | ||
| print(f"\n{'='*60}") | ||
| print(f"Testing: {config.model_path}") | ||
| 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: | ||
| model_start = time.time() | ||
| metrics = run_eval( | ||
| type( | ||
| "Args", | ||
| (), | ||
| { | ||
| "base_url": self.base_url, | ||
| "model": config.model_path, | ||
| "eval_name": "mgsm_en", | ||
| "num_examples": None, | ||
| "num_threads": self.num_threads, | ||
| }, | ||
| )() | ||
| ) | ||
|
michaelzhang-ai marked this conversation as resolved.
|
||
| eval_time = time.time() - model_start | ||
| acc = metrics["score"] | ||
| passed = acc >= config.accuracy_threshold | ||
| status = "PASS" if passed else "FAIL" | ||
| print( | ||
| f" accuracy={acc:.3f} threshold={config.accuracy_threshold}" | ||
| f" time={eval_time:.0f}s {status}" | ||
| ) | ||
|
|
||
| all_results.append( | ||
| { | ||
| "model": config.model_path, | ||
| "accuracy": acc, | ||
| "passed": passed, | ||
| } | ||
| ) | ||
| summary += ( | ||
| f"| {config.model_path} | {config.tp_size}" | ||
| f" | {acc:.3f} | {config.accuracy_threshold}" | ||
| f" | {'✅ PASS' if passed else '❌ FAIL'} |\n" | ||
| ) | ||
|
|
||
| finally: | ||
| kill_process_tree(process.pid) | ||
|
|
||
| except Exception as e: | ||
| summary += ( | ||
| f"| {config.model_path} | {config.tp_size}" | ||
| f" | N/A | {config.accuracy_threshold} | ❌ ERROR |\n" | ||
| ) | ||
| all_results.append( | ||
| { | ||
| "model": config.model_path, | ||
| "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]}") | ||
|
|
||
|
michaelzhang-ai marked this conversation as resolved.
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.