Skip to content

Commit 9e16365

Browse files
fix: modify the gen_test_file prompt to support multiple input configurations and prevent pytest to be too verbose
1 parent 3c28637 commit 9e16365

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

MaxKernel/auto_agent/subagents/testing/prompts/gen_test_file.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@
8282
- **Note**: During validation, the optimized kernel import will be temporarily disabled to verify the test structure works with baseline only
8383
8484
3. **TestPerformance class**: Tests that benchmark performance
85-
- If the base kernel file (`{base_kernel_path?}`) contains a function to generate inputs (e.g., `get_inputs` or similar). If it is defined, you should directly copy and reuse it in the test file.
86-
- Compare execution time between base and optimized kernels
85+
- If the base kernel file (`{base_kernel_path?}`) contains a function to generate inputs (e.g., `get_inputs`), you must directly copy and reuse it.
86+
- **CRITICAL**: If the input generation function returns MULTIPLE configurations (e.g., a list of inputs), you MUST select exactly ONE configuration (the last one) to run the performance benchmark on. Do NOT use `@pytest.mark.parametrize` for the performance test to ensure we get a single, consistent baseline measurement.
87+
- Compare execution time between base and optimized kernels on this single configuration
8788
- Include warmup runs before timing
8889
- Use .block_until_ready() for accurate JAX timing
89-
- Run 10 iterations for each benchmark to get reliable timing measurements
90+
- Run 10 iterations for the benchmark to get reliable timing measurements
9091
9192
## Requirements
9293
@@ -136,9 +137,10 @@
136137
if 'optimized_kernel' not in globals():
137138
optimized_kernel = base_kernel
138139
139-
def report_perf_metrics(execution_time_ms):
140+
def report_perf_metrics(execution_time_ms, speedup):
140141
import sys
141142
sys.__stdout__.write("PERF_METRICS: " + str(execution_time_ms) + "\n")
143+
sys.__stdout__.write("SPEEDUP: " + str(speedup) + "\n")
142144
143145
class TestCompilation:
144146
def test_optimized_kernel_compiles(self):
@@ -161,7 +163,7 @@ def test_performance_comparison(self):
161163
pass
162164
163165
if __name__ == "__main__":
164-
sys.exit(pytest.main([__file__, "-v", "-s", "--tb=short"]))
166+
sys.exit(pytest.main([__file__, "-v", "--tb=short"]))
165167
```
166168
167169
### Important Guidelines
@@ -188,7 +190,7 @@ def test_performance_comparison(self):
188190
- Report speedup ratios
189191
- Include warmup iterations
190192
- Use multiple runs for statistical stability
191-
- **Structured Output**: At the end of the performance test, you MUST call the `report_perf_metrics(execution_time_ms)` helper function provided in the template to report the final average execution time of the optimized kernel. Do not use standard `print()` for this.
193+
- **Structured Output**: At the end of the performance test, you MUST call the `report_perf_metrics(execution_time_ms, speedup)` helper function provided in the template to report the final average execution time and the speedup of the optimized kernel over the base kernel. Do not use standard `print()` for this.
192194
193195
## Output Format
194196
When you have generated the test file:

0 commit comments

Comments
 (0)