Skip to content

Conversation

@cantonios
Copy link
Contributor

Added optimizer variables were orginally interleaved during build prior to #21232, e.g. {momentum0, velocity0, momentum1, velocity1, ...}. In #21232, the order was changed to non-interleaved for some optimizers, e.g. {momentum0, momentum1, ..., velocity0, velocity1, ...}. This broke some custom checkpoint serialization compatibility that relied on the order of variables remaining consistent.

Here we modify the base function add_optimizer_variables(...) to support creating multiple optimizer variables per training variable, and interleaves creation to restore backward compatibility.

…ity.

Added optimizer variables were orginally interleaved during `build` prior to keras-team#21232,
e.g. `{momentum0, velocity0, momentum1, velocity1, ...}`.  In keras-team#21232, the order
was changed to non-interleaved for some optimizers, e.g.
`{momentum0, momentum1, ..., velocity0, velocity1, ...}`.  This broke some
custom checkpoint serialization compatibility that relied on the order of
variables remaining consistent.

Here we modify the base function `add_optimizer_variables(...)` to support
creating multiple optimizer variables per training variable, and interleaves
creation to restore backward compatibility.
@cantonios
Copy link
Contributor Author

@hertschuh, this allows the RecML tests to all pass.

@codecov-commenter
Copy link

codecov-commenter commented May 4, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.59%. Comparing base (f5171b3) to head (2b5d86b).

Files with missing lines Patch % Lines
keras/src/optimizers/base_optimizer.py 87.50% 1 Missing and 1 partial ⚠️
keras/src/optimizers/adafactor.py 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21247      +/-   ##
==========================================
- Coverage   82.60%   82.59%   -0.01%     
==========================================
  Files         564      564              
  Lines       54543    54554      +11     
  Branches     8472     8479       +7     
==========================================
+ Hits        45054    45060       +6     
- Misses       7402     7405       +3     
- Partials     2087     2089       +2     
Flag Coverage Δ
keras 82.40% <88.88%> (-0.01%) ⬇️
keras-jax 63.66% <88.88%> (-0.01%) ⬇️
keras-numpy 58.79% <81.48%> (-0.01%) ⬇️
keras-openvino 32.98% <3.70%> (-0.01%) ⬇️
keras-tensorflow 64.08% <88.88%> (-0.01%) ⬇️
keras-torch 63.73% <88.88%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels May 5, 2025
@fchollet fchollet merged commit 4595239 into keras-team:master May 5, 2025
8 checks passed
@gbaned gbaned added this to PR Queue May 5, 2025
@github-project-automation github-project-automation bot moved this to Assigned Reviewer in PR Queue May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kokoro:force-run ready to pull Ready to be merged into the codebase size:M

Projects

Status: Assigned Reviewer

Development

Successfully merging this pull request may close these issues.

4 participants