Skip to content

[Feature] hicache: support DCP with EAGLE/MTP speculative decoding - #45499

Closed
nvpohanh wants to merge 1 commit into
sgl-project:mainfrom
nvpohanh:pohanh/hicache-dcp-eagle
Closed

nvpohanh wants to merge 1 commit into
sgl-project:mainfrom
nvpohanh:pohanh/hicache-dcp-eagle

Conversation

@nvpohanh

@nvpohanh nvpohanh commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

[by Claude Code]

Motivation

AgentX-style long-context agentic workloads on GLM-5.2 / DSA models benefit from decode context parallelism (DCP) and HiCache at the same time. On 8xB200, TP8+DCP8 gives about 6x the logical KV capacity of TP8. HiCache would keep long multi-turn prefixes in host DRAM. These deployments run the checkpoint's own MTP head through EAGLE. Today the combination is rejected twice:

  • resolve_hicache_dcp_compatibility raises NotImplementedError for --dcp-size > 1 + HiCache unless the speculative algorithm is DSPARK.
  • _dsa_dcp_overrides rejects HiCache for any DSA model under DCP.

So DCP + EAGLE/MTP has to run with GPU-resident KV only.

Root cause

Under DCP, the target MLA KV is striped by position. The HiCache host pool keeps widened logical slots and translates them to this rank's physical rows at the transfer boundary (#33112). The draft KV, including the NextN/MTP layer, is replicated: every rank stores the full draft context over the widened virtual slots, untranslated.

  • EAGLE/MTP drafts are packed. For NextN MTP, _build_hicache_draft_plan packs the draft pool into the target host pool as extra layers. The draft rows would then go through the per-rank translation and be sized like the per-rank shard. That is wrong for a replicated pool. DSpark ([HiCache] Support DCP with DSpark #35221) works because its draft goes through the separate sidecar host pool, sized over the anchor's logical_size with no translation.
  • DSA index-K is replicated too ([DCP] Decode context parallelism for DSA (GLM-5.2 / GLM-5.3) with MTP #43735). DSAIndexerPoolHost copied its size from the anchor's per-rank shard, so logical host indices above size had no host page.
  • The replicated draft indexer sidecar was mis-sized. A replicated DSA draft's stored index-K row holds dcp_size kernel pages. make_dsa_indexer_pool_decl sized a host page from index_page_size, so it either failed its divisibility assert (dcp_size=8) or copied 1/dcp_size of each row.

Change

  • speculative/base_spec_worker.py: with DCP + HiCache, back the draft up as a sidecar instead of packing it. The sidecar is the same host pool that DCP + DSpark already uses. Multi-runner (multi-layer EAGLE) and topk > 1 raise a clear NotImplementedError.
  • arg_groups/hicache_hook.py: allow EAGLE/NEXTN with --speculative-eagle-topk 1 alongside DSPARK. Other algorithms and topk > 1 are still rejected. The L3 storage backend, LMCache, HiSparse and non-MLA guards are unchanged.
  • arg_groups/model_overrides/deepseek_v2.py: DSA + DCP now allows HiCache. HiSparse is still rejected.
  • mem_cache/pool_host/dsa.py:
    • The indexer host pool spans the anchor's widened logical_size. This is unchanged without DCP.
    • The indexer decl sizes a page from the stored row, page_size // index_kpool, which is the same as before for non-replicated pools.
  • mem_cache/hicache_auto_size.py: the draft sidecar estimate counts widened target slots under DCP. It used to undercount the draft host pool by dcp_size.
  • docs/advanced_features/dcp.mdx: document the new scope.

No kernel changes.

Related PRs

Limitations

  • Only HiCache L2 (host DRAM). L3 storage backends with DCP stay rejected, and so does TileLang FP8 KV with DCP.
  • EAGLE/NEXTN needs --speculative-eagle-topk 1 and a single draft model runner, so multi-layer EAGLE is rejected. EAGLE3/STANDALONE stay rejected with DCP + HiCache because they are untested.
  • Each rank's draft sidecar holds every logical slot, because the draft KV is replicated. For GLM-5.2 that is one extra layer next to 78 sharded target layers.

Test evidence

Unit tests (CPU), in lmsysorg/sglang:nightly-dev-20261021-c1c287a4 on this exact commit: 472 passed. The only failure is TestDcpCommBackendDefault::test_a5_npu_supports_dcp, which also fails on unmodified main on that GB300 host because of the fi_a2a platform resolution, so it is unrelated. The run covered test_hicache_dcp_host_pool, test_hicache_mtp_state, test_hicache_auto_size, test_hybrid_pool_assembler, test_mem_pool_host, test_mla_host_dedup_primitives, test_hicache_nixl_storage, test_linker_pool_assembler, test_dsa_pool_host_unit, test_decode_retraction_backup, test_server_args and hicache/test_dsa_host_release.

New cases, each checked to fail on the pre-fix source:

Case Pre-fix failure
DSA target indexer round-trips the top widened logical page under DCP IndexError: index 67 is out of bounds ... size 10
Replicated draft indexer decl covers the stored row (dcp_size=8) AssertionError: index page of 8448 bytes does not split over page_size=512
DCP + HiCache plan backs the MTP draft up as a sidecar; multi-runner and topk 2 are rejected the draft was packed
handle_hicache admits EAGLE/NEXTN topk 1 and DSPARK, rejects EAGLE topk 2, EAGLE3 and STANDALONE only supports DSPARK
Auto-size counts every widened slot for a DCP draft sidecar 4608 != 6144

Pre-commit: pre-commit run --all-files passes on this commit.

GPU (GLM-5.2-FP8, 1x GB300 node with 4 GPUs, TP4 + DCP4). This used SM103 GB300 rather than 8xB200; both run the same DSA DCP trtllm path. All runs used --kv-cache-dtype fp8_e4m3 (DSA prefill/decode resolved to trtllm, DCP comm fi_a2a) and --speculative-algorithm EAGLE --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4, with SGLANG_ENABLE_RANK_CONSENSUS_CHECKER=1.

  • Capacity: device KV is 1,276,224 physical tokens/rank, so max_total_num_tokens=5,104,896 logical. Under the default auto-sizing, the host pools per rank were:

    • target KV: 2,552,512 physical tokens (114.68 GB)
    • DSA indexer, logical-sized: 28.30 GB
    • draft KV sidecar: 10,210,304 logical tokens (5.88 GB)
    • draft indexer: 1.35 GB

    That is 139.9 GiB, matching the auto-size estimate.

  • Load-back probe: a 46K-token fact-list document is prefilled. Eight retrieval questions are asked on the original device KV and repeated once. Then 122 distinct 46K-token fillers (5.6M tokens) evict the document, and the eight questions are asked again. The first of those loads 45,824 prefix tokens from host (cached_tokens_details: {"device": 0, "host": 45824}).

Config GSM8K (sgl-eval 0.1.3, 200 ex., GLM-5.2 preset, thinking on, seed 0) Retrieval acc. device-hit / after host load-back Mean MTP accept len device-hit / after load-back Server avg accept len
No HiCache (baseline) 97.5% 8/8 / 8/8 (recomputed) 3.07 / 3.18 2.89
HiCache write_through, page_first, kernel 98.5% 7/8 / 8/8 3.08 / 3.03 2.96
HiCache write_back, page_first_direct, direct 97.5% 7/8 / 7/8 3.01 / 3.14 3.11

The only retrieval miss is item 1234, which the model also misses on device-resident KV. Greedy continuations past the answer word are not run-to-run deterministic in this configuration, even without HiCache: a plain device-hit repeat matches its own earlier text in only 1-3 of 8 cases. The fair checks are therefore answers and acceptance length, and both match. A wrong latent shard or index-K page would break long-range retrieval. A corrupted draft KV would collapse the MTP acceptance length. The rank-consensus checker never fired.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #39539988880
Latest PR Test (Extra): ❌ Run #39539988828
Latest PR Test (AMD ROCm 10): ❌ Run #39539988915

Under decode context parallelism the draft KV cache is replicated over the
widened logical slots, while the target's HiCache host rows hold only this
rank's shard. Back the EAGLE/NEXTN draft up in its own sidecar host pool
(as DSpark already does) instead of packing it into the target host pool,
and allow EAGLE/NEXTN with topk 1 in the HiCache + DCP guard.

For DSA models (GLM-5.2), the index-K cache stays replicated under DCP, so
size its host pool over the anchor's widened logical slots, and size the
replicated draft indexer sidecar from the stored index-K row. Lift the DSA
DCP HiCache rejection (HiSparse and L3 storage stay rejected), and count the
widened target slots when auto-sizing a DCP draft sidecar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 44a18f7.

Approve preview

@github-actions github-actions Bot added documentation Improvements or additions to documentation deepseek hicache Hierarchical Caching for SGLang labels Oct 21, 2026
fy1214 added a commit to fy1214/sglang that referenced this pull request Nov 24, 2026
…40434) onto glm5.3-flash

Surgical overlay validated on 355461: allow EAGLE/MTP with DCP+HiCache,
role-aware dcp_size through hybrid/TBO, and flashmla_kv DCP gates.
@nvpohanh nvpohanh closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant