-
Notifications
You must be signed in to change notification settings - Fork 43
bugfix #146
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?
bugfix #146
Conversation
Refactor tree_mask updates for clarity and correctness.
Summary of ChangesHello @sleepy-dev-bin, 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 a bug by refactoring the 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 refactors tree_mask updates for clarity and correctness. While the changes appear to fix an issue with how tree_mask is updated, they also introduce a critical bug that can lead to an out-of-bounds memory access. Additionally, there is a commented-out line of code that should be removed for better maintainability.
| tree_mask[token_tree_indices[bid][tid] + cur_position] = True | ||
| parent_tb_idx = parent_tb_indices[bid][cur_position] |
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.
While the update to tree_mask indexing appears correct, the new logic for parent_tb_idx introduces a critical out-of-bounds access vulnerability.
Here's a breakdown of the issue:
selected_indexandparent_tb_indicesboth have a shape of(bs, draft_token_num - 1), so their last dimension can only be indexed from0todraft_token_num - 2.- The
forloop at line 124 (for _ in range(draft_token_num)) iterates one time too many. It will causecur_positionto reachdraft_token_num - 1, leading to an out-of-bounds access onselected_index[bid][cur_position]at line 125. - Even if that loop was corrected to
range(draft_token_num - 1), after the loopcur_positionwould becomedraft_token_num - 1. In the next iteration of the parentwhileloop, the accessparent_tb_indices[bid][cur_position]at line 119 would still be out of bounds.
The logic for calculating the parent index needs to be fundamentally reconsidered to ensure cur_position remains within valid bounds.
Refactor tree_mask updates for clarity and correctness.