[TRTLLM-11875][feat] MambaCacheManager based on KVCacheManagerV2 & add multi-turn chat optimized reuse#15653
[TRTLLM-11875][feat] MambaCacheManager based on KVCacheManagerV2 & add multi-turn chat optimized reuse#15653VALLIS-NERIA wants to merge 5 commits into
Conversation
|
/bot help |
GitHub Bot Help
Provide a user friendly way for developers to interact with a Jenkins server. Run See details below for each supported subcommand. Details
Launch build/test pipelines. All previously running jobs will be killed.
kill
Kill all running builds associated with pull request. skip
Skip testing for latest commit on pull request. reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break. |
|
/bot --help |
GitHub Bot Help
Provide a user friendly way for developers to interact with a Jenkins server. Run See details below for each supported subcommand. Details
Launch build/test pipelines. All previously running jobs will be killed.
kill
Kill all running builds associated with pull request. skip
Skip testing for latest commit on pull request. reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break. |
|
/bot run --gpu-type B200 |
|
PR_Github #56312 [ run ] triggered by Bot. Commit: |
|
PR_Github #56312 [ 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>
9340fe0 to
81a22bc
Compare
|
/bot run --gpu-type B200 --disable-fail-fast |
|
PR_Github #58647 [ run ] triggered by Bot. Commit: |
|
PR_Github #58647 [ run ] completed with state |
VALLIS-NERIA
left a comment
There was a problem hiding this comment.
The V2 Mamba path contains replay-state corruption and a deterministic state-index buffer crash, while several supported configurations either lose reuse behavior or fail during startup. These issues prevent the patch from being considered correct despite the focused unit tests passing.
One additional finding applies to unpushed local commit 032279800f and therefore cannot yet be anchored to the current GitHub diff:
[P2] Restore the GPU-only fallback after host-cache setup failure — tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py:891
When a host cache tier is configured and host allocation or cuMemHostRegister fails because of memory or memlock limits, KVCacheManagerPy still raises CuError/OutOfMemoryError. The removed handling retried with GPU-only tiers, whereas this direct construction now aborts model startup. Retain the fallback for configurations where the optional host tier cannot be initialized.
|
/bot run |
|
PR_Github #58894 [ run ] triggered by Bot. Commit: |
|
PR_Github #58894 [ run ] completed with state
|
Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
Summary
This PR adds V2 Mamba SSM state snapshot reuse support, including saving partial tail snapshots and reusing them for longer prompts with the same prefix.
Key changes:
KvCacheConfig.mamba_save_last_snapshotand propagate it through runtime and compatibility config surfaces.expect_chunking_pointsand fail fast if they are missing.Root Cause
V2 scheduling did not honor Mamba snapshot chunk boundaries, so live SSM state could be committed at the wrong semantic position. The integration test also warmed all base prompts before running all full prompts, which could evict reusable entries before they were checked.
Validation
python -m py_compile tensorrt_llm/_torch/pyexecutor/scheduler/scheduler_v2.py tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py tests/unittest/_torch/executor/test_kv_cache_v2_scheduler.py tests/unittest/_torch/executor/test_mamba_cache_manager.py tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py tests/integration/defs/accuracy/accuracy_core.py tests/integration/defs/accuracy/test_llm_api_pytorch.pypytest -q tests/unittest/_torch/executor/test_kv_cache_v2_scheduler.py::TestChunkedContext::test_force_chunk_uses_expected_chunking_points tests/unittest/_torch/executor/test_kv_cache_v2_scheduler.py::TestChunkedContext::test_force_chunk_requires_expected_chunking_points tests/unittest/_torch/executor/test_kv_cache_v2_scheduler.py::TestChunkedContext::test_force_chunk_uses_next_expected_chunking_point tests/unittest/_torch/executor/test_kv_cache_v2_scheduler.py::TestChunkedContext::test_force_chunk_allows_prompt_end_shorter_than_unit_size tests/unittest/_torch/executor/test_mamba_cache_manager.py::test_v2_hybrid_prepare_expect_chunking_points tests/unittest/_torch/executor/test_mamba_cache_manager.py::test_v2_hybrid_prepare_expect_chunking_points_save_last_only tests/unittest/_torch/executor/test_mamba_cache_manager.py::test_v2_hybrid_prepare_expect_chunking_points_clears_when_reuse_disabled tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py::TestSSMSupport::test_ssm_interval_snapshot_reuses_longer_prompt_prefixpytest -q -s tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestQwen3_5_4B::test_fp8_block_reuse_interval_repeat_shufflepytest -q -s tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestNemotronV3Super::test_nvfp4_4gpus_block_reuse[TEP4_ADP_MTP]