[https://nvbugs/6535767][fix] Added an anonymous-namespace childTokensPerBlock(NodeBase const&) deriving… - #17145
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe block radix tree derives child block sizes directly from the parent and delays sizing until exact-child lookup. The skipped integration-test waiver entry was removed. ChangesBlock sizing and lookup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/tensorrt_llm/batch_manager/kv_cache_manager_v2/blockRadixTree.cpp (1)
481-495: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winGuard the full-block check for orphan parents.
When
previs an orphanBlock,isFull()callstokensPerBlock()withprev->prev == nullptr. With debug checks enabled, this fails before the exact-child lookup. Skip the check for orphan parents or retain block capacity independently ofprev.🤖 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 `@cpp/tensorrt_llm/batch_manager/kv_cache_manager_v2/blockRadixTree.cpp` around lines 481 - 495, The full-block check in the block-creation path must not call tokensPerBlock() for an orphan prev block whose prev pointer is null. Update the logic around childTokensPerBlock and the exact-child lookup to skip or safely handle that check for orphan parents, while preserving normal capacity validation for attached parents.Source: MCP tools
🤖 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.
Outside diff comments:
In `@cpp/tensorrt_llm/batch_manager/kv_cache_manager_v2/blockRadixTree.cpp`:
- Around line 481-495: The full-block check in the block-creation path must not
call tokensPerBlock() for an orphan prev block whose prev pointer is null.
Update the logic around childTokensPerBlock and the exact-child lookup to skip
or safely handle that check for orphan parents, while preserving normal capacity
validation for attached parents.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ddf6c527-9781-4468-b3d7-9b1fff5d2643
📒 Files selected for processing (2)
cpp/tensorrt_llm/batch_manager/kv_cache_manager_v2/blockRadixTree.cpptests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
b4b953b to
ada89f4
Compare
|
The original bug symptom does not seems to be seg fault. It may actually be a bug I already fixed as part of #14047 |
ada89f4 to
df67eed
Compare
|
The real bug for the segfault is because reset_prefix_cache did not wait until all _KVCache instances are closed. Some are still open and committing more blocks later when the radix tree is gone. I'll fix it in another PR. |
a494725 to
5bc95f7
Compare
…prev->prev addOrGetExistingBlock derived the new block's tokensPerBlock by calling prev->tokensPerBlock(), which reads prev->prev. NodeBase::detachNext sets prev = nullptr when eviction prunes a block that a live KvCache still holds via SharedPtr, so that grandparent hop dereferences null and segfaults in KvCache::_commitBlock. Derive the value from prev directly, mirroring the Python reference (_block_radix_tree.py:390-393), which computes the new block's own tokens_per_block one level up and never touches prev.prev outside an assert. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
5bc95f7 to
c27faae
Compare
Summary
addOrGetExistingBlocksized a new block viaprev->tokensPerBlock(), a grandparent hop that derefsprev->prev— null once eviction detachedprevwhile a liveKvCachestill held it — segfaulting inKvCache::_commitBlock.childTokensPerBlock(NodeBase const&)deriving the value fromprevalone (mirroring Python_block_radix_tree.py:390-393), used it at the call site and inBlock::tokensPerBlock(), and removed the now-passing test's waiver.Test plan
Links
Dev Engineer Review
childTokensPerBlock(NodeBase const&)to derive block size without accessing a detached predecessor.Block::tokensPerBlock()andaddOrGetExistingBlock()to use the helper.TestQwen3NextInstruct::test_nvfp4[tp1_block_reuse-cutlass].reset_prefix_cachesynchronization.QA Engineer Review
tests/integration/test_lists/waives.txt.TestQwen3NextInstruct::test_nvfp4[tp1_block_reuse-cutlass].test-db/orqa/files were modified.Verdict: needs follow-up