-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Keras <> NNX integration #21252
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
base: master
Are you sure you want to change the base?
Keras <> NNX integration #21252
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21252 +/- ##
===========================================
- Coverage 82.81% 61.78% -21.03%
===========================================
Files 565 565
Lines 55520 55803 +283
Branches 8664 8716 +52
===========================================
- Hits 45977 34476 -11501
- Misses 7428 19190 +11762
- Partials 2115 2137 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
keras/src/random/random_test.py
Outdated
import jax.numpy as jnp | ||
|
||
x = ops.ones(3) | ||
|
||
@jax.jit | ||
@nnx.jit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the integration prevent the use of jax.jit
with Keras layers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! it would only work with nnx.jit for now ( They might be working on adding support for jax.jit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added nnx as a opt in with this flag - os.environ["KERAS_NNX_ENABLED"]
FLAX installation is pointing to my branch currently until the CL and PR changes makes it through the Flax Github |
model(x) | ||
model.predict(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this change? this seems to indicate a bug perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a model building bug? predict()
should work out of the box because the model should auto-build using the data as reference
set_floatx(_floatx) | ||
set_epsilon(_epsilon) | ||
set_image_data_format(_image_data_format) | ||
_BACKEND = _backend | ||
|
||
# Save config file, if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you need to move this block?
01e3f77
to
896ffa0
Compare
2214458
to
05d0119
Compare
The PR integrates NNX into JAX backend!
The following snippet shows how you would enable the nnx backend
Demo colab here : https://colab.sandbox.google.com/drive/1mK-4qbce2HGRIkcb4v5n4niWGDezL_6n#scrollTo=m-ZH9Mpnphfz
Added a github workflow action for nnx backend. Note this will fail - because this needs a new release of flax to work.