Skip to content

Conversation

@wenyi-guo
Copy link

support all tests in layers to tpu

@wenyi-guo wenyi-guo marked this pull request as draft November 21, 2025 00:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wenyi-guo, 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 significantly enhances the testing infrastructure for Keras layers by enabling comprehensive support for Tensor Processing Units (TPUs). It centralizes TPU strategy management and execution logic into a new utility module, which is then integrated across various layer test suites. This refactoring not only streamlines the process of writing and maintaining TPU tests but also improves the overall reliability and performance validation of Keras layers on specialized hardware accelerators.

Highlights

  • TPU Test Utility: A new utility file, tpu_test_utils.py, has been introduced to centralize the logic for setting up and managing TPU strategies and running functions within those strategies. This promotes code reuse and consistency across TPU-enabled tests.
  • Refactored Test Suites: Numerous test files across keras_rs/src/layers/embedding, keras_rs/src/layers/feature_interaction, and keras_rs/src/layers/retrieval have been updated to leverage the new tpu_test_utils. This includes initializing TPU strategies in setUp methods and using run_with_strategy for executing layer calls.
  • Enhanced Test Assertions: The assertAllClose method in keras_rs/src/testing/test_case.py has been extended with tpu_atol and tpu_rtol parameters, allowing for more flexible and appropriate tolerance settings when comparing values in TPU test environments.
  • Backend-Specific Test Skipping: The ConfigConversionTest in keras_rs/src/layers/embedding/tensorflow/config_conversion_test.py now includes a @pytest.mark.skipif decorator to ensure it only runs when the Keras backend is TensorFlow, preventing irrelevant test failures in other backend configurations.
  • Environment Configuration: The .gitignore file has been updated to include venv_tf/, ensuring that TensorFlow-specific virtual environments are not committed to the repository.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/actions.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.

@wenyi-guo wenyi-guo marked this pull request as ready for review November 21, 2025 00:01
@wenyi-guo wenyi-guo marked this pull request as draft November 21, 2025 00:02
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 is a significant and valuable refactoring to enable TPU support for a wide range of layer tests. The introduction of the tpu_test_utils.py module to centralize TPU strategy creation and execution is a great design choice that improves code maintainability and consistency. The changes are applied systematically across numerous test files. I've identified a couple of issues, including one critical issue in the new utility function that needs to be addressed to ensure tests run correctly on non-TensorFlow backends.

@wenyi-guo wenyi-guo marked this pull request as ready for review November 24, 2025 10:03
@hertschuh hertschuh self-requested a review November 24, 2025 18:40
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.

1 participant