[None][feat] Python transceiver support cpp cache manager + offload - #15245
Conversation
ef8045d to
04a8bfd
Compare
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughThis PR introduces a block-index translation API for disaggregated KV cache management with host offload. The feature adds C++ and Python APIs to translate logical cache block IDs to memory-pool slot indices, integrates this into the cache reuse adapter, and validates correctness through unit and end-to-end tests. ChangesBlock Index Translation and Cache Reuse for Host Offload
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/unittest/disaggregated/test_extractor.py (1)
646-646: 💤 Low valueAdd
strict=Truetozip()calls for defensive validation.Both lists should be equal length by construction, but adding
strict=Truewould catch unexpected mismatches during test execution rather than silently iterating over partial data.Suggested fix
Line 646:
- primary_diverged = [(b, s) for b, s in zip(block_ids_b, slots_b) if b != s] + primary_diverged = [(b, s) for b, s in zip(block_ids_b, slots_b, strict=True) if b != s]Line 723:
- for ptr, idx in zip(spec_region.memory.ptrs, translated_a2): + for ptr, idx in zip(spec_region.memory.ptrs, translated_a2, strict=True):Also applies to: 723-723
🤖 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 `@tests/unittest/disaggregated/test_extractor.py` at line 646, The zip() calls used to pair lists like block_ids_b and slots_b (e.g. where primary_diverged is computed) should be made strict to catch length mismatches; update the zip(...) invocations in test_extractor.py (including the one that produces primary_diverged and the other zip usage around the later comparison) to zip(..., strict=True) so the test will raise on unexpected list-length differences rather than silently truncating.Source: Linters/SAST 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.
Inline comments:
In `@cpp/tensorrt_llm/nanobind/batch_manager/kvCacheManager.cpp`:
- Around line 633-635: The trampoline for BaseKVCacheManager is missing a
pure-virtual override for getMemoryPoolBlockIndicesByBlockIds so Python
subclasses cannot implement it; update PyKvCacheManager to either increase the
NB_TRAMPOLINE(...) count to include the 61st pure virtual or add an explicit
NB_OVERRIDE_PURE forwarding for getMemoryPoolBlockIndicesByBlockIds (matching
the C++ signature used by the binding) and ensure the binding
.def("get_memory_pool_block_indices",
&BaseKVCacheManager::getMemoryPoolBlockIndicesByBlockIds, ...) will dispatch to
the Python override.
In `@tensorrt_llm/_torch/pyexecutor/resource_manager.py`:
- Around line 1542-1544: The check that raises "window_size must be provided for
VSWA" should be guarded by the VSWA predicate rather than by the vector length;
update the conditional to use self.is_vswa (e.g., if self.is_vswa and
len(self.max_attention_window_vec) > 1: raise ValueError(...)) so non-VSWA
configs with multiple identical entries don't trigger the error, and keep
assigning window_size = self.max_attention_window_vec[0] afterward.
---
Nitpick comments:
In `@tests/unittest/disaggregated/test_extractor.py`:
- Line 646: The zip() calls used to pair lists like block_ids_b and slots_b
(e.g. where primary_diverged is computed) should be made strict to catch length
mismatches; update the zip(...) invocations in test_extractor.py (including the
one that produces primary_diverged and the other zip usage around the later
comparison) to zip(..., strict=True) so the test will raise on unexpected
list-length differences rather than silently truncating.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f7de916e-43a4-4125-a371-3901319a2c21
📒 Files selected for processing (9)
cpp/include/tensorrt_llm/batch_manager/kvCacheManager.hcpp/tensorrt_llm/batch_manager/kvCacheManager.cppcpp/tensorrt_llm/nanobind/batch_manager/kvCacheManager.cpptensorrt_llm/_torch/disaggregation/resource/cache_reuse.pytensorrt_llm/_torch/pyexecutor/resource_manager.pytests/integration/defs/disaggregated/test_configs/disagg_config_python_transceiver_host_offload.yamltests/integration/defs/disaggregated/test_disaggregated.pytests/integration/test_lists/test-db/l0_dgx_h100.ymltests/unittest/disaggregated/test_extractor.py
|
PR_Github #53493 [ run ] triggered by Bot. Commit: |
|
PR_Github #53493 [ run ] completed with state
|
04a8bfd to
f61f4ed
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #53761 [ run ] triggered by Bot. Commit: |
|
PR_Github #53761 [ run ] completed with state
|
f61f4ed to
531d745
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #54219 [ run ] triggered by Bot. Commit: |
|
PR_Github #54219 [ run ] completed with state
|
531d745 to
0f9c0c0
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #54414 [ run ] triggered by Bot. Commit: |
|
PR_Github #54414 [ run ] completed with state
|
b944e59 to
576f287
Compare
|
/bot run --disable-fail-fast |
|
/bot skip --comment "all tests have passed" |
|
PR_Github #59414 [ skip ] triggered by Bot. Commit: |
|
PR_Github #59414 [ skip ] completed with state |
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
…tion Commit f84b6da (NVIDIA#15245) made _CacheReuseAdapterV1.get_block_ids translate block ids through get_memory_pool_block_indices with the layer group's window size, but test_v1_adapter_uses_request_py_beam_width kept a windowless fake layer group and a fake manager without the translation hook, tripping the window_size assertion. The gap went unnoticed because test_cache_reuse_adapter.py is not registered in any CI test list. Give the fake layer group a window, add an identity get_memory_pool_block_indices to the fake manager, and assert the adapter passes the layer group's window through to the translation. Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Summary by CodeRabbit
New Features
Tests
Description
Test Coverage
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.