[https://nvbugs/6394425][fix] Added _is_effective_dynamic_tree() helper in utils.py that returns True only…#15842
Conversation
When dynamic_tree_max_topK=1 the dynamic tree degenerates into a linear chain and should be equivalent to the linear Eagle3 one-model path, but the dynamic-tree worker's step-0 mask, KV rewind and tree bookkeeping produce a materially lower acceptance length than the linear worker. Add _is_effective_dynamic_tree() in _torch/speculative/utils.py that gates on both use_dynamic_tree and dynamic_tree_max_topK >= 2, and use it consistently in get_spec_metadata, get_spec_resource_manager and get_spec_worker so K=1 configs pick the linear metadata, resource manager and worker. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds a helper function ChangesEffective dynamic-tree helper and usage
Estimated code review effort: 2 (Simple) | ~10 minutes Related PRs: None identified. Suggested labels: speculative-decoding, bug-fix Suggested reviewers: None identified. 🐰 a tiny rabbit hops through logic gates, checking topK before it consents to grow its dynamic tree of thought. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tensorrt_llm/_torch/speculative/utils.py (1)
35-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a small unit test for the topK=1 regression.
No test changes are included with this fix. Given this addresses a specific acceptance-length regression bug, a focused unit test asserting
_is_effective_dynamic_treereturnsFalsefordynamic_tree_max_topK=1(and thatget_spec_worker/get_spec_resource_managerroute to the linear path) would guard against future regressions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tensorrt_llm/_torch/speculative/utils.py` around lines 35 - 41, The fix in _is_effective_dynamic_tree should be covered with a focused regression test for the topK=1 case. Add a unit test that verifies _is_effective_dynamic_tree returns False when use_dynamic_tree is enabled but dynamic_tree_max_topK is 1, and add a routing test around get_spec_worker and get_spec_resource_manager to confirm they take the linear Eagle3 one-model path instead of the dynamic tree path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tensorrt_llm/_torch/speculative/utils.py`:
- Around line 35-41: The fix in _is_effective_dynamic_tree should be covered
with a focused regression test for the topK=1 case. Add a unit test that
verifies _is_effective_dynamic_tree returns False when use_dynamic_tree is
enabled but dynamic_tree_max_topK is 1, and add a routing test around
get_spec_worker and get_spec_resource_manager to confirm they take the linear
Eagle3 one-model path instead of the dynamic tree path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d94603a5-b6ac-46f3-afd9-499b6e1033e7
📒 Files selected for processing (1)
tensorrt_llm/_torch/speculative/utils.py
|
/bot run --disable-fail-fast |
|
PR_Github #57077 [ run ] triggered by Bot. Commit: |
|
PR_Github #57077 [ run ] completed with state
|
|
/bot run |
|
PR_Github #57285 [ run ] triggered by Bot. Commit: |
|
PR_Github #57285 [ run ] completed with state
|
|
/bot run |
|
PR_Github #57305 [ run ] triggered by Bot. Commit: |
|
PR_Github #57305 [ run ] completed with state
|
|
/bot run |
|
PR_Github #57446 [ run ] triggered by Bot. Commit: |
|
PR_Github #57446 [ run ] completed with state |
… (fork PR #1) Supersedes the previous PR NVIDIA#15653 squash with the updated v2kv_mamba branch from #1: - V2 Mamba state snapshot reuse (updated after upstream review) - Fix KV cache v2 test request mocks - Fix V2 page table roles for Mamba pools - Support V2 Mamba hybrid cache in disagg Also carries the upstream main commits pulled in by the v2kv_mamba merge: DSv4 follow-up runtime KV and cache foundations (NVIDIA#15633), DeepGEMM and MegaMoE (NVIDIA#15632), and _is_effective_dynamic_tree fix (NVIDIA#15842). Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
… (fork PR #1) Supersedes the previous PR NVIDIA#15653 squash with the updated v2kv_mamba branch from nv-guomingz#1: - V2 Mamba state snapshot reuse (updated after upstream review) - Fix KV cache v2 test request mocks - Fix V2 page table roles for Mamba pools - Support V2 Mamba hybrid cache in disagg Also carries the upstream main commits pulled in by the v2kv_mamba merge: DSv4 follow-up runtime KV and cache foundations (NVIDIA#15633), DeepGEMM and MegaMoE (NVIDIA#15632), and _is_effective_dynamic_tree fix (NVIDIA#15842). Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
…er in utils.py that returns True only… (NVIDIA#15842) Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Summary
Test plan
Links
Summary by CodeRabbit