Skip to content

[None][chore] Dead code elimination, we no longer record/fetch through WindowBlockManager:: mContextBlocksByHash #6249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2025

Conversation

eopXD
Copy link
Collaborator

@eopXD eopXD commented Jul 22, 2025

Description

WindowBlockManager::mCachedBlocksRoot is now who is responsible for the bookkeeping of the KVCacheBlock, and the mNextBlocks is now the actual hash map that fetches the block.

The mEnableHashKey knob and related hashing is removed.

No functional change is intended in this MR.

Summary by CodeRabbit

  • Refactor
    • Removed hash-based block lookup and management functionality from cache components, streamlining block handling.
    • Updated cache manager initialization to use dynamic configuration for partial reuse settings.
  • Tests
    • Removed unit tests related to hash key and block reuse features in cache management.

Test Coverage

The following existing test coverages under kvCacheManagerTest.cpp are removed because we are no longer using the utility.

KVCacheManagerHashKeyTest
KVCacheManagerHashKeyWithReuseTest

Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

📝 Walkthrough

Walkthrough

All code and tests related to hash-based block lookup and management have been removed from the KV cache manager. This includes the deletion of hash map member variables, associated methods for adding/removing blocks by hash, and all related test cases and utilities. Additionally, a constructor argument for block reuse configuration was updated to use the actual config value instead of a hardcoded false. No other logic or control flow was changed.

Changes

File(s) Change Summary
Header cleanup
cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h
Removed all hash-based block lookup methods, variables, and related interface declarations.
Implementation cleanup
cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp
Deleted all hash map management logic and all calls to hash-based block add/remove methods; updated constructor calls to remove enableHashKey parameter.
Test removal
cpp/tests/unit_tests/batch_manager/kvCacheManagerTest.cpp
Removed all tests and helpers related to hash key and block reuse functionality.
Constructor argument update
cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp
Changed hardcoded false argument in KVCacheManager constructor call to use kvCacheConfig.getEnablePartialReuse().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • zhengd-nv
  • Funatiq

Poem

A hash map once lived in our code,
For blocks it would swiftly decode.
But now it is gone,
Its duties withdrawn,
Our cache takes a simpler new road.

🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e56ce75 and db957fc.

📒 Files selected for processing (4)
  • cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h (4 hunks)
  • cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp (7 hunks)
  • cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp (1 hunks)
  • cpp/tests/unit_tests/batch_manager/kvCacheManagerTest.cpp (0 hunks)
💤 Files with no reviewable changes (1)
  • cpp/tests/unit_tests/batch_manager/kvCacheManagerTest.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
  • cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h
  • cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp
  • cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@eopXD
Copy link
Collaborator Author

eopXD commented Jul 22, 2025

@thorjohnsen I was introduced by @symphonylyh that you are the one to consult and add as a reviewer.

Tracing through the code, this structure looks dead to me, we should stop maintaining this utility (adding addBlockToHashMap/removeBlockFromHashMap) to reduce complexity of the code base.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Jul 22, 2025
@symphonylyh symphonylyh added Generic Runtime General operational aspects of TRTLLM execution not in other categories. and removed Community want to contribute PRs initiated from Community labels Jul 22, 2025
@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Jul 22, 2025
@thorjohnsen
Copy link
Collaborator

Please sign off your commit, we won't be able to merge without.

Copy link
Collaborator

@thorjohnsen thorjohnsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WindowBlockManager::mCachedBlocksRoot is now who is responsible
for the bookkeeping of the KVCacheBlock, and the mNextBlocks is now
the actual hash map that fetches the block.

Has this change been merged into main already?

@eopXD
Copy link
Collaborator Author

eopXD commented Jul 28, 2025

WindowBlockManager::mCachedBlocksRoot is now who is responsible
for the bookkeeping of the KVCacheBlock, and the mNextBlocks is now
the actual hash map that fetches the block.

Has this change been merged into main already?

Yes, it is already merged into main.

https://github.com/NVIDIA/TensorRT-LLM/blob/main/cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp#L1037
https://github.com/NVIDIA/TensorRT-LLM/blob/main/cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp#L1072

@eopXD
Copy link
Collaborator Author

eopXD commented Jul 28, 2025

Please sign off your commit, we won't be able to merge without.

Updated commit. Thank you for the reminder.

@Funatiq
Copy link
Collaborator

Funatiq commented Jul 29, 2025

TBH I never really understood why we need this hashmap, it was introduced in MR 7247 as a preliminary for TRTLLM-1619 as a part of disaggregated serving. @zhengd-nv could you comment please?

@Funatiq Funatiq requested a review from zhengd-nv July 29, 2025 13:50
@zhengd-nv
Copy link
Collaborator

zhengd-nv commented Jul 30, 2025

This is a preliminary step of transmitting arbitrary kv cache blocks between workers and the hash id is used to identify which blocks to transfer. The feature is delayed due to pytorch integration. @Tabrizian is now working on the design and could you comment if such lookup table is still required.

@zhengd-nv zhengd-nv requested a review from Tabrizian July 30, 2025 01:42
@eopXD
Copy link
Collaborator Author

eopXD commented Jul 30, 2025

This is a preliminary step of transmitting arbitrary kv cache blocks between workers and the hash id is used to identify which blocks to transfer. The feature is delayed due to pytorch integration. @Tabrizian is now working on the design and could you comment if such lookup table is still required.

Why is code added with no real responsibility, and not along the feature to introduce it?
@Tabrizian Please share design doc and roadmap on this.

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 5, 2025

@Tabrizian @thorjohnsen A gentle ping, can we merge this?

@Tabrizian
Copy link
Member

I think it is ok to remove it for now. We can add it back once the feature is completed.

@eopXD eopXD changed the title [KV Cache Manager] Dead code elimination, we no longer record/fetch through WindowBlockManager:: mContextBlocksByHash [None][chore][kv cache manager] Dead code elimination, we no longer record/fetch through WindowBlockManager:: mContextBlocksByHash Aug 6, 2025
@eopXD eopXD changed the title [None][chore][kv cache manager] Dead code elimination, we no longer record/fetch through WindowBlockManager:: mContextBlocksByHash [None][chore] Dead code elimination, we no longer record/fetch through WindowBlockManager:: mContextBlocksByHash Aug 6, 2025
@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14427 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14427 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #10906 completed with status: 'FAILURE'

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@eopXD eopXD enabled auto-merge (squash) August 7, 2025 09:18
@tensorrt-cicd
Copy link
Collaborator

PR_Github #14437 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14437 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #10912 completed with status: 'FAILURE'

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@eopXD eopXD disabled auto-merge August 7, 2025 10:13
@tensorrt-cicd
Copy link
Collaborator

PR_Github #14455 [ run ] triggered by Bot

@eopXD eopXD enabled auto-merge (squash) August 7, 2025 10:14
@tensorrt-cicd
Copy link
Collaborator

PR_Github #14455 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #10923 completed with status: 'FAILURE'

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14460 [ run ] triggered by Bot

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14464 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14460 [ run ] completed with state ABORTED

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14464 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10929 completed with status: 'FAILURE'

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 7, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14481 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14481 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10939 completed with status: 'FAILURE'

@eopXD
Copy link
Collaborator Author

eopXD commented Aug 8, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14574 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14574 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #11010 completed with status: 'FAILURE'

…he blocks with hashmap

WindowBlockManager::mCachedBlocksRoot is responsible for the bookkeeping of the
KVCacheBlock, and the mNextBlocks is now the actual hash map that fetches
the block.

Signed-off-by: eopXD <[email protected]>
@eopXD
Copy link
Collaborator Author

eopXD commented Aug 10, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14700 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14700 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #11096 completed with status: 'SUCCESS'

@eopXD eopXD merged commit 199f306 into NVIDIA:main Aug 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community want to contribute PRs initiated from Community Generic Runtime General operational aspects of TRTLLM execution not in other categories.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants