Add Keras Core (Keras 3.0) support #26224
Closed
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.
This PR is a very-very-very work in progress effort to add Keras Core support, and to prepare for the transition to Keras 3.0. Because Keras Core is still a beta/preview, this PR is likely to be fairly slow and cautious, we don't want to lock ourselves into an API that may change under our feet!
The goal of this PR is to create a "minimum viable port(duct)" of our
tf.keras
code tokeras-core
to assess how difficult it will be to support Keras Core. Therefore, this port has the following properties:safetensors
will be supported for now, so I don't have to support every possible combination of (weights_format, model_framework)GenerationMixin
will be inherited directly from the framework that corresponds to the activekeras-core
framework. This means thatkeras-core
classes will change their inheritance depending on which framework is live, which is risky but greatly reduces the amount of code I need to write.The plan for this PR is:
modeling_keras_outputs.py
(ported frommodeling_tf_outputs.py
)modeling_keras_utils.py
(ported frommodeling_tf_utils.py
)fit()
or auto-wrapping HF datasets in a KerasPyDataset