[HiCache] feat: add draft KV cache backing for L2/L3#21125
[HiCache] feat: add draft KV cache backing for L2/L3#21125alphabetc1 wants to merge 4 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello, 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 introduces a draft KV cache backing for the HiCache system, specifically targeting L2/L3 caches. This enhancement addresses a regression issue in speculative decoding where the draft model could see stale or incorrect slot indices after a load_back operation. The changes ensure that the draft KV pool is properly synchronized with the main KV cache, improving the accuracy and stability of speculative decoding. 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. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for backing up the draft model's KV cache to L2 (host) and L3 (storage) when using HiCache with speculative decoding. This is achieved by a new HiCacheDraftMixin that hooks into HiCache's data movement operations (write, load, evict) to synchronize the draft KV cache with the main model's KV cache. The changes are well-integrated into HiRadixCache and HiMambaRadixCache. My main feedback is to refactor a piece of duplicated logic in the scheduler for better maintainability.
| # Mirror the logic in init_disaggregation() to locate the draft KV pool. | ||
| if self.spec_algorithm.supports_spec_v2() and self.enable_overlap: | ||
| if self.server_args.enable_multi_layer_eagle: | ||
| draft_runner = self.draft_worker.draft_worker.draft_runner_list[0] | ||
| else: | ||
| draft_runner = self.draft_worker.draft_worker.draft_runner | ||
| draft_kv_pool = draft_runner.token_to_kv_pool | ||
| else: | ||
| draft_kv_pool = self.draft_worker.model_runner.token_to_kv_pool |
There was a problem hiding this comment.
The logic to locate the draft KV pool is duplicated from init_disaggregation (lines 946-959). To improve maintainability and avoid future inconsistencies, consider refactoring this logic into a helper method, e.g., _get_draft_kv_pool(), and calling it from both _maybe_register_hicache_draft and init_disaggregation.
Motivation
see #16964
How wo reproduce:
benchmark result before this feature(draft L2/L3kvcache):
benchmark result after this feature(draft L2/L3kvcache):
accelt length 4.77->6.90
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci