Skip to content

enable hisparse prefetch utilizing IndexShare for GLM-5.2 and more - #29637

Closed
xiezhq-hermann wants to merge 2 commits into
mainfrom
hisparse-prefetch-indexshare
Closed

xiezhq-hermann wants to merge 2 commits into
mainfrom
hisparse-prefetch-indexshare

Conversation

@xiezhq-hermann

@xiezhq-hermann xiezhq-hermann commented Jun 29, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Loading KV cache from host memory on critical path has been a major overhead of HiSparse. This PR utilize ShareIndex feature introduced in GLM-5.2 to enable prefetch, which effectively hides 70% of the IO latency according to our benchmark.
Credit to an earlier PR #28523 by @huangtingwei9988 as well.

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #28358284984
Latest PR Test (Extra): ❌ Run #28359147399

…exshare

# Conflicts:
#	python/sglang/srt/managers/hisparse_coordinator.py
#	python/sglang/srt/model_executor/model_runner.py
@xiezhq-hermann xiezhq-hermann self-assigned this Jun 29, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 29, 2026
@xiezhq-hermann xiezhq-hermann added run-ci CI: run the baseline test suite on this PR hisparse high priority and removed documentation Improvements or additions to documentation labels Jun 29, 2026
@mintlify

mintlify Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
lmsysorg 🟢 Ready View Preview Jun 29, 2026, 8:20 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 automatic shared-index prefetching in HiSparse to optimize decode performance for models that reuse anchor layer top-k selections (such as DeepSeek DSA). It refactors HiSparseCoordinator to initialize a separate prefetch stream, events, and buffers, and updates swap_in_selected_pages to asynchronously prefetch skip layers on this stream. Additionally, ModelRunner is updated to auto-enable this feature for compatible models when pipeline parallelism and speculative decoding are disabled. The reviewer feedback suggests synchronizing the newly introduced prefetch_stream in the destroy() method of HiSparseCoordinator to prevent potential race conditions or CUDA errors during teardown.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

group = self._prefetch_groups.setdefault(anchor, [])
self._prefetch_slot[i] = len(group)
group.append(i)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The newly introduced self.prefetch_stream is not synchronized in the destroy() method of HiSparseCoordinator. To prevent potential race conditions, undefined behavior, or CUDA errors when the coordinator is destroyed while prefetch operations are still in-flight, please ensure self.prefetch_stream.synchronize() is called inside destroy() if self.enable_prefetch is enabled.

@xiezhq-hermann

Copy link
Copy Markdown
Collaborator Author

There is a branch implementing the IO-only path (eliminating duplicated meta data processing on the skipped layers), which is potentially more performant on less powerful GPUs, can you give a try on your benchmark @huangtingwei9988:
https://github.com/sgl-project/sglang/tree/hisparse-prefetch-indexshare-io-only

@xiezhq-hermann

Copy link
Copy Markdown
Collaborator Author

Replaced by #34329

@Jiminator
Jiminator deleted the hisparse-prefetch-indexshare branch September 14, 2026 04:42
@alexnails
alexnails restored the hisparse-prefetch-indexshare branch September 14, 2026 05:44

This branch was successfully deployed

1 active deployment
staging - docs_new — 69c4073e Deployed Jun 29, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high priority hisparse run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants