flax icon indicating copy to clipboard operation
flax copied to clipboard

[nnx] Add NNX WeightNorm.

Open nilq opened this issue 11 months ago • 4 comments

What does this PR do?

This PR addresses #4426 by implementing an NNX WeightNorm class. This brings the requested normalization class to the NNX library – implemented to be consistent with the corresponding module in Linen.

Checklist

  • [x] This change is discussed in #4426.
  • [x] The documentation and docstrings adhere to the documentation guidelines.
  • [x] This change includes necessary high-coverage tests.

nilq avatar Feb 24 '25 18:02 nilq

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.

google-cla[bot] avatar Feb 24 '25 18:02 google-cla[bot]

To resolve the pytest issues you will have to add some deprecation warning to the list here: https://github.com/google/flax/blob/6af8fcb0bfac1eb078bdf5ba41a3899a71dcaf81/pyproject.toml#L186-L188

If this is not from your PR we can fix it in main first.

cgarciae avatar Feb 27 '25 03:02 cgarciae

To resolve the pytest issues you will have to add some deprecation warning to the list here:

https://github.com/google/flax/blob/6af8fcb0bfac1eb078bdf5ba41a3899a71dcaf81/pyproject.toml#L186-L188

If this is not from your PR we can fix it in main first.

I believe this would be outside of this PR.

nilq avatar Mar 06 '25 09:03 nilq

@cgarciae Just a friendly ping – in case this might have drowned. 🙂

nilq avatar Mar 26 '25 09:03 nilq

Hello, I think the variable filter is not correctly working? The code does not apply them to extract only the required variables to be normalized, and there is only case where no variable filter is passed.

HyperBlaze456 avatar Jun 21 '25 23:06 HyperBlaze456

Hi @nilq - we'd like to finally land this PR on top of all the recent changes to nnx! We just merged support for SpectralNorm (#4623), and your WeightNorm code is quite similar. Do you think it might be possible to factor out some of the shared functionality?

samanklesaria avatar Oct 02 '25 15:10 samanklesaria

Closed by #5043

samanklesaria avatar Oct 27 '25 14:10 samanklesaria