8000 [Inductor] Pattern matcher support for mutable ops with non-view inputs by yf225 · Pull Request #152775 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[Inductor] Pattern matcher support for mutable ops with non-view inputs #152775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: gh/yf225/171/base
Choose a base branch
from

Conversation

ghstack-source-id: daace00
Pull-Request-resolved: #152767

[ghstack-poisoned]
Copy link
pytorch-bot bot commented May 4, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures, 1 Cancelled Job, 1 Unrelated Failure

As of commit 69fd7e1 with merge base 56d6d4d (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOB - The following job was cancelled. Please retry:

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.

yf225 added a commit that referenced this pull request May 4, 2025
ghstack-source-id: daace00
Pull-Request-resolved: #152767

ghstack-source-id: dbf44a7
Pull Request resolved: #152775
…n-view inputs"

Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 4, 2025
ghstack-source-id: 9592ff6
Pull-Request-resolved: #152767

ghstack-source-id: 9592ff6
Pull Request resolved: #152775
…n-view inputs"

Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 4, 2025
ghstack-source-id: 4173fb9
Pull-Request-resolved: #152767

ghstack-source-id: 4173fb9
Pull Request resolved: #152775
@yf225 yf225 requested review from zou3519 and eellison May 4, 2025 06:33
…n-view inputs"

Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 4, 2025
ghstack-source-id: 01c0214
Pull-Request-resolved: #152767

ghstack-source-id: 01c0214
Pull Request resolved: #152775
@@ -2082,6 +2083,7 @@ def fwd_only(
fn: Callable[..., Any],
args: Sequence[Any],
*,
apply_auto_functionalize: bool = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eellison usually has some ideas around API expansion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

    apply_auto_functionalize: bool = False,
    run_functional_passes: bool = True,

How do these two options relate to each other ? when would you do one but not the other ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed with Richard, currently:

  • run_functional_passes=True means "run DCE on the pattern and replacement graphs" (which is not safe to use for reinplace pass), maybe we can rename it to run_dce_and_noop_elimination.
  • apply_auto_functionalize=True means "run functionalize on both pattern and replacement graphs", maybe we can rename it to functionalize_patterns.

Q: Can we merge the two flags?

Seems in general they are the same value:

  • if "non_functional_ir", both False
  • if "functional_ir", both True
  • However pre_grad FX IR is an exception right now: it's "non_functional_ir", but it currently has run_functional_passes=True; so we might need to change it to False, if we want to merge the two flags.

8000
search_fn=mutable_ops_pattern,
replace_fn=mutable_ops_replacement,
example_inputs=[inp.clone().detach(), inp.clone().detach()],
trace_fn=functools.partial(fwd_only, apply_auto_functionalize=True),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should apply_auto_functionalize be the default for fwd_only? Since Inductor pattern matching happens only at the post-grad pass?
  2. If not, should we rename apply_auto_functionalize something like post_grad? Because that is where we plan to use the pattern matcher

register_replacement(
search_fn=mutable_ops_pattern,
replace_fn=mutable_ops_replacement,
example_inputs=[inp.clone().detach(), inp.clone().detach()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are technically exposing fwd_only as public API.

Instead of doing that I think it might be better for PatternMatcherPass to get an enum about the location it's operating on (e.g. post-grad functional IR).

Copy link
Contributor
@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I suggested another test case, plus we should bikeshed the API since this should be "public".

@yf225 yf225 mentioned this pull request May 7, 2025
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 7, 2025
ghstack-source-id: 07ff4e8
Pull-Request-resolved: #152767

ghstack-source-id: 07ff4e8
Pull Request resolved: #152775
@yf225 yf225 mentioned this pull request May 7, 2025
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 7, 2025
ghstack-source-id: 4560edf
Pull-Request-resolved: #152767

ghstack-source-id: 4560edf
Pull Request resolved: #152775
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 7, 2025
ghstack-source-id: 73677c7
Pull-Request-resolved: #152767

ghstack-source-id: 73677c7
Pull Request resolved: #152775
yf225 added 2 commits May 6, 2025 22:01
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
yf225 added a commit that referenced this pull request May 8, 2025
ghstack-source-id: 65eb9ad
Pull-Request-resolved: #152767

ghstack-source-id: 65eb9ad
Pull Request resolved: #152775
yf225 added 3 commits May 10, 2025 12:50
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
…n-view inputs"

Fixes the non-view input use case in #152441.


Pull-Request-resolved: #152767

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

[ghstack-poisoned]
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.

3 participants
0