Skip to content

[Doc]: Best Practice for HICache#11001

Merged
hnyls2002 merged 12 commits intosgl-project:mainfrom
hzh0425:hicache/best-practice
Oct 7, 2025
Merged

[Doc]: Best Practice for HICache#11001
hnyls2002 merged 12 commits intosgl-project:mainfrom
hzh0425:hicache/best-practice

Conversation

@hzh0425
Copy link
Collaborator

@hzh0425 hzh0425 commented Sep 28, 2025

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hzh0425, 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 comprehensive documentation for SGLang's HiCache feature. The new guide outlines the architecture, benefits, configuration, and deployment best practices for HiCache, a hierarchical KV caching system designed to significantly enhance performance and efficiency for large language models in long-context and multi-turn conversational AI applications. This addition aims to provide users with clear instructions and insights into leveraging HiCache effectively.

Highlights

  • Introduction to HiCache: This document introduces SGLang's HiCache, a three-tier hierarchical KV caching system that extends RadixAttention. It's designed to significantly improve performance for long-context and multi-turn conversation scenarios by intelligently managing KV caches across GPU memory, host memory, and external storage backends, addressing capacity bottlenecks.
  • Real-World Performance Gains: The documentation highlights substantial performance improvements, including a 56% reduction in Time to First Token (TTFT) and a 2x inference throughput improvement for coding agents, and an 84% reduction in TTFT for general QA scenarios, demonstrating HiCache's effectiveness.
  • Architecture and Components: An overview of HiCache's three-tier memory hierarchy (GPU, host, and storage) is provided, along with its key components: HiRadixTree for page referencing, a Cache Controller for data movement, pluggable Storage Backends, and an Optimized Data Plane with GPU-assisted I/O kernels.
  • Supported Storage Backends: The document lists various production-ready storage backends such as DeepSeek 3FS (HF3FS), Mooncake, AIBrix KVCache, and NIXL, as well as HiCacheFile for development and testing purposes, showcasing the system's flexibility.
  • Configuration and Deployment Guidelines: Detailed guidelines are included for configuring core HiCache parameters, optimizing memory layout, and setting prefetch policies. It also provides practical deployment examples for HF3FS and Mooncake, and demonstrates integration with PD Disaggregation.
  • Custom Storage Backend Integration: Instructions are given for integrating new storage backends, requiring the implementation of get(key), exists(key), and set(key, value) methods, and registration with the HiCache BackendFactory, emphasizing the extensibility of the system.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 comprehensive guide on SGLang HiCache best practices. The documentation is well-structured and covers the motivation, architecture, configuration, and deployment of HiCache. My review focuses on improving the clarity and accuracy of the examples by pointing out potentially incorrect or internal model names that might confuse users. I've also suggested a minor formatting fix.

@hzh0425 hzh0425 force-pushed the hicache/best-practice branch from f344495 to 09f28b0 Compare September 28, 2025 06:39
@ykwd
Copy link
Contributor

ykwd commented Sep 28, 2025

I think we also need to update ‎docs/index.rst

Copy link
Contributor

@merrymercy merrymercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to link it in the index

sglang/docs/index.rst

Lines 35 to 40 in 336e9a6

:caption: Advanced Features
advanced_features/server_arguments.md
advanced_features/hyperparameter_tuning.md
advanced_features/speculative_decoding.ipynb
advanced_features/structured_outputs.ipynb

@merrymercy merrymercy mentioned this pull request Sep 28, 2025
4 tasks
@hzh0425
Copy link
Collaborator Author

hzh0425 commented Sep 29, 2025

also need to link it in the index

sglang/docs/index.rst

Lines 35 to 40 in 336e9a6

:caption: Advanced Features
advanced_features/server_arguments.md
advanced_features/hyperparameter_tuning.md
advanced_features/speculative_decoding.ipynb
advanced_features/structured_outputs.ipynb

added, thx. @merrymercy

@hnyls2002 hnyls2002 merged commit df08bf9 into sgl-project:main Oct 7, 2025
21 of 26 checks passed
ch-tiger1 pushed a commit to ch-tiger1/sglang that referenced this pull request Oct 9, 2025
Co-authored-by: 晟海 <huangtingwei.htw@antgroup.com>
Co-authored-by: huangtingwei <141888744+huangtingwei9988@users.noreply.github.com>
Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
lpc0220 pushed a commit to lpc0220/sglang that referenced this pull request Oct 29, 2025
Co-authored-by: 晟海 <huangtingwei.htw@antgroup.com>
Co-authored-by: huangtingwei <141888744+huangtingwei9988@users.noreply.github.com>
Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Comments