functionalization: avoid some unnecessary view_copy calls#75819
functionalization: avoid some unnecessary view_copy calls#75819bdhirsh wants to merge 6 commits intogh/bdhirsh/206/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit f96d020 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc @ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. [ghstack-poisoned]
When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc @ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. [ghstack-poisoned]
and exporting it to fbcode (not actually landing tis) [ghstack-poisoned]
ezyang
left a comment
There was a problem hiding this comment.
Nice! Having a test would be even better!
When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc @ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. [ghstack-poisoned]
When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc @ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. [ghstack-poisoned]
When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc @ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. [ghstack-poisoned]
|
@bdhirsh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@pytorchbot merge this (Initiating merge automatically since Phabricator Diff has merged) |
|
Merge failed due to Command Raised by https://github.com/pytorch/pytorch/actions/runs/2185815423 |
|
@pytorchmergebot merge this please |
|
Hey @bdhirsh. |
Summary: Pull Request resolved: #75819 When we're performing a sync on a `FuntionalTensorWrapper`, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base. This came up in the context of mobile using `functionalize()` and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872 cc ZolotukhinM We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply. Test Plan: Imported from OSS Reviewed By: zhxchen17 Differential Revision: D35705380 Pulled By: bdhirsh fbshipit-source-id: acd6811b4ca45e3b9d277496b391994fc7240927
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
…iews of same base" welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
welp, I realized my "perf improvement" from #75819 was wrong. This originally came up because `functionalize()` was sometimes emit an unnecessary `view_copy`, but there's a more correct fix that I can make inside of functorch, which I have here: pytorch/functorch#795 [ghstack-poisoned]
When we're performing a sync on a
FuntionalTensorWrapper, right now we first apply any updates to the base, and then we unconditionally regenerate the current tensor from the base.This came up in the context of mobile using
functionalize()and seeing an extra copy, so I have tests in a corresponding functorch PR: https://github.com/pytorch/functorch/pull/678/files#diff-449582f4f3e1ae76a73397c4b8ca62cc9dd5235dd831187f143180b498dee332R2872cc @ZolotukhinM
We can avoid some unnecessary copies going to the backend if we skip the regenerating when we know that there weren't any updates to apply.
Stack from ghstack:
Differential Revision: D35705380