vllm - ✅(Solved) Fix [Feature]: IndexCache support for DSA models [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#37684Fetched 2026-04-08 01:04:04
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
4
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Fix Action

Fix / Workaround

Z.ai released IndexCache based on their research with a claim of 1.2-1.8.x performance increase for DSA models. At least some providers seem to have already included them with some success (see below). It'd be great to have this patch included natively, though I'm not exactly sure if it would need to be a bit more defensive/optional than what's provided in the research repository.

Manually maintaining the vLLM patch from https://github.com/THUDM/IndexCache/blob/main/indexcache_vllm.patch - not a fun prospect.

Sources:

PR fix notes

PR #12: IndexCache: Accelerating Sparse Attention via Cross-Layer Index Reuse

Description (problem / solution / changelog)

Attempted implementation of this paper in SGLang, with calibration/etc.: https://arxiv.org/abs/2603.12201

Changed files

  • python/sglang/srt/environ.py (modified, +3/-0)
  • python/sglang/srt/function_call/gpt_oss_detector.py (modified, +3/-1)
  • python/sglang/srt/layers/attention/nsa/index_cache.py (added, +78/-0)
  • python/sglang/srt/model_executor/forward_batch_info.py (modified, +3/-0)
  • python/sglang/srt/models/deepseek_common/attention_forward_methods/forward_mla.py (modified, +70/-12)
  • python/sglang/srt/models/deepseek_v2.py (modified, +50/-0)
  • python/sglang/srt/server_args.py (modified, +21/-0)
  • scripts/bench_index_cache.py (added, +725/-0)
  • scripts/index_cache_calibrate.py (added, +620/-0)

PR #214: feat: add IndexCache optimization for DSA models

Description (problem / solution / changelog)

Summary

  • implement IndexCache (arXiv:2603.12201) for DeepSeek V3.2 and GLM-5 models
  • monkey-patch mlx-lm's DeepseekV32Attention to skip redundant indexer computation in configurable "shared" layers, reusing topk indices from "full" layers
  • add index_cache_freq to per-model settings (admin UI toggle + frequency input)
  • add centralized apply_post_load_transforms() for future post-load model optimizations

GLM-5-4bit benchmark results (index_cache_freq=4):

contextprefill (OFF→ON)decode (OFF→ON)
pp4096181→186 tok/s (+3%)14.0→15.3 tok/s (+9%)
pp8192154→163 tok/s (+6%)13.0→14.9 tok/s (+15%)
pp16384117→127 tok/s (+8%)12.4→14.1 tok/s (+14%)

Test plan

  • 17 unit tests pass (pytest tests/test_index_cache.py)
  • no regressions in existing test suite (2458 passed)
  • GLM-5-4bit benchmark with freq=4 shows improvement at all context lengths
  • test with DeepSeek V3.2 model
  • verify admin UI toggle works (enable/disable/save/reload)

Changed files

  • omlx/admin/i18n/en.json (modified, +3/-0)
  • omlx/admin/i18n/ja.json (modified, +3/-0)
  • omlx/admin/i18n/ko.json (modified, +3/-0)
  • omlx/admin/i18n/zh-TW.json (modified, +3/-0)
  • omlx/admin/i18n/zh.json (modified, +3/-0)
  • omlx/admin/routes.py (modified, +15/-6)
  • omlx/admin/static/js/dashboard.js (modified, +8/-0)
  • omlx/admin/templates/dashboard/_modal_model_settings.html (modified, +21/-0)
  • omlx/engine/batched.py (modified, +10/-0)
  • omlx/engine_pool.py (modified, +8/-0)
  • omlx/model_settings.py (modified, +1/-0)
  • omlx/patches/__init__.py (added, +2/-0)
  • omlx/patches/index_cache.py (added, +276/-0)
  • omlx/server.py (modified, +1/-0)
  • omlx/utils/model_loading.py (added, +46/-0)
  • tests/test_index_cache.py (added, +189/-0)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Z.ai released IndexCache based on their research with a claim of 1.2-1.8.x performance increase for DSA models. At least some providers seem to have already included them with some success (see below). It'd be great to have this patch included natively, though I'm not exactly sure if it would need to be a bit more defensive/optional than what's provided in the research repository.

I guess if the upcoming DeepSeek V4 retains the DSA architecture, vLLM might also benefit from a native performance boost.

Alternatives

Manually maintaining the vLLM patch from https://github.com/THUDM/IndexCache/blob/main/indexcache_vllm.patch - not a fun prospect.

Additional context

Sources:

Existing implementations:

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To integrate IndexCache for a performance boost, we'll apply the patch from the research repository to our codebase.

Steps:

  • Clone the IndexCache repository: git clone https://github.com/THUDM/IndexCache.git
  • Apply the patch: git apply IndexCache/indexcache_vllm.patch
  • Verify the changes and resolve any conflicts

Example Code Changes:

Before applying the patch, our code might look like this:

import torch

class DSA(torch.nn.Module):
    def __init__(self):
        super(DSA, self).__init__()
        # existing implementation

After applying the patch, the updated code with IndexCache integration might look like this:

import torch
from indexcache import IndexCache

class DSA(torch.nn.Module):
    def __init__(self):
        super(DSA, self).__init__()
        self.index_cache = IndexCache()
        # updated implementation using IndexCache

Verification

To verify the fix, run performance benchmarks on the updated code and compare the results to the original implementation.

Extra Tips

  • Monitor the performance impact of IndexCache on your specific use case
  • Consider adding configuration options to enable or disable IndexCache for flexibility
  • Keep an eye on future updates to the IndexCache repository and reapply patches as needed to maintain compatibility and performance gains.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING