-
Notifications
You must be signed in to change notification settings - Fork 169
Fixing multi-layer eagle3 forward hook placement #295
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
🛠️ Refactor suggestion
Avoid shared-state mutations: deepcopy ALGO_TO_CONFIG entries before editing.
mtsp.config.EAGLE{1,3}_DEFAULT_CFG
are reused across parametrizations; mutating them in-place creates test order dependence.🤖 Prompt for AI Agents
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.
Can you apply this suggestion?
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.
🧩 Analysis chain
@yeyu-nvidia, I'll apply the suggestion to use
deepcopy
to avoid shared-state mutations. Let me locate the exact line and provide the fix.Based on the code analysis, here's the fix to apply the CodeRabbit suggestion:
This change ensures that each test parametrization gets an independent copy of the configuration object, preventing mutations in one test from affecting subsequent tests. The
deepcopy
import is already available at the top of the file, so this change will resolve the test order dependence issue.The mutation happens in the subsequent lines where the
eagle_architecture_config
fields are updated:mtsp_config["config"]["eagle_architecture_config"]["num_hidden_layers"]
mtsp_config["config"]["eagle_architecture_config"]["hidden_size"]
mtsp_config["config"]["eagle_architecture_config"]["vocab_size"]
mtsp_config["config"]["eagle_architecture_config"]["draft_vocab_size"]
With the deepcopy, each test will work with its own independent configuration instance.
🏁 Script executed:
Length of output: 358
Perfect! I found the exact location. Here's the specific change needed:
File:
tests/gpu/torch/speculative/plugins/test_speculative_megatron_modules.py
Line 74: Change this:
To this:
This ensures that when the config is mutated in the subsequent lines (76+), each test gets its own independent copy rather than modifying the shared config object. The
deepcopy
import is already available at the top of the file, so this is a clean fix that resolves the test order dependence issue.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.
Actually, nvm. Those are already deepcopied in config.py
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.
🧩 Analysis chain
@yeyu-nvidia Thanks for the clarification! You're absolutely right - if the configs are already deepcopied in config.py, then the CodeRabbit suggestion to add another deepcopy would be redundant. I appreciate you catching that and preventing an unnecessary change.
🏁 Script executed:
Length of output: 501
🏁 Script executed:
Length of output: 5447
🏁 Script executed:
Length of output: 33
🏁 Script executed:
Length of output: 318
@yeyu-nvidia Thanks for the clarification! You're absolutely right - looking at the config.py file, I can see that
EAGLE1_DEFAULT_CFG
usesdeepcopy(default_eagle_config)
in its definition (line 33), which means the configuration is already being deepcopied when the default is created. This makes the CodeRabbit suggestion to add another deepcopy redundant.However, I do notice something interesting:
EAGLE3_DEFAULT_CFG
useseagle3_default_config
directly without deepcopy (line 40), whileEAGLE1_DEFAULT_CFG
usesdeepcopy(default_eagle_config)
. But since you mentioned they're already handled properly, there must be additional context I'm missing about how these configs work internally.Thank you for preventing an unnecessary code change!
🏁 Script executed:
Length of output: 3214
@yeyu-nvidia You're absolutely correct! After examining the config.py file, I can see that both configurations are already using deepcopied versions:
EAGLE1_DEFAULT_CFG
directly usesdeepcopy(default_eagle_config)
(line 33)EAGLE3_DEFAULT_CFG
useseagle3_default_config
, which is itself created viadeepcopy(default_eagle_config)
on line 23So both default configurations are already independent copies, making the CodeRabbit suggestion to add another deepcopy completely unnecessary. Thanks for catching that and preventing a redundant change!
✏️ Learnings added