Skip to content

fix(contrib): correct momo and momo_adam docstring examples to use apply_updates - #1745

Open
wahid18-maqs wants to merge 2 commits into
google-deepmind:mainfrom
wahid18-maqs:fix/momo-docstring-update-example
Open

fix(contrib): correct momo and momo_adam docstring examples to use apply_updates#1745
wahid18-maqs wants to merge 2 commits into
google-deepmind:mainfrom
wahid18-maqs:fix/momo-docstring-update-example

Conversation

@wahid18-maqs

Copy link
Copy Markdown

Summary

This PR corrects the usage examples in the momo() and momo_adam() docstrings to follow the standard Optax optimizer update pattern and adds doctest coverage to keep the examples executable.

Changes

  • Update the momo() and momo_adam() docstring examples to:
    • capture updates from solver.update(...),
    • apply them using optax.apply_updates(...), and
    • update the expected outputs to match the corrected behavior.
  • Add a dedicated doctest wrapper in optax/contrib/_momo_test.py to execute the examples as part of the test suite.

Why

The previous examples assigned the return value of solver.update() directly to params, even though update() returns (updates, state). Users copying the examples would end up treating updates as parameters, leading to incorrect optimization behavior.

Adding doctest coverage also ensures the examples remain valid and synchronized with the implementation.

The doctest suite passes successfully

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@wahid18-maqs