Skip to content

Repair use of deprecated parameter#1671

Merged
copybara-service[bot] merged 2 commits into
google-deepmind:mainfrom
NeilGirdhar:fix_seed
May 29, 2026
Merged

Repair use of deprecated parameter#1671
copybara-service[bot] merged 2 commits into
google-deepmind:mainfrom
NeilGirdhar:fix_seed

Conversation

@NeilGirdhar
Copy link
Copy Markdown
Contributor

Note: This function is untested on main.

@NeilGirdhar
Copy link
Copy Markdown
Contributor Author

Incidentally, would you reconsider #1? Maintaining downstream shims for all of these functions is becoming increasingly tedious, especially since there appears to be a fairly small upstream change that would eliminate a lot of duplicated workaround code.

At least in my case, I’ve ended up maintaining an entire layer of wrappers/shims around Optax to recover this functionality:
https://github.com/NeilGirdhar/tjax/tree/main/tjax/_src/gradient

From reading through the discussion, it seems I’m not the only one who has independently arrived at this kind of solution.

Copy link
Copy Markdown
Collaborator

@rdyro rdyro left a comment

Choose a reason for hiding this comment

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

Thanks! Could you add a small tests for this change?

@rdyro
Copy link
Copy Markdown
Collaborator

rdyro commented May 5, 2026

Incidentally, would you reconsider #1? Maintaining downstream shims for all of these functions is becoming increasingly tedious, especially since there appears to be a fairly small upstream change that would eliminate a lot of duplicated workaround code.

At least in my case, I’ve ended up maintaining an entire layer of wrappers/shims around Optax to recover this functionality: https://github.com/NeilGirdhar/tjax/tree/main/tjax/_src/gradient

From reading through the discussion, it seems I’m not the only one who has independently arrived at this kind of solution.

I'm working on a PR for this, but it's hard to make this change while passing all internal tests. This might take some time :(

@NeilGirdhar
Copy link
Copy Markdown
Contributor Author

NeilGirdhar commented May 5, 2026

I'm working on a PR for this, but it's hard to make this change while passing all internal tests. This might take some time :(

Absolutely no problem!! If this is on the horizon, and I'll one day be able to delete my shims, that makes me extremely happy ❤️

By the way, as far as I can tell, my shims do pass your internal tests already--at least from the time I copied those tests.

Thanks! Could you add a small tests for this change?

Happy to, and done!

Comment thread optax/contrib/_privacy_test.py Outdated
with self.assertRaises(ValueError):
dp_agg.update(mean_grads, state, self.params)

def test_dpsgd_accepts_key(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you parametrized on both seed key: int = 0 and key: jax.Array = jax.random.key(0)

I think jax.random.key might need to called in the test scope rather than in the decorator, thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Collaborator

@rdyro rdyro left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Collaborator

@rdyro rdyro left a comment

Choose a reason for hiding this comment

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

Thanks!

@copybara-service copybara-service Bot merged commit 666c4a2 into google-deepmind:main May 29, 2026
11 of 16 checks passed
@NeilGirdhar NeilGirdhar deleted the fix_seed branch May 29, 2026 01:31
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.

2 participants