Skip to content
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

update jax.tree.map to comply with jax 0.4.34 #1094

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

a1302z
Copy link
Contributor

@a1302z a1302z commented Oct 7, 2024

Pull Request to fix #1093

Copy link

google-cla bot commented Oct 7, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

@vroulet vroulet left a comment

Choose a reason for hiding this comment

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

Thank you for doing that!
Would it be possible to add a generic test for such functions?
(tree_update_moment, tree_update_infinity_moment and tree_update_moment_per_elem_norm follow the same fix).
Thanks again!

@a1302z
Copy link
Contributor Author

a1302z commented Oct 8, 2024

Happy to do that. How would you imagine this test to be fully generic? A simple test case would be something like this (extended to all corresponding functions):

  def test_none_arguments(self):
    m = jnp.logspace(-10, 10, num=21, dtype=jnp.bfloat16)  # 1e-10 ... 1e10
    tu.tree_update_moment(None, m, 0.9, 1)

Let me know what you think.

@vroulet
Copy link
Collaborator

vroulet commented Oct 8, 2024

Yes, I would even simplify it by using just jnp.array([1., 2., 3.]) instead of jnp.logspace.
Thank you again for doing that!

@a1302z
Copy link
Contributor Author

a1302z commented Oct 10, 2024

I have added test cases for tree_add_scalar_mul, tree_update_moment, tree_update_infinity_moment, tree_update_moment_per_elem_norm, apply_updates, incremental_update, keep_params_nonnegative, and add_decayed_weights. I have omitted scale_by_adam as mu would need to be None, which is not an input argument to the function.

Copy link
Collaborator

@vroulet vroulet left a comment

Choose a reason for hiding this comment

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

Thank you very much, I left you some additional comments

optax/_src/update_test.py Outdated Show resolved Hide resolved
optax/transforms/_adding_test.py Outdated Show resolved Hide resolved
optax/transforms/_constraining_test.py Outdated Show resolved Hide resolved
optax/tree_utils/_tree_math_test.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@vroulet vroulet left a comment

Choose a reason for hiding this comment

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

That's perfect, thank you again @a1302z !

@copybara-service copybara-service bot merged commit cd28329 into google-deepmind:main Oct 14, 2024
8 checks passed
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.

Jax 0.4.34 raises an error for None as tree-prefix
2 participants