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

What is the status of nnx and TrainState? Are they compatible? #4609

Open
samuela opened this issue Mar 10, 2025 · 4 comments
Open

What is the status of nnx and TrainState? Are they compatible? #4609

samuela opened this issue Mar 10, 2025 · 4 comments
Assignees

Comments

@samuela
Copy link

samuela commented Mar 10, 2025

Looking at the nnx docs and example code, I am noticing that TrainState is conspicuously absent. Furthermore, the TrainState docstring still references the outdated linen API.

What's the word on the street on TrainState? Is it still relevant in a flax.nnx world?

@samuela
Copy link
Author

samuela commented Mar 10, 2025

@samuela
Copy link
Author

samuela commented Mar 10, 2025

There's also https://flax.readthedocs.io/en/latest/api_reference/flax.training.html#flax.training.train_state.TrainState but it does not mention flax.nnx.TrainState.

@cgarciae
Copy link
Collaborator

Hey @samuela, nnx.TrainState is not documented because it was a prototype from the old days, the need for this API was reduced when we introduced nnx.Optimizer which is more ergonomic. I think we should delete it and instead show users how to use train_state.TrainState with NNX.

@cgarciae cgarciae self-assigned this Mar 11, 2025
@samuela
Copy link
Author

samuela commented Mar 11, 2025

I think we should delete it and instead show users how to use train_state.TrainState with NNX.

My read from https://flax.readthedocs.io/en/latest/guides/linen_to_nnx.html#using-trainstate-in-flax-nnx, and specifically "In Flax NNX, [bundling parameters and optimizer] is not really necessary." was that TrainState is now obsolete. But perhaps this incorrect?

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

No branches or pull requests

2 participants