Skip to content

[None][feat] Support beam search in KV cache manager v2#14945

Open
yizhang-nv wants to merge 1 commit into
NVIDIA:feat/deepseek_v4from
yizhang-nv:yizhan/kvcm-v2-beam-origin-deepseek-v4
Open

[None][feat] Support beam search in KV cache manager v2#14945
yizhang-nv wants to merge 1 commit into
NVIDIA:feat/deepseek_v4from
yizhang-nv:yizhan/kvcm-v2-beam-origin-deepseek-v4

Conversation

@yizhang-nv
Copy link
Copy Markdown
Member

@coderabbitai summary

Description

Support beam search in KV cache manager v2 for the PyTorch runtime path. Context still starts with beam width 1; generation expands the KV cache to the request beam width. Full context blocks are shared across beams, while the final partial context block is copied into private pages for new beams. Beam-search generation commit remains a runtime responsibility, and V2 only commits full context blocks for reuse.

Test Coverage

  • python3 -m py_compile tensorrt_llm/runtime/kv_cache_manager_v2/_core/_kv_cache.py tensorrt_llm/_torch/pyexecutor/resource_manager.py tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py
  • ruff check --select F401 tensorrt_llm/runtime/kv_cache_manager_v2/_core/_kv_cache.py tensorrt_llm/_torch/pyexecutor/resource_manager.py tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py
  • git diff --check
  • H100 targeted tests before final push: python -m pytest -s -q tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py::TestNoBatching::test_beam_width_expansion_shares_full_context_blocks tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py::TestNoBatching::test_beam_width_expansion_copies_partial_context_tail tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py::TestNoBatching::test_beam_search_generation_commit_is_runtime_responsibility tests/unittest/kv_cache_manager_v2_tests/test_kv_cache_manager_v2.py::TestNoBatching::test_beam_width_expansion_close_uses_stop_committing (4 passed, 2 warnings).
  • Post-commit GPU rerun was not completed because the H100 allocation ended; no active yizhan Slurm jobs were available.

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)

  • 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.

Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
@yizhang-nv yizhang-nv requested a review from a team as a code owner June 4, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants