Skip to content

Commit

Permalink
Update the benchmarking script to clone an eager model (#113046)
Browse files Browse the repository at this point in the history
Summary:
fix pytorch/pytorch#113029 where running a model in eager somehow can change a weight stride

X-link: pytorch/pytorch#113046
Approved by: https://github.com/angelayi

Reviewed By: PaliC

Differential Revision: D51139962

Pulled By: desertfire

fbshipit-source-id: 3ae8a878cd408c9e20e1b5846f0086b540ff17e4
  • Loading branch information
desertfire authored and facebook-github-bot committed Nov 10, 2023
1 parent 15ce7cd commit 2796871
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion userbenchmark/dynamo/dynamobench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,10 @@ def load(cls, model, example_inputs, device):
if key not in cls.cache:
# Register the output dataclass to pytree
example_args, example_kwargs = _normalize_bench_inputs(example_inputs)
example_outputs = model(*example_args, **example_kwargs)
with torch.no_grad():
# copy.deepcopy is required to prevent any surprising side-effect,
# see https://github.com/pytorch/pytorch/issues/113029
example_outputs = copy.deepcopy(model)(*example_args, **example_kwargs)
_register_dataclass_output_as_pytree(example_outputs)

so_path = torch._export.aot_compile(model, example_args, example_kwargs)
Expand Down

0 comments on commit 2796871

Please sign in to comment.