[GH-ISSUE #644] [Usage]: MooncakeStore #209

Closed
opened 2026-10-29 21:10:55 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @longyuetang on GitHub (Jul 19, 2025).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/644

Describe your usage question

In MooncakeStore, the hash value of the input tokens is truncated and used as the key. What if a hash collision occurs? Wouldn't that corrupt the KV cache data?

Before submitting a new issue...

  • Make sure you already searched for relevant issues and read the documentation
Originally created by @longyuetang on GitHub (Jul 19, 2025). Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/644 ### Describe your usage question In MooncakeStore, the hash value of the input tokens is truncated and used as the key. What if a hash collision occurs? Wouldn't that corrupt the KV cache data? ### Before submitting a new issue... - [ ] Make sure you already searched for relevant issues and read the [documentation](https://kvcache-ai.github.io/Mooncake/)
Author
Owner

@ykwd commented on GitHub (Jul 20, 2025):

As far as I know, the prefix hash of the input tokens, which is used as the key for KV-cache indexing, is not truncated. Could you clarify where exactly the truncation is happening?

<!-- gh-comment-id:3093185635 --> @ykwd commented on GitHub (Jul 20, 2025): As far as I know, the prefix hash of the input tokens, which is used as the key for KV-cache indexing, is not truncated. Could you clarify where exactly the truncation is happening?
Author
Owner

@longyuetang commented on GitHub (Jul 20, 2025):

As far as I know, the prefix hash of the input tokens, which is used as the key for KV-cache indexing, is not truncated. Could you clarify where exactly the truncation is happening?

Image Image
<!-- gh-comment-id:3094433440 --> @longyuetang commented on GitHub (Jul 20, 2025): > As far as I know, the prefix hash of the input tokens, which is used as the key for KV-cache indexing, is not truncated. Could you clarify where exactly the truncation is happening? <img width="780" height="573" alt="Image" src="https://github.com/user-attachments/assets/ea9b978b-f9f3-4414-99d4-51521c3d68cf" /> <img width="731" height="156" alt="Image" src="https://github.com/user-attachments/assets/e10a885a-6c0b-4c9c-9362-3f6435480e8d" />
Author
Owner

@ykwd commented on GitHub (Jul 21, 2025):

@ShangmingCai Could you take a look? Thanks.

<!-- gh-comment-id:3095066653 --> @ykwd commented on GitHub (Jul 21, 2025): @ShangmingCai Could you take a look? Thanks.
Author
Owner

@ShangmingCai commented on GitHub (Jul 21, 2025):

@jialei-jialei Yeah, this is possible, all hash method has this issue, but the chance is very tiny. Just like the block hash in vllm page attention. BTW, if current_tokens of different requests are identical, it means their prompts are identical, that's when we reuse kvcache. You'd better check what input_tokens_tensor really means.

<!-- gh-comment-id:3095114202 --> @ShangmingCai commented on GitHub (Jul 21, 2025): @jialei-jialei Yeah, this is possible, all hash method has this issue, but the chance is very tiny. Just like the block hash in vllm page attention. BTW, if `current_tokens` of different requests are identical, it means their prompts are identical, that's when we reuse kvcache. You'd better check what `input_tokens_tensor` really means.
Author
Owner

@longyuetang commented on GitHub (Jul 23, 2025):

@jialei-jialei Yeah, this is possible, all hash method has this issue, but the chance is very tiny. Just like the block hash in vllm page attention. BTW, if current_tokens of different requests are identical, it means their prompts are identical, that's when we reuse kvcache. You'd better check what input_tokens_tensor really means.

My point is, if different current_tokens end up with identical hash values, MoonStore would retrieve the wrong data. This is what I'm questioning. I’d like to understand—even if the probability is extremely low, would such a case still be negligible in practice?

<!-- gh-comment-id:3105407867 --> @longyuetang commented on GitHub (Jul 23, 2025): > [@jialei-jialei](https://github.com/jialei-jialei) Yeah, this is possible, all hash method has this issue, but the chance is very tiny. Just like the block hash in vllm page attention. BTW, if `current_tokens` of different requests are identical, it means their prompts are identical, that's when we reuse kvcache. You'd better check what `input_tokens_tensor` really means. My point is, if different current_tokens end up with identical hash values, MoonStore would retrieve the wrong data. This is what I'm questioning. I’d like to understand—even if the probability is extremely low, would such a case still be negligible in practice?
Author
Owner

@ShangmingCai commented on GitHub (Jul 23, 2025):

@jialei-jialei Yes, I think it is negligible. Although we didn't split kvcache at the block level for this version, you can refer to the content-hash-based impl of https://github.com/vllm-project/vllm/blob/main/vllm/core/block/prefix_caching_block.py#L54-L67, which shares a similar hash-based design.

<!-- gh-comment-id:3106763472 --> @ShangmingCai commented on GitHub (Jul 23, 2025): @jialei-jialei Yes, I think it is negligible. Although we didn't split kvcache at the block level for this version, you can refer to the content-hash-based impl of https://github.com/vllm-project/vllm/blob/main/vllm/core/block/prefix_caching_block.py#L54-L67, which shares a similar hash-based design.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/Mooncake#209
No description provided.