-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[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
base: gh/yf225/171/base
Are you sure you want to change the base?
Conversation
🔗 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 FailureAs of commit 69fd7e1 with merge base 56d6d4d ( 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. |
…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]
…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]
…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]
@@ -2082,6 +2083,7 @@ def fwd_only( | |||
fn: Callable[..., Any], | |||
args: Sequence[Any], | |||
*, | |||
apply_auto_functionalize: bool = False, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 torun_dce_and_noop_elimination
.apply_auto_functionalize=True
means "run functionalize on both pattern and replacement graphs", maybe we can rename it tofunctionalize_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.
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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should apply_auto_functionalize be the default for fwd_only? Since Inductor pattern matching happens only at the post-grad pass?
- If not, should we rename
apply_auto_functionalize
something likepost_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()], |
There was a problem hiding this comment.
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).
There was a problem hiding this 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".
Fixes the non-view input use case in #152441.
Stack from ghstack (oldest at bottom):
Pull-Request-resolved: #152767
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov