[AMD] Update test_gpt_oss_1gpu.py#23829
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the estimated execution time for CUDA CI and modifies the test_mxfp4_20b test to conditionally set the SGLANG_USE_AITER environment variable when running on HIP-compatible hardware. Feedback suggests replacing the manual environment variable management with the more idiomatic unittest.mock.patch.dict to improve code readability and ensure proper cleanup.
| prev = os.environ.get("SGLANG_USE_AITER") | ||
| if is_hip(): | ||
| os.environ["SGLANG_USE_AITER"] = "1" | ||
| try: | ||
| self.run_test( | ||
| model_variant="20b", | ||
| quantization="mxfp4", | ||
| expected_score_of_reasoning_effort={ | ||
| "low": 0.34, | ||
| "medium": 0.34, | ||
| "high": 0.27, # TODO investigate | ||
| }, | ||
| ) | ||
| finally: | ||
| if prev is None: | ||
| os.environ.pop("SGLANG_USE_AITER", None) | ||
| else: | ||
| os.environ["SGLANG_USE_AITER"] = prev |
There was a problem hiding this comment.
The manual management of environment variables using try...finally is verbose and can be simplified using unittest.mock.patch.dict. This approach is more idiomatic for Python tests and ensures the environment is correctly restored even if exceptions occur during setup or execution. It also prevents potential environment leakage to subsequent tests.
from unittest.mock import patch
env_updates = {"SGLANG_USE_AITER": "1"} if is_hip() else {}
with patch.dict(os.environ, env_updates):
self.run_test(
model_variant="20b",
quantization="mxfp4",
expected_score_of_reasoning_effort={
"low": 0.34,
"medium": 0.34,
"high": 0.27, # TODO investigate
},
)
Motivation
Modifications
Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ci