Skip to content

Patch release commits for 3.13.1 - #22005

Merged
hertschuh merged 4 commits into
keras-team:r3.13from
sachinprasadhs:r3.13
Jan 14, 2026
Merged

hertschuh merged 4 commits into
keras-team:r3.13from
sachinprasadhs:r3.13

Conversation

@sachinprasadhs

Copy link
Copy Markdown
Collaborator

hertschuh and others added 4 commits January 13, 2026 15:05
Merely importing keras currently triggers this warning with NumPy 2.

```
keras/src/export/tf2onnx_lib.py:8: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
```

Only patch NumPy if and when needed.
The signature of `check_is_flash_attention` changed with JAX 0.7.0. In addition to `query` and `key`, a positional argument of `value` was added.

This was not caught as our kokoro tests use JAX 0.6.2 because it's the last version that supports Python 3.10.

This change was tested here: keras-team#21957
This is a follow-up of keras-team#21674

This PR changed the signature of `make_tf_tensor_spec` from `(x)` to `(x, dynamic_batch=True)`, thereby adding the ability to make the batch size dynamic.

This PR also adds `_get_save_spec(self, dynamic_batch=True)` which uses `make_tf_tensor_spec` and forwards the `dynamic_batch` argument.

However, the default before this change for other export (SavedModel, ONNX) was to keep the batch size untouched. In particular, when a user manually provides an `input_signature` to [`ExportArchive.add_endpoint`](https://github.com/keras-team/keras/blob/master/keras/src/export/saved_model.py#L362), we should honor. The user controls whether the batch size is dynamic or not in the `input_signature`.

This PR changes the default of `make_tf_tensor_spec` back to `dynamic_batch=False` to revert SavedModel and ONNX exports to the previous behavior.

Also removed call to `return super()._get_save_spec(dynamic_batch)` which can never succeed as `TFLayer` is a top level class (ignoring the auto-tracking stuff).
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @sachinprasadhs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces Keras version 3.13.1, a patch release focused on addressing several critical bugs. It includes fixes for CUDNN flash attention compatibility with recent JAX versions, resolves regressions in the model export process, and enhances NumPy compatibility for ONNX export to prevent import-time warnings. These changes aim to improve the stability and robustness of the Keras framework.

Highlights

  • JAX Flash Attention Compatibility Fix: Resolved an issue where CUDNN flash attention was broken when using JAX versions greater than 0.6.2. This was achieved by making the argument passing to internal utility functions (check_layout and check_is_flash_attention) more robust through dynamic inspection of their signatures.
  • Export Regression Addressed: Fixed regressions related to model export functionality. This includes simplifying the _get_save_spec logic in the TensorFlow backend and changing the default dynamic_batch parameter in make_tf_tensor_spec from True to False, which impacts how batch dimensions are handled during export.
  • NumPy Compatibility for ONNX Export: Improved compatibility with newer NumPy versions by relocating a patch for np.object within the tf2onnx_lib.py file. This change prevents potential warnings during Keras import by ensuring the patch is applied only when tf2onnx is actively being used.
  • Version Update: The Keras version has been updated from 3.13.0 to 3.13.1, signifying this patch release that incorporates the aforementioned fixes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request includes a set of patches for the 3.13.1 release, addressing a warning on import, a CUDNN flash attention issue with JAX, and an export regression. The changes appear correct and effectively resolve the described issues. The version bump is appropriate for a patch release. I've added a couple of suggestions to improve code quality and robustness in the JAX backend.

Comment thread keras/src/backend/jax/nn.py
Comment thread keras/src/backend/jax/nn.py
@codecov-commenter

codecov-commenter commented Jan 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 14 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (r3.13@986ff97). Learn more about missing BASE report.

Files with missing lines Patch % Lines
keras/src/backend/jax/nn.py 0.00% 7 Missing ⚠️
keras/src/backend/tensorflow/layer.py 0.00% 5 Missing ⚠️
keras/src/export/tf2onnx_lib.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             r3.13   #22005   +/-   ##
========================================
  Coverage         ?   82.65%           
========================================
  Files            ?      588           
  Lines            ?    61266           
  Branches         ?     9607           
========================================
  Hits             ?    50642           
  Misses           ?     8141           
  Partials         ?     2483           
Flag Coverage Δ
keras 82.48% <12.50%> (?)
keras-jax 61.67% <12.50%> (?)
keras-numpy 56.91% <12.50%> (?)
keras-openvino 37.19% <12.50%> (?)
keras-tensorflow 63.84% <12.50%> (?)
keras-torch 62.57% <12.50%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@google-ml-butler google-ml-butler Bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Jan 13, 2026
@hertschuh
hertschuh merged commit 8914427 into keras-team:r3.13 Jan 14, 2026
18 checks passed
@google-ml-butler google-ml-butler Bot removed awaiting review ready to pull Ready to be merged into the codebase labels Jan 14, 2026
@sachinprasadhs
sachinprasadhs deleted the r3.13 branch January 14, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants