-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
[Feature]: IndexCache support for DSA models #37735
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
Merged
+83
−5
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
979229b
[Feature]: IndexCache support for DSA models
chaunceyjiang f4aefc3
[Feature]: IndexCache support for DSA models
chaunceyjiang c9d55ec
[Feature]: IndexCache support for DSA models
chaunceyjiang 164830e
[Feature]: IndexCache support for DSA models
chaunceyjiang f2f798c
[Feature]: IndexCache support for DSA models
chaunceyjiang 4160163
[Feature]: IndexCache support for DSA models
chaunceyjiang 8b066b9
[Feature]: IndexCache support for DSA models
chaunceyjiang 41df56c
[Feature]: IndexCache support for DSA models
chaunceyjiang d1bac13
[Feature]: IndexCache support for DSA models
chaunceyjiang 5eeaa44
[Feature]: IndexCache support for DSA models
chaunceyjiang ad20124
Merge branch 'main' into index_cache
mergify[bot] b5b643d
Merge branch 'main' into index_cache
chaunceyjiang 695a152
Merge branch 'main' into index_cache
chaunceyjiang 9d29d06
Merge branch 'main' into index_cache
chaunceyjiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # IndexCache | ||
|
|
||
| IndexCache reduces redundant top-k computation in DeepSeek-V3.2 (DSA) models by caching and reusing top-k indices across layers. | ||
|
|
||
| ## Background | ||
|
|
||
| DeepSeek-V3.2 uses a DeepSeek Sparse Attention (DSA) mechanism where top-k token selection is computed per layer. For deep models with many layers, this computation can be expensive. IndexCache allows skipping redundant top-k computations by reusing indices from previous layers. | ||
|
|
||
| See: [IndexCache Paper](https://arxiv.org/abs/2603.12201) | ||
|
|
||
| ## Usage | ||
|
|
||
| ### CLI | ||
|
|
||
| ```bash | ||
| vllm serve deepseek-ai/DeepSeek-V3.2 \ | ||
| --hf-overrides '{"use_index_cache": true, "index_topk_freq": 4}' ... | ||
| ``` | ||
|
|
||
| ### Configuration Reference | ||
|
|
||
| | Parameter | Type | Default | Description | | ||
| |----------------------|------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | `use_index_cache` | bool | false | Enable IndexCache. Must be set to true to use this feature | | ||
| | `index_topk_freq` | int | 1 | Frequency (in layers) at which top-k is computed. 1 = compute on every layer (disabled), 4 = compute on 1/4 of layers | | ||
| | `index_topk_pattern` | str | null | Per-layer F/S pattern. Overrides index_topk_freq if set. Each character maps to one DSA layer: F = Full, S = Shared | | ||
|
|
||
| ### Configuration Examples | ||
|
|
||
| **Using `index_topk_freq`** (compute every N layers): | ||
|
|
||
| ```bash | ||
| vllm serve deepseek-ai/DeepSeek-V3.2 \ | ||
| --hf-overrides '{"use_index_cache": true, "index_topk_freq": 4}' ... | ||
| ``` | ||
|
|
||
| **Using `index_topk_pattern`** (explicit per-layer control): | ||
|
|
||
| ```bash | ||
| # custom pattern for 61 layers: F = compute, S = reuse | ||
| vllm serve deepseek-ai/DeepSeek-V3.2 \ | ||
| --hf-overrides '{"use_index_cache": true, "index_topk_pattern": "FFSFSSSFSSFFFSSSFFFSFSSSSSSFFSFFSFFSSFFFFFFSFFFFFSFFSSSSSSFSF"}' | ||
| ``` | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. When IndexCache is enabled, layers marked with `"F"` (Full) calculate and store top-k indices | ||
| 2. Subsequent layers marked with `"S"` (Shared) receive the cached indices from the previous layer instead of recomputing | ||
| 3. The cached indices are passed through the layer stack, reducing total computation | ||
|
|
||
| ## Requirements | ||
|
|
||
| - DeepSeek-V3.2 or compatible DSA model | ||
| - `use_index_cache: true` via `--hf-overrides` |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.