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

Add direct penzai.treescope support for NNX objects. #3948

Merged
1 commit merged into from
May 29, 2024
Merged

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented May 28, 2024

Add direct penzai.treescope support for NNX objects.

This change implements the __penzai_repr__ protocol on most NNX
objects, making it possible to directly visualize them using the
standard penzai.treescope configuration without an extra conversion
step. Modules, GraphDefs, and States are all visualizable.

The nnx.display function is no longer needed if Penzai is installed,
since pz.ts.basic_interactive_setup() followed by
IPython.display.display or pz.show (or just returning an object
from an IPython cell) is now sufficient to visualize NNX objects.

Also fixes GraphDef repr to use "leaves" instead of "variables".

@copybara-service copybara-service bot force-pushed the test_637319547 branch 2 times, most recently from 37d5b08 to 4c20880 Compare May 29, 2024 14:33
This change implements the `__penzai_repr__` protocol on most NNX
objects, making it possible to directly visualize them using the
standard `penzai.treescope` configuration without an extra conversion
step. Modules, GraphDefs, and States are all visualizable.

The `nnx.display` function is no longer needed if Penzai is installed,
since `pz.ts.basic_interactive_setup()` followed by
`IPython.display.display` or `pz.show` (or just returning an object
from an IPython cell) is now sufficient to visualize NNX objects.

Also fixes GraphDef __repr__ to use "leaves" instead of "variables".

PiperOrigin-RevId: 638280968
@copybara-service copybara-service bot closed this pull request by merging all changes into main in 144486b May 29, 2024
@copybara-service copybara-service bot deleted the test_637319547 branch May 29, 2024 14:42
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.

1 participant