Skip to content

Conversation

@pctablet505
Copy link
Collaborator

This pull request focuses on updating the minimum Python version requirement to 3.11 across the project, updating the default Keras version in CI workflows, and simplifying the implementation of the ReversibleEmbedding layer by delegating to the upstream Keras implementation. It also removes the local test suite for ReversibleEmbedding and updates documentation and environment setup instructions accordingly.

Python and Keras version updates:

  • Updated all GitHub Actions workflows and documentation (README.md, CONTRIBUTING.md) to require Python 3.11 or later instead of 3.10, ensuring consistency across development, testing, and deployment environments. [1] [2] [3] [4] [5] [6] [7]
  • Updated the CI matrix to use Keras 3.13 as the stable version for JAX backend, and changed installation steps to match. [1] [2]

Environment and build script changes:

  • In .kokoro/github/ubuntu/gpu/build.sh, set DEBIAN_FRONTEND=noninteractive for non-interactive package installs and temporarily relaxed the pyproject.toml Python requirement to allow Python 3.10 for GPU tests. [1] [2]

Codebase simplification and maintenance:

  • Replaced the local implementation of ReversibleEmbedding in keras_hub/src/layers/modeling/reversible_embedding.py with a direct subclass of the upstream Keras version, delegating all logic.
  • Updated imports in token_and_position_embedding.py to use the upstream ReversibleEmbedding directly.
  • Removed the now-redundant local test suite for ReversibleEmbedding from reversible_embedding_test.py.## Description of the change

Reference

Colab Notebook

Checklist

  • I have added all the necessary unit tests for my change.
  • I have verified that my change does not break existing code and works with all backends (TensorFlow, JAX, and PyTorch).
  • My PR is based on the latest changes of the main branch (if unsure, rebase the code).
  • I have followed the Keras Hub Model contribution guidelines in making these changes.
  • I have followed the Keras Hub API design guidelines in making these changes.
  • I have signed the Contributor License Agreement.

divyashreepathihalli and others added 16 commits December 22, 2025 11:54
* Update gemma3_causal_lm_preprocessor.py

Added checks for invalid inputs

* Update gemma3_causal_lm_preprocessor.py

* Update gemma3_causal_lm_preprocessor_test.py

Added tests to check invalid inputs

* Update reversible_embedding.py

Fix for model not loading when using numpy behaviour with tensorflow

* upadated Gemma3InterleaveEmbeddings

* Update gemma3_interleave_embeddings.py

* Revert "Update reversible_embedding.py"

This reverts commit 3fdc7fd.

* Update gemma3_interleave_embeddings.py

* Fix ReversibleEmbedding quantization for Keras 3.13 compatibility

- Update _int8_build method to accept config parameter
- Ensure backward compatibility with Keras 3.12
- Resolves TypeError in quantization tests
…am#2482)

* Models should reference ReversibleEmbedding from Keras core

* backwards compat

* remove keras 3.9 from test matrix

* python version changes

* disable cache when fetching nightly
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pctablet505, 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 primarily focuses on modernizing the project's dependencies and simplifying its codebase. It updates the minimum required Python version to 3.11 and the default Keras version to 3.13, ensuring the project leverages recent language and framework improvements. A significant simplification involves delegating the ReversibleEmbedding layer's implementation to the upstream Keras library, which reduces custom code and potential for discrepancies. Additionally, specific adjustments were made to address a JAX abstractification error, improving stability and compatibility with the JAX backend.

Highlights

  • Python Version Update: The minimum Python version requirement has been upgraded from 3.10 to 3.11 across the project, affecting documentation, CI workflows, and environment setup instructions.
  • Keras Version Update: The default Keras version used in CI workflows and project dependencies has been updated to 3.13, ensuring compatibility with the latest Keras features and fixes.
  • ReversibleEmbedding Simplification: The custom ReversibleEmbedding layer has been refactored to directly subclass the upstream Keras implementation, simplifying the codebase, reducing maintenance overhead, and removing its local test suite.
  • JAX Abstractification Fix: Changes were made to address a JAX abstractification error, particularly in the CausalLM model's generation function, by explicitly handling sampler variables to improve stability and compatibility with the JAX backend.
  • CI/Build Script Adjustments: Build scripts for GPU environments were updated to set DEBIAN_FRONTEND=noninteractive and temporarily relax Python version requirements to 3.10 for specific GPU tests.

🧠 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.

Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/actions.yml
    • .github/workflows/nightly.yml
    • .github/workflows/publish-to-pypi.yml
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.

Copy link
Contributor

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

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 introduces several important updates and fixes. The upgrade of the minimum Python version to 3.11 and Keras to 3.13 across the project ensures the use of more recent features and bug fixes. The most significant improvement is the refactoring of ReversibleEmbedding to use the upstream implementation from Keras. This greatly simplifies the codebase, reduces maintenance overhead, and aligns perfectly with the repository's style guide on reusability. The core fix for the JAX abstractification error in CausalLM by explicitly using variable.value is also a crucial change for backend compatibility.

I have a couple of minor suggestions for code cleanup in a build script and a Python file, but overall, this is a high-quality contribution that improves the project's health and stability.

Comment on lines 20 to 21
cd "${KOKORO_ROOT}/"

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This cd command is redundant as the directory is already changed to ${KOKORO_ROOT}/ on line 17. You can remove this line and the following blank line for clarity.

sampler_variables = []
for v in self.sampler.variables:
new_sampler_variables = []
for i, v in enumerate(self.sampler.variables):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The loop variable i from enumerate is not used within the loop. It's cleaner to iterate directly over self.sampler.variables.

Suggested change
for i, v in enumerate(self.sampler.variables):
for v in self.sampler.variables:

@pctablet505 pctablet505 removed the request for review from divyashreepathihalli December 23, 2025 04:37
Eliminated a duplicate 'cd' command in the GPU build script. Refactored the sampler variable update loop in causal_lm.py to remove the unused enumerate, improving code clarity.
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.

3 participants