-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add LazyBatchNormXd #51548
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
Add LazyBatchNormXd #51548
Conversation
💊 CI failures summary and remediationsAs of commit 623ec45 (more details on the Dr. CI page):
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
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.
Thanks for the PR!
The batchnorm part looks good to me. Just small comments.
For the LazyBuffer, I think we can do some refactoring to simplify the code, see comment below.
torch/nn/parameter.py
Outdated
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.
paremeter -> buffer
torch/nn/parameter.py
Outdated
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.
Unlike
torch/nn/parameter.py
Outdated
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.
nit: can we share this list with the UninitializedParameter version above?
torch/nn/parameter.py
Outdated
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 almost identical the parameter version above. i wonder if we could reduce the code duplication with a UninitializedMixin
that is shared for both here?
@albanD Thank you for the review! Could you take another look? |
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.
Thanks for the update! It looks much better.
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.
The code looks good to me!
CI failures are real though, can you fix that? Let me know if you need help!
4bdd32b
to
d9845dc
Compare
d9845dc
to
623ec45
Compare
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.
Hey!
Thanks for fixing the mypy issues.
The doc failure does look unrelated to me.
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.
@albanD has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request has been reverted by a930162. |
So the doc issues were real and broke master. Could you send a new PR with the same diff where we can check how to fix the doc? |
Summary: Some minor improvement for lazy modules introduced in #44538, #47350 and #51548. This PR mainly turn the bias to `UninitializedParameter` and instead of creating empty tensors like ```python self.bias = Parameter(torch.Tensor(0)) self.bias = UninitializedParameter() ``` I think it would be better to ```python self.register_parameter('bias', None) self.bias = UninitializedParameter() ``` In addition, I change the constructor of the `LazyBatchNorm` from ```python self.running_mean = UninitializedBuffer() ``` to ```python self.register_buffer('running_mean', UninitializedBuffer()) ``` as the original one would not change the underlying `self._buffers`. Thank you for your time on reviewing this PR :). Gently ping albanD, mruberry Pull Request resolved: #52212 Reviewed By: jbschlosser Differential Revision: D26504508 Pulled By: albanD fbshipit-source-id: 7094d0bb4fa9e2a40a07b79d350ea12a6ebfd080
Summary: Same diff with pytorch#51548 (cc. albanD) Pull Request resolved: pytorch#51862 Reviewed By: izdeby Differential Revision: D26312289 Pulled By: albanD fbshipit-source-id: 9cdec0e0c9021c33d10d85010978c7fa5cb4dc60
…h#52212) Summary: Some minor improvement for lazy modules introduced in pytorch#44538, pytorch#47350 and pytorch#51548. This PR mainly turn the bias to `UninitializedParameter` and instead of creating empty tensors like ```python self.bias = Parameter(torch.Tensor(0)) self.bias = UninitializedParameter() ``` I think it would be better to ```python self.register_parameter('bias', None) self.bias = UninitializedParameter() ``` In addition, I change the constructor of the `LazyBatchNorm` from ```python self.running_mean = UninitializedBuffer() ``` to ```python self.register_buffer('running_mean', UninitializedBuffer()) ``` as the original one would not change the underlying `self._buffers`. Thank you for your time on reviewing this PR :). Gently ping albanD, mruberry Pull Request resolved: pytorch#52212 Reviewed By: jbschlosser Differential Revision: D26504508 Pulled By: albanD fbshipit-source-id: 7094d0bb4fa9e2a40a07b79d350ea12a6ebfd080
This PR implements UninitializedBuffer and LazyBatchnormXd based on #44538. (cc. @emcastillo and @albanD)