-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add hf3fs support for hicache storage (based on #7704) #7280
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
Conversation
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.
Summary of Changes
Hello @pansicheng, 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 significant enhancement to the KV cache management system by integrating disk storage into the existing HiRadixCache. This "Hidisk" feature expands the total capacity of the KV cache, allowing for larger context windows or more concurrent requests by offloading less frequently accessed KV pairs to disk. The changes include a multi-tiered caching strategy with synchronous writes to memory and disk, and intelligent reads that leverage temporal locality, resulting in improved cache hit rates and overall throughput, as demonstrated by the provided benchmarks.
Highlights
- Disk-Backed Hierarchical Cache: Introduced a new 'Hidisk' feature that integrates disk storage with the existing HiRadixCache, significantly expanding the KV cache capacity. This allows for larger context windows and improved performance by offloading less frequently accessed KV pairs to disk.
- Multi-Tiered Cache Management: Implemented a sophisticated multi-tiered caching strategy. KV data is synchronously written to both memory and disk, and read operations intelligently fetch data from memory or disk into GPU memory, with a portion of disk data copied back to host memory to leverage temporal locality.
- Dedicated Disk I/O Control: Added a new
HiCacheControllerDisk
class with dedicated threads and queues for managing disk I/O operations (writing from device to disk, loading from disk to host, and loading from disk to device), ensuring efficient and asynchronous data transfers. - Configurable Disk Cache: Introduced new command-line arguments (
--hicache-use-disk
,--hicache-disk-path
,--hicache-disk-ratio
,--hicache-disk-size
) to enable and configure the disk-backed hierarchical cache, providing flexibility for deployment and tuning. - Enhanced Memory Management and Eviction: Refactored the cache eviction and load-back policies to intelligently manage KV cache across device, host, and disk tiers. The system now proactively evicts data to lower tiers (host then disk) when GPU memory is constrained and loads data back as needed.
- Performance Benchmarking: Included a new benchmarking script (
disk.sh
) and updated the multi-turn benchmark to demonstrate the performance benefits of the disk-backed cache, showing improved cache hit rates and overall throughput compared to memory-only caching.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 disk storage integration into the hierarchical KV cache, significantly expanding its capacity. The changes involve adding new classes and methods to manage disk operations, updating the cache controller and radix tree logic to handle the new disk layer, and adding configuration options via server arguments. The benchmark results provided demonstrate the potential performance benefits of this feature. The code is generally well-structured, using inheritance and helper methods to manage complexity. There are a few areas identified for potential improvement related to correctness (handling device indices with overlap schedule) and maintainability (clarity of certain logic flows and documentation).
Happy to see this great work! 3FS is on the way :) cc @yizhang2077 |
b1e8900
to
cb1433e
Compare
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
3 similar comments
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
2 similar comments
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
…l-project#7280) Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
…l-project#7280) Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
@pansicheng Hi, I have a question regarding the code. In |
@ykwd Thanks for your review! Currently in storage_hf3fs, different ranks correspond to different 3fs files. For the same key, each rank reads and writes to its own corresponding file, so there won't be any conflicts. |
…l-project#7280) Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
…l-project#7280) Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
Motivation
This PR add hf3fs support for hicache storage (#7704)
bench_multiturn results
Benchmark configuration and test scripts can be found in:
benchmark/hf3fs/bench.sh
Modifications
Checklist