KEMBAR78
[torch][fx] Add new replacement_callback to materialize a replacement just in time by dulinriley · Pull Request #135553 · pytorch/pytorch · GitHub
Skip to content

Conversation

@dulinriley
Copy link
Contributor

Summary:
Sometimes we only want to generate a replacement for a matched pattern
once we know some information about the nodes in the pattern.

So far, we have found this the most useful to do matches based on specific
shapes of tensors flowing into functions.
Use a callback function similar to match_filters. By default this isn't used.

Had to make replacement a None-able parameter because Callable was
already used to detect a case where a graph needed to be traced.

Differential Revision: D62412628

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 9, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 958e9df with merge base 3bf6be4 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Sep 9, 2024
@facebook-github-bot
Copy link
Contributor

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

@SherlockNoMad
Copy link
Contributor

lgtm, could you mind adding a unittest?

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 10, 2024
@dulinriley
Copy link
Contributor Author

@SherlockNoMad where should I add a unit test for this function? Is test/fx/test_subgraph_rewriter.py the right location?

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

… just in time (pytorch#135553)

Summary:
Pull Request resolved: pytorch#135553

Sometimes we only want to generate a replacement for a matched pattern
once we know some information about the nodes in the pattern.

So far, we have found this the most useful to do matches based on specific
shapes of tensors flowing into functions.
Use a callback function similar to `match_filters`. By default this isn't used.

Had to make `replacement` a None-able parameter because Callable was
already used to detect a case where a graph needed to be traced.

Test Plan: Added a new unit test in test_subgraph_rewriter.py

Reviewed By: SherlockNoMad

Differential Revision: D62412628
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge -f 'Landed internally'

(Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
… just in time (pytorch#135553)

Summary:
Sometimes we only want to generate a replacement for a matched pattern
once we know some information about the nodes in the pattern.

So far, we have found this the most useful to do matches based on specific
shapes of tensors flowing into functions.
Use a callback function similar to `match_filters`. By default this isn't used.

Had to make `replacement` a None-able parameter because Callable was
already used to detect a case where a graph needed to be traced.

Differential Revision: D62412628

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

Labels

ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged release notes: fx release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants