Skip to content

Commit 373ffb1

Browse files
angelayifacebook-github-bot
authored andcommitted
Copy model before benchmark warmup runs (#145858)
Summary: Fixes pytorch/pytorch#144772 The eager warmup runs causes the model to change state so that later when we export it, the model is different than when we export it directly out of box. For some reason exporting the model with the changed state causes issues but exporting the inital model is ok. This is the reason why the accuracy checks pass but the performance check fails when exporting. X-link: pytorch/pytorch#145858 Approved by: https://github.com/desertfire Reviewed By: ZainRizvi Differential Revision: D68897720 fbshipit-source-id: 8b8f82c6986a1a6e7d92b8dabe3852cce6016d5c
1 parent d9cc213 commit 373ffb1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

userbenchmark/dynamo/dynamobench/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,11 +3446,15 @@ def warmup(fn, model, example_inputs, mode, niters=5):
34463446
self.args.snapshot_memory, f"eager_{self.args.only}"
34473447
):
34483448
eager_latency, eager_peak_mem, _ = warmup(
3449-
self.model_iter_fn, model, example_inputs, "eager"
3449+
self.model_iter_fn, copy.deepcopy(model), example_inputs, "eager"
34503450
)
34513451
if self.args.use_warm_peak_memory:
34523452
_, eager_peak_mem, _ = warmup(
3453-
self.model_iter_fn, model, example_inputs, "eager", niters=1
3453+
self.model_iter_fn,
3454+
copy.deepcopy(model),
3455+
example_inputs,
3456+
"eager",
3457+
niters=1,
34543458
)
34553459

34563460
if self.args.export_aot_inductor:

0 commit comments

Comments
 (0)