-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Fix ConcretizationTypeError in dot_product_attention with traced masks #21853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix ConcretizationTypeError in dot_product_attention with traced masks #21853
Conversation
Add check for traced masks to disable flash attention.
Summary of ChangesHello @Abhinavexists, 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 resolves a specific Highlights
Using Gemini Code AssistThe 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
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 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
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21853 +/- ##
=======================================
Coverage 82.47% 82.47%
=======================================
Files 577 577
Lines 59508 59510 +2
Branches 9332 9333 +1
=======================================
+ Hits 49080 49082 +2
Misses 8015 8015
Partials 2413 2413
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 a ConcretizationTypeError that occurs when using dot_product_attention with a traced mask on TPUs. The fix involves adding a check to detect if the mask is a JAX tracer and, if so, disabling flash attention. This is a good and direct solution to the problem. I've suggested a small improvement to scope this check specifically to the TPU platform, aligning it more closely with the reported issue and preventing any potential unintended side effects on other platforms like GPU.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this 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 addresses a ConcretizationTypeError that occurs when using dot_product_attention with a traced mask on TPUs, which typically happens within JAX control flow constructs like scan or while_loop. The fix involves detecting if the attention mask is a JAX Tracer and disabling flash attention in that case to fall back to a compatible implementation. My review focuses on making this fix more precise to avoid potential performance regressions on other hardware platforms. I've suggested restricting the check to only apply on TPUs, aligning it more closely with the described issue.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Fix: #21808
using
dot_product_attentionwith a mask inside JAX control flow operations (e.g.,while_loop,scan) on TPU, the code raised aConcretizationTypeErrorAdded a traced mask detection check before attempting to use TPU flash attention