Skip to content

[Feat] kimi-k3.1: HiCache under decode context parallelism - #48877

Merged
kpham-sgl merged 4 commits into
sgl-project:mainfrom
kpham-sgl:kpham/k31-dcp-hicache
Nov 7, 2026
Merged

kpham-sgl merged 4 commits into
sgl-project:mainfrom
kpham-sgl:kpham/k31-dcp-hicache

Conversation

@kpham-sgl

@kpham-sgl kpham-sgl commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Original authors: @yhyang201, @kpham-sgl, @alphabetc1

Split from #48741, which now carries only PD.

Port of #48414

Kimi-K3.1 shards the DSA index-K cache by token under DCP (#48721), so HiCache has to store index-K the way it already handles the sharded MLA KV. This PR ports that path from the Kimi-K3.1 Day-0 branch (#48414) and lifts #48721's DCP rejection of HiCache.

  • L2: the DSA indexer host pool takes the MLA host's dcp_size / dcp_rank and pages by the widened logical page.
  • L3: the indexer pool addresses pages through _storage_page_index (moved from the MLA host to the base class), and storage backends key pages by l3_page_span. check_dcp_l3_extra_pool admits the sharded indexer next to the MLA anchor and KDA state.

Against the raw port (first commit):

  • DSAIndexerPoolHost takes dcp_size / dcp_rank as constructor arguments, not from an anchor host. The assembler passes them only when index-K is sharded by token, so replicated index-K under DCP (other DSA models) keeps its current slot space.
  • The DCP L3 pool check leaves out the DFLASH MLA draft case.

API changes for the source's callers: MLATokenToKVPoolHost._storage_page_index moves to HostKVCache, and DSAIndexerPoolHost.__init__ gains dcp_size / dcp_rank.

Left for later ports: the DFLASH draft in the HiCache L3 check; prefill CP / L3 deduplication stays with #48715; the direct external linker under DCP.

Modifications

  • mem_cache/pool_host/{base,dsa,mla}.py, mem_cache/hybrid_cache/hybrid_pool_assembler.py: DCP translation for the indexer host pool.
  • managers/cache_controller.py, mem_cache/hybrid_cache/hybrid_cache_controller.py, mem_cache/hicache_storage.py, mem_cache/storage/mooncake_store/mooncake_store.py: L3 under DCP with the sharded indexer.
  • arg_groups/model_overrides/kimi_k3.py: Kimi-K3.1 DCP allows HiCache. This gate edit overlaps [Feat] kimi-k3.1: PD disaggregation under decode context parallelism #48741's; whichever merges second takes both.

Tests

  • Static checks: ruff format and ruff check --select F on the touched files.
  • GPU validation owed: HiCache L2 and Mooncake L3 under DCP8, a multi-turn prefix-hit run comparing outputs and hit rates against DCP1.

CI States

Latest PR Test (Base): ❌ Run #42339654945
Latest PR Test (Extra): ❌ Run #42339654848
Latest PR Test (AMD ROCm 10): ❌ Run #42339655023

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

yhyang201 and others added 3 commits November 6, 2026 01:38
Copy the Kimi-K3.1 DCP hunks of the Day-0 branch for PD disaggregation
(Mooncake moves the token-sharded DSA index-K with the KV rows; decode
pages index-K like the prefill) and for HiCache (the DSA indexer host
pool translates widened slots like the MLA anchor, on L2 and L3) onto
the DCP runtime port as they are. Follow-up commits adapt them to main.

Co-authored-by: Khoa Pham <[email protected]>
Co-authored-by: Shuwen Wang <[email protected]>
- disaggregation/utils: main registers PD state from the storage's wire
  entries; record the index-K token bytes from the DSA entry's view.
- DSAIndexerPoolHost takes dcp_size / dcp_rank as constructor arguments
  (main builds it from buffer info, not an anchor host); the assembler
  passes the MLA host's only when index-K is sharded by token, so
  replicated index-K under DCP keeps its current slot space.
The DCP-collapsed MLA draft pool comes with the speculative-decoding DCP
port; until then HiCache L3 under DCP accepts only the MLA anchor, KDA
state and Kimi-K3.1's sharded index-K.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@kpham-sgl

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/unit/mem_cache/test_hicache_dcp_host_pool.py test/registered/unit/mem_cache/test_mem_pool_host.py test/registered/unit/mem_cache/test_dsa_pool_host_unit.py test/registered/unit/mem_cache/test_hybrid_pool_assembler.py test/registered/unit/managers/test_scheduler_hicache_attach.py test/registered/unit/mem_cache/test_hicache_storage_registration_hook.py

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (5 tests): ✅ View workflow run

cd test/ && python3 registered/unit/mem_cache/test_hicache_dcp_host_pool.py  # base-a
cd test/ && python3 registered/unit/mem_cache/test_mem_pool_host.py  # base-a
cd test/ && python3 registered/unit/mem_cache/test_hybrid_pool_assembler.py  # base-a
cd test/ && python3 registered/unit/managers/test_scheduler_hicache_attach.py  # base-a
cd test/ && python3 registered/unit/mem_cache/test_hicache_storage_registration_hook.py  # base-a

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/mem_cache/test_dsa_pool_host_unit.py  # base-b

@kpham-sgl
kpham-sgl merged commit b165323 into sgl-project:main Nov 7, 2026
109 of 127 checks passed
EricKing626 added a commit to EricKing626/sglang that referenced this pull request Nov 8, 2026
sgl-project#48877 gave DSAIndexerPoolHost a dcp_size/dcp_rank of its own for the
Kimi-K3.1 layout, where the index-K is sharded across the group. The host
mirror only spans every rank's slots when that index-K is replicated, so
the widened page count now asks the same question the two new arguments
below it do, and the sharded layout keeps main's per-rank count.
@hnyls2002 hnyls2002 mentioned this pull request Nov 12, 2026
11 of 13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hicache Hierarchical Caching for SGLang mooncake

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants