Skip to content

Add graph argument to split, state, graphdef, clone#5258

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_869919836
Open

Add graph argument to split, state, graphdef, clone#5258
copybara-service[bot] wants to merge 1 commit intomainfrom
test_869919836

Conversation

@copybara-service
Copy link

Add graph argument to split, state, graphdef, clone

Expose the graph: bool = True argument on the remaining public graph utility
functions, allowing users to opt into tree-mode for split, state, graphdef,
and clone — not just through transforms like nnx.jit.

Tree-mode (graph=False) treats Modules as regular JAX pytrees, avoiding the
overhead of the graph protocol. In tree-mode, duplicate Variable instances
are not allowed and will raise a ValueError, and shared Ref instances between
different parts of the graph are not supported since reference tracking is
bypassed entirely.

Also parametrizes 9 existing split/merge/flatten tests to run under both
graph=True and graph=False, increasing tree-mode test coverage.

@copybara-service copybara-service bot force-pushed the test_869919836 branch 2 times, most recently from 0df996b to 57aa6bc Compare February 17, 2026 23:43
Expose the graph: bool = True argument on the remaining public graph utility
functions, allowing users to opt into tree-mode for split, state, graphdef,
and clone — not just through transforms like nnx.jit.

Tree-mode (graph=False) treats Modules as regular JAX pytrees, avoiding the
overhead of the graph protocol. In tree-mode, duplicate Variable instances
are not allowed and will raise a ValueError, and shared Ref instances between
different parts of the graph are not supported since reference tracking is
bypassed entirely.

Also parametrizes 9 existing split/merge/flatten tests to run under both
graph=True and graph=False, increasing tree-mode test coverage.
PiperOrigin-RevId: 869919836
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.

0 participants

Comments