Commit 583bf08
Mark Saroufim
Fix benchmark exploit via object-identity caching
The benchmark harness was vulnerable to submissions that cache results
based on Python object identity (e.g., id(tensor)). Since the same
data objects were reused across all timing iterations, a submission
could cache on first call and return cached results on subsequent
calls, showing artificial speedups of 12-36%.
Changes:
- Clone data before each timing iteration (outside the timed region)
to give each iteration fresh object identities while not affecting
measured kernel time
- Use local seed variable instead of mutating test.args["seed"] to
avoid shared mutable state between benchmark runs1 parent 2998db4 commit 583bf08
1 file changed
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
245 | 246 | | |
246 | | - | |
247 | | - | |
248 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
| |||
272 | 276 | | |
273 | 277 | | |
274 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
275 | 282 | | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
279 | 286 | | |
280 | | - | |
| 287 | + | |
281 | 288 | | |
282 | 289 | | |
283 | 290 | | |
| |||
0 commit comments