Skip to content

Conversation

@divyashreepathihalli
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @divyashreepathihalli, 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 addresses an issue encountered when using dot_product_attention with the JAX backend, particularly on TPU devices and within jax.lax.scan operations. It enhances the error handling for flash attention's Splash kernel by specifically catching a JAX concretization error, ensuring a graceful fallback. Additionally, a new test has been introduced to validate the correct functioning of dot_product_attention in this specific TPU/scan context, preventing regressions.

Highlights

  • Improved Error Handling: The dot_product_attention function in the JAX backend now explicitly catches jax.errors.ConcretizationTypeError when the Splash kernel fails, ensuring a more specific and graceful fallback to native JAX attention.
  • New TPU Test Case: A new test, test_dot_product_attention_inside_scan, has been added to verify the correct behavior of dot_product_attention when used within jax.lax.scan on TPU devices, specifically with a mask to trigger potential issues.
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 fixes an issue with Splash attention on TPUs when used within a jax.lax.scan by catching jax.errors.ConcretizationTypeError and falling back to the native JAX implementation. A new test case is added to verify this fix. The changes are sound, but I have one suggestion to improve the exception handling in the new test case.

Comment on lines +1335 to +1336
except:
self.skipTest("TPU-specific test")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using a bare except: clause is generally discouraged as it can catch unexpected errors like SystemExit or KeyboardInterrupt, making it harder to debug issues. It's better to be more specific and catch Exception instead.

Suggested change
except:
self.skipTest("TPU-specific test")
except Exception:
self.skipTest("TPU-specific test")

@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.26%. Comparing base (7631c1a) to head (575b01e).

Files with missing lines Patch % Lines
keras/src/backend/jax/nn.py 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21891      +/-   ##
==========================================
- Coverage   76.27%   76.26%   -0.01%     
==========================================
  Files         579      579              
  Lines       59917    59923       +6     
  Branches     9403     9406       +3     
==========================================
  Hits        45703    45703              
- Misses      11748    11754       +6     
  Partials     2466     2466              
Flag Coverage Δ
keras 76.13% <0.00%> (-0.01%) ⬇️
keras-jax 62.70% <0.00%> (-0.01%) ⬇️
keras-numpy 57.36% <0.00%> (-0.01%) ⬇️
keras-openvino 34.28% <0.00%> (-0.01%) ⬇️
keras-torch 63.28% <0.00%> (-0.01%) ⬇️

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.

hertschuh
hertschuh previously approved these changes Dec 3, 2025
@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Dec 3, 2025
@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Dec 3, 2025
@hertschuh hertschuh dismissed their stale review December 4, 2025 00:42

Dismiss review to re-trigger TPU tests

@google-ml-butler google-ml-butler bot added the ready to pull Ready to be merged into the codebase label Dec 4, 2025
@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Dec 4, 2025
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.

6 participants