Skip to content

Commit f3ef83d

Browse files
mlazosfacebook-github-bot
authored andcommitted
Optimize dedupe region ancestor tracking (#152589)
Summary: X-link: pytorch/pytorch#152589 Approved by: https://github.com/anijain2305 ghstack dependencies: #152389, #152505, #152410, #152506, #152570, #152572 Reviewed By: jeanschmidt Differential Revision: D74668984 fbshipit-source-id: cdb0ee61902bcde560b369fc065ab5b4d76e6157
1 parent d36d477 commit f3ef83d

File tree

1 file changed

+14
-6
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+14
-6
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,12 +3152,20 @@ def get_fake_value(node, tx, allow_non_graph_fake=False):
31523152
args, kwargs = get_fake_values_from_nodes(
31533153
tx, (node.args, node.kwargs), allow_non_graph_fake
31543154
)
3155-
flat_args_kwargs = get_fake_values_from_nodes(
3156-
tx, _get_flat_args(node, {}), allow_non_graph_fake
3157-
)
3158-
id_to_initial_version = {
3159-
id(arg): arg._version for arg in flat_args_kwargs if is_fake(arg)
3160-
}
3155+
3156+
if (
3157+
torch._dynamo.config.use_graph_deduplication
3158+
or torch._dynamo.config.track_nodes_for_deduplication
3159+
):
3160+
flat_args_kwargs = get_fake_values_from_nodes(
3161+
tx, _get_flat_args(node, {}), allow_non_graph_fake
3162+
)
3163+
id_to_initial_version = {
3164+
id(arg): arg._version for arg in flat_args_kwargs if is_fake(arg)
3165+
}
3166+
else:
3167+
flat_args_kwargs = []
3168+
id_to_initial_version = {}
31613169

31623170
nnmodule = None
31633171
if op == "call_method" and len(args) > 0 and isinstance(args[0], torch.nn.Module):

0 commit comments

Comments
 (0)