-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(kv-events): Add medium field to KV event types for storage tier tracking #18205
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
base: main
Are you sure you want to change the base?
feat(kv-events): Add medium field to KV event types for storage tier tracking #18205
Conversation
…tracking Add `medium` field to `BlockStored` and `BlockRemoved` event classes to indicate which storage tier the block resides in. This enables KV-aware routers to track SGLang KV blocks across all hi-cache storage tiers. Changes: - Add MEDIUM_GPU, MEDIUM_CPU_TIER1, MEDIUM_CPU_TIER2 constants to kv_events.py - Add optional `medium: str` field to BlockStored and BlockRemoved classes - Update radix_cache.py to emit events with medium="GPU" for L1 cache The medium field is optional for backward compatibility and uses vLLM-compatible values: "GPU" (L1), "CPU_TIER1" (L2), "CPU_TIER2" (L3).
Summary of ChangesHello @ishandhanani, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the KV cache event system by introducing a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a medium field to KV cache events (BlockStored and BlockRemoved) to track the storage tier of KV blocks. This is a valuable addition for monitoring and managing blocks across different storage tiers. The implementation is correct and maintains backward compatibility by making the new field optional.
My main suggestion is to use a string-based Enum for the storage medium types instead of module-level constants. This would improve type safety and make the code more self-documenting about the allowed values for the medium field. I've added specific comments with code suggestions to implement this.
|
We're intentionally using simple string constants instead of an Enum here to match vLLM's API exactly. vLLM uses the same pattern ( This compatibility is important because Dynamo's KV-aware router parses these events and expects the exact string values ("GPU", "CPU_TIER1", "CPU_TIER2") as documented in vLLM. Using an Enum could potentially change serialization behavior with msgspec/msgpack. |
|
Good catch! LGTM |
Got it. Enum is unfriendly for (de)serialization |
|
|
||
| # Medium values for storage tiers (compatible with vLLM) | ||
| MEDIUM_GPU = "GPU" | ||
| MEDIUM_CPU_TIER1 = "CPU_TIER1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does CPU_TIER1 means HiRadixCache? And CPU_TIER2 means remote cpu memory pool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit confusing actually.
CPU_TIER1is actuallyL2storage. Its thehost_to_deviceanddevice_to_hostbuffers inHiRadixCache. Pinned memoryCPU_TIER2is actuallyL3storage. This is the remote storage backend
I'm not sure why VLLM does it this way. I am ok with changing this btw
Summary
Add
mediumfield toBlockStoredandBlockRemovedevent classes inkv_events.pyto indicate which storage tier the block resides in. This enables KV-aware routers to track SGLang KV blocks across all hi-cache storage tiers (L1/GPU, L2/Host, L3/Storage).Changes
MEDIUM_GPU,MEDIUM_CPU_TIER1,MEDIUM_CPU_TIER2constants tokv_events.pymedium: Optional[str]field toBlockStoredandBlockRemovedclassesradix_cache.pyto emit events withmedium="GPU"for L1 cache operationsCompatibility
Noneby default) for backward compatibility"GPU"(L1),"CPU_TIER1"(L2),"CPU_TIER2"(L3)Test Plan
test_radix_cache_unit.py- 35 tests)medium="GPU"via ZMQ subscriber