Skip to content

fix(contrib): improve adopt docstring example to show meaningful convergence and add doctest coverage - #1747

Draft
wahid18-maqs wants to merge 2 commits into
google-deepmind:mainfrom
wahid18-maqs:docs/adopt-docstring-convergence-example
Draft

fix(contrib): improve adopt docstring example to show meaningful convergence and add doctest coverage#1747
wahid18-maqs wants to merge 2 commits into
google-deepmind:mainfrom
wahid18-maqs:docs/adopt-docstring-convergence-example

Conversation

@wahid18-maqs

Copy link
Copy Markdown

Summary

This PR improves the adopt() docstring example to show meaningful optimizer convergence and adds doctest coverage to keep the example executable.

Changes

  • Update the adopt() docstring example to:
    • Use learning_rate=0.1 instead of 0.003 so the optimizer makes visible progress
    • Use jax.value_and_grad instead of jax.grad to follow the idiomatic optax pattern
    • Update expected outputs to match the corrected example
  • Add optax/contrib/_adopt_test.py with a doctest.DocTestSuite wrapper to execute the example as part of the test suite

Why

The previous example used learning_rate=0.003 which produced no visible decrease in the objective function across 5 steps — the loss stayed at 14.0 throughout. This misled users into thinking ADOPT was not working or that stagnation was expected behavior.

The updated example uses a more appropriate learning rate that shows the optimizer actually making progress, giving users a realistic expectation of what ADOPT does.

Adding doctest coverage also ensures the example remains valid and synchronized with the implementation going forward.

Sign up for free to 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