Skip to content

Conversation

@samanklesaria
Copy link
Collaborator

@samanklesaria samanklesaria commented Dec 12, 2025

Fixes #5128

According to the documentation, attributes of Modules that are Arrays, Variables, other Modules, or annotated with nnx.data should all show up as children when the parent module is flattened.

Currently, this is only true in flax when it comes to Jax's flattening system. In the NNX graph flattening system, we actually follow somewhat different rules. I'm not entirely sure how this system works (as there's lots of mutable state involved), but it roughly seems like the leaf nodes we get when flattening are just descent Variable and Array nodes. Nnx.data declarations don't do anything at all in Flax's graph flattening system.

This PR attempts to make Flax's graph flattening system work more like Jax's tree flattening one.

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.

nnx.data is lost during nnx.eval_shape

1 participant