feat(kvevents): parse HMA KV event metadata#612
Open
sagearc wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for vLLM HMA (KV cache group metadata) in KV-cache event parsing so downstream consumers can attribute events to cache groups and understand cache semantics.
Changes:
- Extend
BlockStoredEvent/BlockRemovedEventwith group metadata (group index + cache spec kind + sliding window size) and persistBlockSize. - Update vLLM adapter to decode new trailing fields (HMA metadata) with backward/forward compatibility.
- Add/extend tests covering valid/invalid HMA metadata decoding and group index handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/kvevents/events.go | Adds KV cache spec kind type/constants and extends event structs with block size + group metadata fields. |
| pkg/kvevents/engineadapter/vllm_adapter.go | Decodes/stores block_size and new HMA trailing fields; adds toUint32 helper. |
| pkg/kvevents/engineadapter/vllm_adapter_test.go | Adds tests for HMA metadata parsing, group_idx parsing, and invalid metadata errors. |
| pkg/kvevents/engineadapter/sglang_adapter.go | Populates BlockSize for SGLang block-stored events for parity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
09c490c to
bd0172a
Compare
Signed-off-by: Sage Ahrac <sagiahrak@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Parse and carry vLLM HMA KV event metadata in llm-d-kv-cache.
This adds support for the vLLM fields introduced for hybrid KV cache groups in vLLM PR #40984:
No routing indexing filtering or scoring behavior changes are included in this PR.
Motivation
vLLM emits one KV event per cache group for HMA models.
BlockStoredcarries semantic group metadata whileBlockRemovedcarries only the structural group identity.llm-d-kv-cache needs to preserve this metadata before implementing group aware indexing or HMA aware scoring in follow up work. This PR is intended as the small base change for that work.
Notes
BlockRemovedintentionally does not carrykv_cache_spec_kindin current vLLM. The consumer is expected to learn group semantics fromBlockStoredand useblock_hashwithgroup_idxto identify removed group entries.This PR only preserves the metadata. It does not yet interpret it.
Related: