improve hijax guide#5115
Merged
copybara-service[bot] merged 1 commit intomainfrom Jan 6, 2026
Merged
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
0520c58 to
a7f8af9
Compare
8ce1c26 to
e99e55f
Compare
9cef051 to
d68e156
Compare
IvyZX
approved these changes
Jan 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR introduces significant refactoring to
flax.nnxto standardize variable metadata, improve Hijax support, and consolidate APIs. It also includes fixes for type hinting and documentation.Key Changes
Variable Metadata Standardization:
is_hijax→hijaxhas_ref→refis_mutable→mutableNew
var_defaultsAPI:nnx.var_defaults()to replacennx.use_hijax()andnnx.using_hijax().with nnx.var_defaults(hijax=True): ...@nnx.var_defaults(hijax=True)defaults = nnx.var_defaults()Unified Variable Conversion API:
nnx.vars_as()function:nnx.as_ref_vars(...)→nnx.vars_as(..., ref=True)nnx.as_immutable_vars(...)→nnx.vars_as(..., mutable=False)nnx.as_mutable_vars(...)→nnx.vars_as(..., mutable=True)nnx.as_hijax_vars(...)→nnx.vars_as(..., hijax=True)Fixes & Improvements
Refredefinition errors inflax/nnx/variablelib.py.@tp.overloadvalue shadowing forvar_defaults.propertyusage on non-method attributes.recursive_mapdocstring inflax/nnx/graph.py.docs_nnx/hijax/index.rst.Testing
integration_test.py,mutable_array_test.py,spmd_test.py,variable_test.py) to utilize the newvars_asandvar_defaultsAPIs.var_defaultscontext manager, including nesting behavior../tests/run_all_tests.sh --only-mypyand./tests/run_all_tests.sh --only-doctest.