-
Notifications
You must be signed in to change notification settings - Fork 102
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
[jvpvjp] Batch norm coverage with decomposition #877
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samdow
force-pushed
the
batch_norm_decomp
branch
from
June 15, 2022 17:52
e072fd0
to
44727e7
Compare
samdow
force-pushed
the
batch_norm_decomp
branch
2 times, most recently
from
June 16, 2022 16:23
3b68942
to
825f439
Compare
zou3519
approved these changes
Jun 17, 2022
zou3519
reviewed
Jun 17, 2022
Comment on lines
+208
to
+215
grad_weight = torch.zeros_like(weight) # should be None but doesn't work with vjp | ||
else: | ||
grad_weight = torch.zeros(()) # should be None but doesn't work with vjp | ||
|
||
if output_mask[2]: | ||
grad_bias = grad_output_sum | ||
else: | ||
grad_bias = torch.zeros_like(grad_output_sum) # should be None but doesn't work with vjp |
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.
sad, but is it what it is
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 11, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 12, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 12, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 12, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 12, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
zou3519
pushed a commit
to zou3519/pytorch
that referenced
this pull request
Jul 20, 2022
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
bigfootjon
pushed a commit
to pytorch/pytorch
that referenced
this pull request
Jul 21, 2022
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Aug 4, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Aug 4, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Aug 4, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Aug 4, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Oct 10, 2022
… and saved_var when input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
soulitzer
added a commit
to pytorch/pytorch
that referenced
this pull request
Oct 10, 2022
…hen input requires grad" We want to avoid having to recompute saved_mean and saved_invstd in batch_norm_backward's decomposition in functorch (see pytorch/functorch#877), but also avoid unnecessarily computing forward grads for saved_mean and saved_invstd when they are not needed. Tested locally with: `python test/test_ops.py -k test_jvpvjp_nn_functional_batch_norm` Issues: - not sure if gradgrad in core is missing something, but it is able to pass while the fwgrad_bwgrad comparison fails in functorch [ghstack-poisoned]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds decomposition from #675 for forward over reverse coverage. Similar to with layer norm, we needed to recompute the mean and variance so autograd propagates properly (sad) and needed to return tensors of zeros instead of None (sad)