Commit dda5832
committed
[ModelSuite] Refactor TorchBench for ModelSuite inheritance
This PR integrates operator benchmarking into the Model Suite by having it inherit from TorchBenchTestSuite. The suite now extracts operator lists from model configs and benchmarks those operators using TorchBench data before running end-to-end model tests.
This approach aligns with the core goal of BackendBench: testing operators. The Model Suite is designed with the assumption that for a given set of ops, users can provide kernel implementations, and the suite will benchmark both the individual ops and the full model using those implementations.
The long-term vision is to make this process seamless—allowing users to run both operator and model benchmarking with a single command.
TorchBench is used here because it provides the strongest guarantee that running the suite benchmarks all operators required for a specific model configuration. Its dataset is easily extensible and includes realistic tensor shapes derived from actual models.
The main design drawback is that this integration makes supporting kernel fusions with models more complex. However, it is preferable to handle kernel fusions in a separate suite regardless.
### Testing
Running `uv run python BackendBench/scripts/main.py --suite model --backend directory --topn 1` with a working mm kernel and other kernels being watermakred yeilds the expected result (below)
```bash
Successfully registered 36 custom operators
[2025-10-02 07:21:23][INFO][main.py] ============================================================
[2025-10-02 07:21:23][INFO][main.py] MODEL EVALUATION RESULTS
[2025-10-02 07:21:23][INFO][main.py] ============================================================
[2025-10-02 07:21:23][INFO][model.py]
Model: ToyCoreOpsModel
[2025-10-02 07:21:23][INFO][model.py] Status: ✗ Failed (0/3 tests)
[2025-10-02 07:21:23][INFO][model.py] ✗ small_batch
[2025-10-02 07:21:23][INFO][model.py] Error: Model ToyCoreOpsModel::small_batch failed: Expected number of channels in input to be divisible by num_groups, but got input of shape [2, 3, 32, 32] and num_groups=8
[2025-10-02 07:21:23][INFO][model.py] ✗ medium_batch
[2025-10-02 07:21:23][INFO][model.py] Error: Model ToyCoreOpsModel::medium_batch failed: Expected number of channels in input to be divisible by num_groups, but got input of shape [4, 3, 64, 64] and num_groups=8
[2025-10-02 07:21:23][INFO][model.py] ✗ large_input
[2025-10-02 07:21:23][INFO][model.py] Error: Model ToyCoreOpsModel::large_input failed: Expected number of channels in input to be divisible by num_groups, but got input of shape [2, 3, 128, 128] and num_groups=8
[2025-10-02 07:21:23][INFO][model.py]
Model: SmokeTestModel
[2025-10-02 07:21:23][INFO][model.py] Status: ✓ Passed (3/3 tests)
[2025-10-02 07:21:23][INFO][model.py] ✓ small_batch
[2025-10-02 07:21:23][INFO][model.py] Output match: ✓ Gradients match: ✓ (4 gradients)
[2025-10-02 07:21:23][INFO][model.py] ✓ medium_batch
[2025-10-02 07:21:23][INFO][model.py] Output match: ✓ Gradients match: ✓ (4 gradients)
[2025-10-02 07:21:23][INFO][model.py] ✓ large_batch
[2025-10-02 07:21:23][INFO][model.py] Output match: ✓ Gradients match: ✓ (4 gradients)
[2025-10-02 07:21:23][INFO][main.py] ============================================================
[2025-10-02 07:21:23][INFO][output.py] Full results saved to generated_kernels/full_results.json
[2025-10-02 07:21:23][INFO][output.py] Operator summary CSV saved to generated_kernels/operator_summary.csv
[2025-10-02 07:21:23][INFO][output.py] Failed operations log saved to generated_kernels/failed_tests.json
[2025-10-02 07:21:23][INFO][output.py] Overall summary saved to generated_kernels/OVERALL_SUMMARY.md
[2025-10-02 07:21:23][INFO][output.py] Results saved to directory: /home/dev/sapling_repos/BackendBench/generated_kernels
Results saved to directory: /home/dev/sapling_repos/BackendBench/generated_kernels
Overall summary saved to: /home/dev/sapling_repos/BackendBench/generated_kernels/OVERALL_SUMMARY.md
```
### Future work with Model Suite
#1811 parent 4409ee2 commit dda5832
3 files changed
+51
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
189 | 187 | | |
190 | 188 | | |
191 | 189 | | |
| |||
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | 264 | | |
268 | 265 | | |
269 | 266 | | |
| |||
332 | 329 | | |
333 | 330 | | |
334 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| 23 | + | |
| 24 | + | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
| |||
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
92 | | - | |
93 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
98 | 109 | | |
| 110 | + | |
99 | 111 | | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
103 | 115 | | |
104 | 116 | | |
| 117 | + | |
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
110 | 123 | | |
111 | | - | |
112 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
113 | 127 | | |
114 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
115 | 144 | | |
116 | 145 | | |
117 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| 97 | + | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| |||
0 commit comments