Repository navigation
inductor: avoiding moving constructor to cuda when it would cause h2d sync in index_put_ fallback - #130338
inductor: avoiding moving constructor to cuda when it would cause h2d sync in index_put_ fallback#130338bdhirsh wants to merge 3 commits into
Conversation
… sync in index_put_ fallback [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/130338
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5e6f3a2 with merge base 81df076 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| # Therefore, when inductor sees an index_put_ with byte tensor indices, | ||
| # it should *not* convert the cpu scalar value into a cuda tensor. | ||
| any_byte_bool_indices = False | ||
| indices = node.args[1] |
There was a problem hiding this comment.
nit: use operator_schemas.normalize_function instead of directly accessing args
|
|
||
|
|
||
| def is_index_put_and_requires_h2d_sync_for_cuda_value(node): | ||
| if node.target is not torch.ops.aten.index_put.default: |
There was a problem hiding this comment.
do we want this for index_put_ as well ?
There was a problem hiding this comment.
I figured it would just never get hit since functionalization has already run, and reinplacing runs in a later pass. But probably doesn't hurt to add, can add it
hmmm let me know if you have better testing ideas - the idea of a "no h2d sync happened" test feels a bit fragile (e.g. I could have the test run the profiler and parse the output to ensure that Alternatively, I could just add an expecttest test where I assert that the final inductor graph properly keeps the scalar-tensor on cpu when the above conditions apply, as a proxy for the H2D sync test (i'll probably default to that) |
|
@bdhirsh yea sg, that's what i was thinking |
…d cause h2d sync in index_put_ fallback" My attempt at a fix for #130335, see issue for more details / internal xref. Any feedback from inductor folks is appreciated. I attempted to make the move-constructors-to-cuda pass a bit less aggressive by detecting when the movement would incur a H2D sync for `aten.index_put_`. I'm not sure if there are any other ops that inductor falls back to eager on, that may-or-may-not incur a H2D sync if we change any of their inputs from cpu to cuda. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
…d cause h2d sync in index_put_ fallback" My attempt at a fix for #130335, see issue for more details / internal xref. Any feedback from inductor folks is appreciated. I attempted to make the move-constructors-to-cuda pass a bit less aggressive by detecting when the movement would incur a H2D sync for `aten.index_put_`. I'm not sure if there are any other ops that inductor falls back to eager on, that may-or-may-not incur a H2D sync if we change any of their inputs from cpu to cuda. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
|
land ? |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
… sync in index_put_ fallback (#130338) My attempt at a fix for #130335, see issue for more details / internal xref. Any feedback from inductor folks is appreciated. I attempted to make the move-constructors-to-cuda pass a bit less aggressive by detecting when the movement would incur a H2D sync for `aten.index_put_`. I'm not sure if there are any other ops that inductor falls back to eager on, that may-or-may-not incur a H2D sync if we change any of their inputs from cpu to cuda. Pull Request resolved: #130338 Approved by: https://github.com/eellison
… sync in index_put_ fallback (pytorch#130338) My attempt at a fix for pytorch#130335, see issue for more details / internal xref. Any feedback from inductor folks is appreciated. I attempted to make the move-constructors-to-cuda pass a bit less aggressive by detecting when the movement would incur a H2D sync for `aten.index_put_`. I'm not sure if there are any other ops that inductor falls back to eager on, that may-or-may-not incur a H2D sync if we change any of their inputs from cpu to cuda. Pull Request resolved: pytorch#130338 Approved by: https://github.com/eellison
My attempt at a fix for #130335, see issue for more details / internal xref. Any feedback from inductor folks is appreciated. I attempted to make the move-constructors-to-cuda pass a bit less aggressive by detecting when the movement would incur a H2D sync for
aten.index_put_. I'm not sure if there are any other ops that inductor falls back to eager on, that may-or-may-not incur a H2D sync if we change any of their inputs from cpu to cuda.Stack from ghstack (oldest at bottom):
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang