[None][fix] Remove redundant residual bound check in EAGLE3 hidden-state capture#16165
[None][fix] Remove redundant residual bound check in EAGLE3 hidden-state capture#16165eopXD wants to merge 1 commit into
Conversation
…ate capture The residual bound check in Eagle3OneModelSpecMetadata.maybe_capture_hidden_states is unreachable: residual and hidden_states are always produced by the same decoder layer and share their leading (token) dimension, so the preceding num_tokens > hidden_states.shape[0] check already guarantees num_tokens <= residual.shape[0]. Remove the dead branch and leave a note so it is not re-added. Follow-up to review feedback on NVIDIA#15708. Co-Authored-By: Yueh-Ting Chen <yueh.ting.chen@gmail.com> Signed-off-by: Yueh-Ting Chen <yuehtingc@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoved a redundant explicit runtime bounds check on residual.shape[0] within Eagle3OneModelSpecMetadata.maybe_capture_hidden_states, relying instead on the pre-existing hidden_states-based validation, with added comments explaining the assumption before slicing residual[:num_tokens]. ChangesEagle3 hidden states capture bounds check removal
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/bot skip --comment "This is a trvial change that addresses comments from my previous merge request. This should be safe to land." |
|
PR_Github #58392 [ skip ] triggered by Bot. Commit: |
|
PR_Github #58392 [ skip ] completed with state |
Description
Follow-up to review feedback on #15708. During review, @lancelly noted that the
residualbound check inEagle3OneModelSpecMetadata.maybe_capture_hidden_statesis redundant with the precedinghidden_statescheck. This PR removes it.In every caller,
residualandhidden_statesare produced by the same decoder layer and therefore share their leading (token) dimension, so once thenum_tokens > hidden_states.shape[0]check passes,num_tokens <= residual.shape[0]is already guaranteed — the residual branch was unreachable dead code. It is replaced with a short comment explaining why no separate check is needed, so it is not re-added.The two remaining checks are intentionally kept because they guard different tensors:
self.hidden_states.shape[0]) protects the preallocated capture buffer thatinplace_slice_copywrites into (the overrun the original fix addresses);hidden_states.shape[0]) protects the input read.No behavior change.
Test Coverage
No new tests. The existing GPU-gated
test_eagle3_one_model_capture_uses_real_token_countintests/unittest/_torch/speculative/test_eagle3.pyexercises the retained residual path (hidden_states[:4] + residual[:4]); the removed branch was never reachable, so no test regresses. This is a pure dead-code removal on the CUDA-onlymaybe_capture_hidden_states→inplace_slice_copypath, covered by the same CI stages that passed on #15708.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.Summary by CodeRabbit