Skip to content

Conversation

yushangdi
Copy link
Contributor

@yushangdi yushangdi commented Jul 30, 2025

Summary:

The replace_hook is called once for each user of the replaced node. This fix avoids adding duplicated node sources.

This also means that if there are two nested pass like:

with GraphTransformObserver(gm, "outer"):
      with GraphTransformObserver(gm, "inner"):
              .....

We'll only see the outer pass's pass name recorded for the replaced node in the "from_node" node meta. I think this is fine. In practice, the outer pass usually contains a more meaningful name, e.g. decompose_auto_functionalized, and the inner pass name is just a default pass name like pattern_matcher.

Test Plan:

buck2 run @mode/dev-nosan fbcode//caffe2/test:fx -- -r test_graph_transform_observer_replace

Rollback Plan:

Differential Revision: D79203058

cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

Summary: Reduce compilation time when flag is on by at least 10x.

Test Plan:
```
 python test/higher_order_ops/test_invoke_subgraph.py -k test_input_mutation_mutiple_times
```

Rollback Plan:

Differential Revision: D79203058
Copy link

pytorch-bot bot commented Jul 30, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159484

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (6 Unrelated Failures)

As of commit 48cf0e4 with merge base ee343ce (image):

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79203058

@yushangdi yushangdi changed the title Fix duplicated sources Fix duplicated sources in inductor provenance tracking Jul 30, 2025
@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 30, 2025
@yushangdi yushangdi requested a review from angelayi July 30, 2025 16:09
@yushangdi yushangdi added topic: not user facing topic category and removed release notes: fx release notes category labels Jul 30, 2025
@yushangdi
Copy link
Contributor Author

@pytorchbot merge -i

yangw-dev pushed a commit that referenced this pull request Aug 1, 2025
Summary:

The `replace_hook` is called once for each user of the replaced node. This fix avoids adding duplicated node sources.

This also means that if there are two nested pass like:

```
with GraphTransformObserver(gm, "outer"):
      with GraphTransformObserver(gm, "inner"):
              .....
```

We'll only see the outer pass's pass name recorded for the replaced node in the "from_node" node meta. I think this is fine. In practice, the outer pass usually contains a more meaningful name, e.g. `decompose_auto_functionalized`, and the inner pass name is just a default pass name like `pattern_matcher`.

Test Plan:
```
buck2 run @mode/dev-nosan fbcode//caffe2/test:fx -- -r test_graph_transform_observer_replace
```

Rollback Plan:

Differential Revision: D79203058

Pull Request resolved: #159484
Approved by: https://github.com/angelayi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants