Skip to content

feat: include model name in KVBlock key hash#220

Merged
github-actions[bot] merged 4 commits into
llm-d:mainfrom
sagearc:add-request-model-name-to-kvblock-key-hash
Dec 18, 2025
Merged

feat: include model name in KVBlock key hash#220
github-actions[bot] merged 4 commits into
llm-d:mainfrom
sagearc:add-request-model-name-to-kvblock-key-hash

Conversation

@sagearc
Copy link
Copy Markdown
Collaborator

@sagearc sagearc commented Dec 17, 2025

Closes #189

Since the hashing algorithm is now decoupled from vllm (#195), the simplest solution is to always include the model/lora name from the request in the hash, along with the token ids.

Specifically, in this PR this is applied only to the first block key hash.

Notes:
Changed chunkedTokenDatabase to private, as it already implements TokenProcessor and is not used directly anywhere. This is mainly to ensure that the initial hash cannot be overridden by mistake.

Copilot AI review requested due to automatic review settings December 17, 2025 16:05
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to include the model name in the KVBlock key hash to address issue #189. The change ensures that different models or LoRA adapters generate distinct hash keys, preventing cache collisions. The implementation applies the model name specifically to the first block key hash initialization.

Key Changes

  • Changed ChunkedTokenDatabase struct from exported to unexported (chunkedTokenDatabase)
  • Moved initial hash computation from lazy initialization to constructor
  • Modified getInitHash to accept modelName parameter and include it in hash computation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/kvcache/kvblock/token_processor.go
Comment thread pkg/kvcache/kvblock/token_processor.go
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
@sagearc
Copy link
Copy Markdown
Collaborator Author

sagearc commented Dec 17, 2025

@vMaroon Can you take a look?

@vMaroon
Copy link
Copy Markdown
Member

vMaroon commented Dec 18, 2025

Great, thanks @sagiahrac

/lgtm
/approve

@github-actions github-actions Bot added the lgtm Looks good to me, indicates that a PR is ready to be merged. label Dec 18, 2025
@github-actions github-actions Bot merged commit 3ae0faf into llm-d:main Dec 18, 2025
2 checks passed
@sagearc sagearc deleted the add-request-model-name-to-kvblock-key-hash branch December 18, 2025 17:18
@sagearc
Copy link
Copy Markdown
Collaborator Author

sagearc commented Jan 6, 2026

closes #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Looks good to me, indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KV-Cache Hashing Incompatibility with LoRA

3 participants