-
Notifications
You must be signed in to change notification settings - Fork 610
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
fix LazyAdam resource variable ops performance issue #2274
fix LazyAdam resource variable ops performance issue #2274
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
You are owner of some files modified in this pull request. |
@googlebot I signed it! |
0ab4d4c
to
389e955
Compare
389e955
to
e18fcfc
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.
LGTM! Thanks for the fix and sorry that I didn't notice the performance regression previously.
@WindQAQ no worries! Thanks for merging. I see some GPU build check failed after the merge with a connection error. Is that related/normal? |
It's unrelated to this PR I believe 😄 Will let you know if there is anything wrong! |
Description
Brief Description of the PR:
Swap calls to
OptimizerV2._resource_scatter_update
andOptimizerV2._resource_scatter_add
with direct calls toresource_variable_ops.resource_scatter_update
andresource_variable_ops.resource_scatter_sub
.The
OptimizerV2
methods are wrappers around theresource_variable_ops
, except they extract and return the underlyingTensor
from the op instead of returning the operation. This causes a big performance hit as outlined in issue #2273.The returned tensor is not necessary for this "lazy" version of Adam sparse updates, since the op isn't used in subsequent computation. Thus we can avoid the extra
.value()
call inOptimizerV2._resource_scatter_update/sub/add
Fixes #2273
Type of change
Checklist:
How Has This Been Tested?
If you're adding a bugfix or new feature please describe the tests that you ran to verify your changes:
https://colab.research.google.com/drive/1T1X9log6pyDShHkKRxTPqkZwj0iZsowy?usp=sharing
With both the Keras and Estimator APIs. Validated model equality while observing major performance boost.