Skip to content

Commit 9881210

Browse files
authored
Merge branch 'main' into new-mi300x-node
2 parents c5b4472 + a2f2a54 commit 9881210

4 files changed

Lines changed: 206 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test Process Result
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'utils/process_result.py'
7+
- 'utils/test_process_result.py'
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
if: github.event.pull_request.draft != true
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install pytest
32+
33+
- name: Run pytest
34+
run: |
35+
cd utils
36+
pytest test_process_result.py -v

utils/process_result.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
'input_tput_per_gpu': (float(bmk_result['total_token_throughput']) - float(bmk_result['output_throughput']) )/ prefill_gpus
3737
}
3838

39+
# Check if both PREFILL_GPUS and DECODE_GPUS env vars exist and are not empty
40+
if prefill_gpus_str and decode_gpus_str:
41+
data['disagg'] = True
42+
data['num_prefill_gpu'] = prefill_gpus
43+
data['num_decode_gpu'] = decode_gpus
44+
else:
45+
data['disagg'] = False
46+
3947
if mtp_mode: # MTP
4048
data['mtp'] = mtp_mode
4149

utils/pytest.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[pytest]
2+
testpaths = .
3+
python_files = test_*.py
4+
python_classes = Test*
5+
python_functions = test_*
6+
addopts =
7+
-v
8+
--strict-markers
9+
--tb=short
10+
markers =
11+
slow: marks tests as slow (deselect with '-m "not slow"')
12+
integration: marks tests as integration tests

utils/test_process_result.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import pytest
2+
import json
3+
import sys
4+
import importlib.util
5+
from pathlib import Path
6+
from io import StringIO
7+
8+
9+
def create_mock_result_file(tmp_path):
10+
"""Create a mock result JSON file."""
11+
result_data = {
12+
"max_concurrency": 10,
13+
"model_id": "test-model",
14+
"total_token_throughput": 1000.0,
15+
"output_throughput": 400.0,
16+
"ttft_ms": 50.0,
17+
"tpot_ms": 20.0
18+
}
19+
result_file = tmp_path / "test_result.json"
20+
with open(result_file, 'w') as f:
21+
json.dump(result_data, f)
22+
return result_file
23+
24+
25+
def run_process_result_script(tmp_path):
26+
"""Helper to run process_result.py and return the output data."""
27+
# Create mock result file
28+
create_mock_result_file(tmp_path)
29+
30+
# Get script path relative to this test file
31+
script_path = Path(__file__).parent / "process_result.py"
32+
spec = importlib.util.spec_from_file_location("process_result", script_path)
33+
module = importlib.util.module_from_spec(spec)
34+
35+
# Capture stdout
36+
old_stdout = sys.stdout
37+
sys.stdout = StringIO()
38+
39+
try:
40+
spec.loader.exec_module(module)
41+
output = sys.stdout.getvalue()
42+
return json.loads(output)
43+
finally:
44+
sys.stdout = old_stdout
45+
46+
47+
def test_disagg_true_when_both_env_vars_set(tmp_path, monkeypatch):
48+
"""Test that disagg=true when both PREFILL_GPUS and DECODE_GPUS are set."""
49+
# Set environment variables
50+
monkeypatch.setenv('RUNNER_TYPE', 'h200')
51+
monkeypatch.setenv('TP', '8')
52+
monkeypatch.setenv('EP_SIZE', '1')
53+
monkeypatch.setenv('PREFILL_GPUS', '4')
54+
monkeypatch.setenv('DECODE_GPUS', '4')
55+
monkeypatch.setenv('DP_ATTENTION', 'false')
56+
monkeypatch.setenv('RESULT_FILENAME', 'test_result')
57+
monkeypatch.setenv('FRAMEWORK', 'vllm')
58+
monkeypatch.setenv('PRECISION', 'fp8')
59+
60+
# Change to tmp_path directory
61+
monkeypatch.chdir(tmp_path)
62+
63+
# Run the script and get output
64+
data = run_process_result_script(tmp_path)
65+
66+
# Check that disagg is true
67+
assert data['disagg'] is True
68+
# Check that num_prefill_gpu and num_decode_gpu are present
69+
assert data['num_prefill_gpu'] == 4
70+
assert data['num_decode_gpu'] == 4
71+
72+
73+
def test_disagg_false_when_prefill_gpus_not_set(tmp_path, monkeypatch):
74+
"""Test that disagg=false when PREFILL_GPUS is not set."""
75+
# Set environment variables (without PREFILL_GPUS)
76+
monkeypatch.setenv('RUNNER_TYPE', 'h200')
77+
monkeypatch.setenv('TP', '8')
78+
monkeypatch.setenv('EP_SIZE', '1')
79+
monkeypatch.setenv('DECODE_GPUS', '4')
80+
monkeypatch.setenv('DP_ATTENTION', 'false')
81+
monkeypatch.setenv('RESULT_FILENAME', 'test_result')
82+
monkeypatch.setenv('FRAMEWORK', 'vllm')
83+
monkeypatch.setenv('PRECISION', 'fp8')
84+
85+
# Change to tmp_path directory
86+
monkeypatch.chdir(tmp_path)
87+
88+
# Run the script and get output
89+
data = run_process_result_script(tmp_path)
90+
91+
# Check that disagg is false
92+
assert data['disagg'] is False
93+
# Check that num_prefill_gpu and num_decode_gpu are NOT present
94+
assert 'num_prefill_gpu' not in data
95+
assert 'num_decode_gpu' not in data
96+
97+
98+
def test_disagg_false_when_decode_gpus_not_set(tmp_path, monkeypatch):
99+
"""Test that disagg=false when DECODE_GPUS is not set."""
100+
# Set environment variables (without DECODE_GPUS)
101+
monkeypatch.setenv('RUNNER_TYPE', 'h200')
102+
monkeypatch.setenv('TP', '8')
103+
monkeypatch.setenv('EP_SIZE', '1')
104+
monkeypatch.setenv('PREFILL_GPUS', '4')
105+
monkeypatch.setenv('DP_ATTENTION', 'false')
106+
monkeypatch.setenv('RESULT_FILENAME', 'test_result')
107+
monkeypatch.setenv('FRAMEWORK', 'vllm')
108+
monkeypatch.setenv('PRECISION', 'fp8')
109+
110+
# Change to tmp_path directory
111+
monkeypatch.chdir(tmp_path)
112+
113+
# Run the script and get output
114+
data = run_process_result_script(tmp_path)
115+
116+
# Check that disagg is false
117+
assert data['disagg'] is False
118+
# Check that num_prefill_gpu and num_decode_gpu are NOT present
119+
assert 'num_prefill_gpu' not in data
120+
assert 'num_decode_gpu' not in data
121+
122+
123+
def test_disagg_false_when_both_env_vars_empty_strings(tmp_path, monkeypatch):
124+
"""Test that disagg=false when both PREFILL_GPUS and DECODE_GPUS are empty strings."""
125+
# Set environment variables with empty strings
126+
monkeypatch.setenv('RUNNER_TYPE', 'h200')
127+
monkeypatch.setenv('TP', '8')
128+
monkeypatch.setenv('EP_SIZE', '1')
129+
monkeypatch.setenv('PREFILL_GPUS', '')
130+
monkeypatch.setenv('DECODE_GPUS', '')
131+
monkeypatch.setenv('DP_ATTENTION', 'false')
132+
monkeypatch.setenv('RESULT_FILENAME', 'test_result')
133+
monkeypatch.setenv('FRAMEWORK', 'vllm')
134+
monkeypatch.setenv('PRECISION', 'fp8')
135+
136+
# Change to tmp_path directory
137+
monkeypatch.chdir(tmp_path)
138+
139+
# Run the script and get output
140+
data = run_process_result_script(tmp_path)
141+
142+
# Check that disagg is false
143+
assert data['disagg'] is False
144+
# Check that num_prefill_gpu and num_decode_gpu are NOT present
145+
assert 'num_prefill_gpu' not in data
146+
assert 'num_decode_gpu' not in data
147+
148+
149+
if __name__ == "__main__":
150+
pytest.main([__file__, "-v"])

0 commit comments

Comments
 (0)