-
Notifications
You must be signed in to change notification settings - Fork 90
fix: remove attention mask shift & add pe shift #244
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: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Liyuhui-12, 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 refines the EAGLE-3 implementation by correcting how attention masks and position encodings are handled. It removes an erroneous and unnecessary attention mask shift while introducing a crucial, previously missing, position encoding shift. These adjustments aim to improve the correctness and alignment of the model's internal computations. 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
|
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 correctly refactors the Test-Time Training (TTT) loop logic by replacing a manual attention mask shift with a more appropriate position ID increment. This change simplifies the code and fixes an issue where position encodings were not being shifted correctly. The code is now cleaner and more aligned with standard transformer practices. I've added one comment regarding the need to update unit tests to reflect this logic change.
specforge/core/eagle3.py
Outdated
attention_mask[:, :, ind0, ind1] = torch.finfo( | ||
attention_mask.dtype | ||
).min | ||
position_ids += 1 |
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.
This change to use position_ids += 1
is a great improvement for handling the position encoding shift during the TTT loop. It's cleaner and more correct than manipulating the attention mask directly.
However, this logic change should be reflected in the unit tests. I noticed that tests/test_utils/test_flex_attention.py
seems to simulate the TTT loop with the old logic of shifting the attention mask. To ensure the correctness of this fix and prevent future regressions, could you please update the relevant unit tests to use position_ids
incrementing instead?
Motivation
The implementation of EAGLE-3 uses an unnecessary attention mask shift and is missing the position encoding shift.
Modifications
Remove attention mask shift & Add pe shift
Related Issues
Accuracy Test
Benchmark & Profiling
Checklist