Skip to content

[Feat] [AMD] hicache: Enable HiCache for DSA DCP with a packed MTP draft - #45205

Merged
HaiShaw merged 24 commits into
sgl-project:mainfrom
EricKing626:amd/hicache-dsa-dcp-packed-mtp
Nov 17, 2026
Merged

HaiShaw merged 24 commits into
sgl-project:mainfrom
EricKing626:amd/hicache-dsa-dcp-packed-mtp

Conversation

@EricKing626

@EricKing626 EricKing626 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR enables HiCache for DSA (For GLM and DeepSeek models) DCP on ROCm, including the packed MTP draft, for device + host (L1/L2) and for L3 storage backends. Under DCP the DSA index-K is replicated on every rank rather than row-sharded like the MLA KV, so this PR also gives it its own L3 page span: one L3 key covers dcp_size of its pages instead of one page per rank.

Result (GLM-5.2-MXFP4, TP4/EP4 + DCP4, MI355X, AgentX):

Conc P90 interactivity (tok/s/user) Throughput (tok/s/GPU) P90 TTFT (s)
40 21.51 → 24.42 (+14%) 27,749 → 29,444 (+6%) 2.57 → 1.90
48 6.03 → 18.91 (3.1x) 18,361 → 32,764 (1.8x) 11.74 → 2.57

Scope

  • Only affects ROCm with dcp_size > 1. On CUDA, DSA DCP + HiCache is still rejected; nothing changes without DCP.
  • L1/L2 and L3 are supported. L3 was checked with the file and Mooncake backends; buffer_only host memory is still rejected under DCP.
  • [Feat] kimi-k3.1: HiCache under decode context parallelism #48877 enabled the DSA L3 path for a row-sharded index-K. This extends it to the replicated layout DeepSeek-V3.2 and GLM use.
  • Speculative decoding: DSA MTP (EAGLE) on ROCm, whose draft KV packs into the target's DCP host rows, plus the DSPARK / DFLASH drafts that were already allowed. Other draft models are rejected, since their host pools have no DCP index translation.
  • Still rejected under DSA DCP: HiSparse, LMCache, PD disaggregation (except on NPU), and --speculative-eagle-topk other than 1.

Correctness

MI355X, amd/GLM-5.2-MXFP4, TP4 + DCP4, fp8 KV, MTP (EAGLE), HiCache write_through.

Result: all pass.

Test Result
test_hicache_dcp_host_pool.py (DCP host pool, L3 page span, L3 extra-pool guard) 33 pass
test_hicache_mtp_state.py (packed draft state) 12 pass
test_hicache_dsa_dcp_gate.py (argument gate) 6 pass
test_dcp_layout_unit.py 18 pass
E2E test_glm52_dcp4_hicache_amd.py 9 pass, ~12.7 min
L3 GPU check, file backend pass
L3 GPU check, Mooncake backend (TCP) pass

E2E details:

  • Accuracy: GSM8K 0.940 (normal) / 0.940 (device pool forced to evict), threshold 0.9.
  • Host reload: after eviction, a re-sent prompt hits the host cache (cached_tokens_details["host"] > 0).
  • KL ≤ 0.25: measured 0.07–0.15 across the six multi-turn replays, no higher than the 0.09–0.20 that plain TP4 + MTP shows without DCP or HiCache, so HiCache adds no drift.
Multi-turn replay Normal Evicted
logprobs_match 0.134 0.072
prefill_cache_hit_branching 0.120 0.151
decode_cache_hit_branching 0.123 0.136

L3 details (same checks on both backends):

  • Exact reload: six 2,816-token random prompts, flush L1/L2, resend. Every resend is served entirely from storage (cached_tokens_details["storage"] = 2816, device 0, host 0).
  • Accuracy across a flush: GSM8K (200 questions) before / after flushing L1/L2 and reloading from storage: file 0.940 / 0.935, Mooncake 0.965 / 0.950. The second pass reads 18,432 tokens from storage.

Performance

glm5.2-fp4-mi355x-sglang-agentic-mtp agentic replay with AgentX (aiperf, semianalysis_cc_traces_weka_062126, seed 42), aggregated with InferenceX. MI355X TP4/EP4 + DCP4, golden simulated AL 3.61, 3600 s profiling window, --mem-fraction-static 0.85, --chunked-prefill-size 32768, --max-running-requests 2×conc, --cuda-graph-max-bs-decode 64. HiCache arm: --hicache-size 256 --hicache-write-policy write_through; the baseline is the same command without HiCache.

Baseline: 75d7c3b + PR #48773 (for fix topk-v2 GPU illegal memory problem)

Conc Config P90 Interactivity (tok/s/user) TPUT per Chip (tok/s/GPU) P90 TTFT (s) Chip Cache Hit Rate CPU Cache Hit Rate Theoretical Cache Hit Rate
16 TP4 + DCP4 49.35 17,734 1.47 96.7% — 97.0%
16 TP4 + DCP4 + HiCache 49.04 17,708 1.47 96.7% 0.0% 97.0%
24 TP4 + DCP4 35.43 24,330 1.71 96.9% — 97.3%
24 TP4 + DCP4 + HiCache 35.25 24,379 1.57 96.9% 0.1% 97.3%
40 TP4 + DCP4 21.51 27,749 2.57 96.1% — 97.1%
40 TP4 + DCP4 + HiCache 24.42 29,444 1.90 93.4% 3.4% 97.2%
48 TP4 + DCP4 6.03 18,361 11.74 89.7% — 96.9%
48 TP4 + DCP4 + HiCache 18.91 32,764 2.57 89.3% 7.4% 97.1%
  • c16 / c24: the working set fits in HBM (CPU hit ≤ 0.1%), and every metric moves by less than 1%. HiCache costs nothing when it isn't needed.
  • c40: the working set starts to spill. HiCache serves 3.4% of prompt tokens from host, raising the total hit rate from 96.1% to 96.8%. P90 interactivity improves 14%, throughput 6%, and P90 TTFT drops from 2.57 s to 1.90 s.
  • c48: without HiCache, evicted prefixes are prefilled again and prefill starves decode. With HiCache they reload from host (7.4% of prompt tokens), for a total hit rate of 96.7% against a 97.1% theoretical ceiling. P90 interactivity rises 3.1x, throughput 1.8x, and P90 TTFT drops from 11.74 s to 2.57 s.

Checklist

  • pre-commit on changed files
  • Unit tests: test_hicache_dcp_host_pool.py (33), test_hicache_mtp_state.py (12), test_hicache_dsa_dcp_gate.py (6), test_dcp_layout_unit.py (18)
  • gfx950 end-to-end: test_glm52_dcp4_hicache_amd.py (9 pass, including the forced-eviction host reload)
  • gfx950 L3: file and Mooncake backends, exact reload + GSM8K after flush
  • Agentic replay c40 / c48, with the DCP4 baseline

CI States

Latest PR Test (Base): ✅ Run #42633028221
Latest PR Test (Extra): ✅ Run #42633028115
Latest PR Test (AMD ROCm 10): ✅ Run #42633028097

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

On ROCm the DSA MTP draft shards its KV like the DCP target, so HiCache can
mirror it the same way as the target instead of rejecting DSA DCP outright.
CUDA keeps rejecting HiCache with DSA DCP.

- The draft packs into the target's host rows and shares their DCP rank
  translation, so no separate draft host pool is needed.
- The DSA indexer host pages the widened transfer indices untranslated,
  since the device index-K spans every DCP rank's slots.

Carried from the original patch onto main, with three rebase decisions:
`dsa_draft_shards_under_dcp` is added here because the compatibility gate
needs it; the index-K elision hunk is dropped because sgl-project#41769 already removed
the HiCache gate from `_should_elide_dsa_index_k` on every platform; and the
packed-draft host-pool unit test is dropped because `MLATokenToKVPoolHost`
now takes buffer infos instead of device pools.
@github-actions github-actions Bot added amd deepseek hicache Hierarchical Caching for SGLang labels Oct 19, 2026
@EricKing626
EricKing626 marked this pull request as ready for review October 19, 2026 17:23
@1am9trash 1am9trash added the run-ci CI: run the baseline test suite on this PR label Oct 20, 2026
1am9trash and others added 3 commits October 20, 2026 08:01
…elds

`DSAIndexerPoolHost` now sizes itself over the anchor's widened slot space,
so it reads `logical_size` and `dcp_size`. This test builds the anchor as a
bare `SimpleNamespace` and had neither, so it failed with an AttributeError
that `retry()` reported as "exceed maximum number of retries".

A real `MLATokenToKVPoolHost` always carries both; the stub now does too.
Every other `DSAIndexerPoolHost` test already anchors on a real host pool.
…l-project#44322 does

`dsa_draft_shards_under_dcp` is also defined by sgl-project#44322, at the same place in
this file. Writing it with `is_hip()` instead of `get_platform().is_hip`
makes the two definitions byte-identical, so whichever PR lands second has
an add/add that resolves itself instead of a conflict. `is_hip` is already
imported here.

@Jacob0226 Jacob0226 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.

Requesting changes on two points. This branch sits on main, not on #44322, so the hook accepts a packed DSA MTP draft whose device pool is still dcp_replicated=True. Its host rows then get mistranslated. Separately, the e2e test is registered on a suite no workflow runs. Details are inline. Please rebase onto #44322 (or hold this until #44322 merges) and add a runtime guard on the packed draft pool.

if not algo.is_eagle() or algo.is_eagle3():
return False
hf_config = model_config_of(server_args).hf_config
return dsa_draft_shards_under_dcp(hf_config, cfg.dcp_size)

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.

On this branch, dsa_draft_shards_under_dcp is only called here. The draft pool still uses loc_space_scale = dcp_size, so it's dcp_replicated=True. On ROCm with DCP, EAGLE and HiCache, this returns True. The draft then packs into the MLA host, and maybe_dcp_kernel_indices maps replicated rows as sharded, so backup and reload hit the wrong draft rows. Please rebase onto #44322. Also add a check in _build_hicache_draft_plan that raises when a packed draft under DCP has dcp_replicated, since the device pool knows how it is actually sharded.

@EricKing626 EricKing626 Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Added a plan-time guard at 3db5d71 that refuses a packed DSA draft whose KV is DCP-replicated. Not rebasing (fork branches); marked as depending on #44322, will merge after it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Location: _check_hicache_draft_dcp_layout() in _build_hicache_draft_plan


cfg = resolving_view(server_args)
algo = SpeculativeAlgorithm.from_string(cfg.speculative_algorithm)
if not algo.is_eagle() or algo.is_eagle3():

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.

This repeats _can_pack_hicache_mtp, but without its num_nextn_predict_layers check. An EAGLE draft with no NextN layers passes here, then runtime picks SIDECAR, and that path assumes a replicated draft under DCP. Please keep one predicate: either reuse the runtime rule, or rely on the plan-time dcp_replicated guard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The plan-time check in _build_hicache_draft_plan is now the single authority (also catches a sharded draft falling to sidecar); the hook docstring says it's only an argument screen.

…sen plan

The argument-level gate only reads the model config, so it cannot tell whether
the draft pool this run actually built is DCP-sharded or replicated. Packed
host rows translate the draft with the target's owner rule; a sidecar mirrors
it untranslated. Reading the wrong one is silent corruption, not a crash.

`_build_hicache_draft_plan` now refuses the mismatch once the pools exist: a
PACKED plan over a replicated DSA draft, and a SIDECAR plan over a sharded
one. The gate's docstring says it is only a screen.

The GLM-5.2 DCP4 HiCache test moves to `nightly-amd-8-gpu-mi35x`, since
`stage-c-test-large-4-gpu-amd-mi35x` is not a suite any workflow runs, and
spells out how `--max-total-tokens` and DCP4 size the pool it overflows. New
unit tests cover the layout check in both directions and the argument gate:
ROCm DSA MTP is accepted, EAGLE3 / non-ROCm / non-DSA are not, and DSPARK and
the no-draft case skip the DSA check.
@EricKing626

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@github-actions

This comment has been minimized.

@EricKing626

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

2 similar comments
@EricKing626

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@EricKing626

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

sgl-project#45019 rebuilt DSAIndexerPoolHost from an IndexKeyBufferInfo plus explicit
geometry, so the host pool no longer sees the anchor it used to widen under
DCP. Take that file as main has it and pass the widened page count from the
one place that now owns the geometry:

    num_host_pages=root_host_pool.page_num * root_host_pool.dcp_size

This is the same widening as before. transfer_page_size is the physical
page, size is always page_num * page_size, and logical_size is size *
dcp_size, so the new expression reproduces the old anchor_host.logical_size
and anchor_host.page_num * dcp_size exactly. dcp_size defaults to 1 on
HostKVCache, so pools without DCP are unchanged.

The NIXL storage test's stub anchor goes away with the same refactor: the
constructor takes no anchor now, so main's version of that test stands.
main reshaped _build_sidecar_host_pool again; re-apply the DCP widening of
num_host_pages on top of its version.
sgl-project#45019 took the decl and the anchor away from DSAIndexerPoolHost and made
the caller pass the geometry, so these DCP cases no longer import. Build
them the way the pool is built now: an IndexKeyBufferInfo over the target
buffers with any packed draft appended, and a layer mapping whose draft ids
follow the target layers.

num_host_pages carries the widening the anchor used to supply, which is
also what _build_sidecar_host_pool passes, so the cases still assert the
host mirror spans every rank's slots and pages the transfer indices
untranslated.
@EricKing626

EricKing626 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Conflict with #45019. Resolved conflicts

@EricKing626

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

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.
sgl-project#49105 added DFLASH to the drafts HiCache accepts under DCP, and sgl-project#48882
let NPU keep PD disaggregation and moved the platform lookup into a local.
Both gates keep their new cases; the ROCm DSA MTP draft and the ROCm-only
HiCache allowance ride alongside them.
…ield

sgl-project#48882 taught _dsa_dcp_overrides to ask whether the platform is NPU, and
it asks unconditionally when it picks the split backends. The stub only
answered about ROCm. Build it from a helper that names every field the
override reads, so the next one fails on a missing argument here instead
of an AttributeError in CI.
…under DCP

DeepSeek-V3.2 and GLM keep the DSA index-K replicated on every rank, so its
HiCache host mirror spans the whole widened slot space instead of one row per
rank. L3 assumed the other layout -- one physical page per rank -- so it keyed
a fraction of each widened page and the DCP guard rejected these models
outright, leaving them on L1/L2 only.

Let a host pool declare how many of its own pages one L3 key covers:

- HostKVCache.storage_page_span reports the logical slots a key spans, and
  l3_page_span now asks the pool rather than deriving it from dcp_size. A
  row-sharded pool keeps its widened page, so nothing changes for Kimi-K3.1
  or for runs without DCP.
- DSAIndexerPoolHost takes storage_pages_per_key and reads, writes and
  describes that many consecutive pages per key, in rank order. Unaligned or
  out-of-range page starts now raise instead of silently landing elsewhere.
- The DCP L3 guard admits a replicated indexer whose mirror covers the
  anchor's logical slots and whose span equals the anchor's widened page.

With this, GLM and DeepSeek-V3.2 run HiCache L1/L2/L3 under DCP with the file
and Mooncake backends.
@github-actions

This comment has been minimized.

…that need it

Narrow the previous commit's footprint without changing behaviour.

HostKVCache no longer carries a storage_page_span property. Nothing read it:
l3_page_span asks with getattr and falls back to page_size * dcp_size, which
is exactly what the property returned, and the DCP L3 guard only reads the
span off a pool it has already type-checked as a DSA indexer. Dropping it
keeps the host pool base class out of this change entirely.

The guard now adds its replicated-index case as a separate branch instead of
restructuring the row-sharded one, so the Kimi-K3.1 path is untouched.
@github-actions

This comment has been minimized.

@EricKing626

Copy link
Copy Markdown
Contributor Author

@HaiShaw could you help reviewing this? Thanks

@HaiShaw HaiShaw added the run-ci-nv-extra CI: NVIDIA/shared Extra suite (requires run-ci) label Nov 11, 2026
@HaiShaw
HaiShaw merged commit b097614 into sgl-project:main Nov 17, 2026
207 of 219 checks passed
@bingxche

Copy link
Copy Markdown
Collaborator

@EricKing626 AMD CI jobs started failing after this PR was merged, and the evidence points at this change.

cc @HaiShaw (merged, reviewed), @1am9trash (co-author), @Jacob0226 (reviewed)

test_glm52_dcp4_hicache_amd.py, added by this PR, hit its 3600 s per-file timeout on its first scheduled run (Nov 17 01:10, rocm10) because about 58 minutes went to downloading amd/GLM-5.2-MXFP4 into the Spur CI HF cache; the exclusive 8-GPU job held the node so long that stage-b-test-1-gpu-small-amd-mi35x queued 75 minutes and hit its 110-minute step timeout. No functional error was seen, and est

The last passing run was on 424fa3c8 and the first failing run on 6c9a1938; this PR's commit b097614b is between them.

Failing jobs (2):

If this PR is the cause, a fix or a revert would turn these jobs green again. If it isn't, please say so here so the attribution can be corrected.

Posted automatically by amd-bot, the AMD CI monitor. Confidence: HIGH.

@bingxche

Copy link
Copy Markdown
Collaborator

@EricKing626 AMD CI jobs started failing after this PR was merged, and the evidence points at this change.

cc @HaiShaw (merged, reviewed), @1am9trash (co-author), @Jacob0226 (reviewed)

test_glm52_dcp4_hicache_amd.py, added by this PR, hit its 3600 s per-file timeout on its first scheduled run (Nov 17 01:10, rocm10) because about 58 minutes went to downloading amd/GLM-5.2-MXFP4 into the Spur CI HF cache; the exclusive 8-GPU job held the node so long that stage-b-test-1-gpu-small-amd-mi35x queued 75 minutes and hit its 110-minute step timeout. No functional error was seen, and est

The last passing run was on 424fa3c8 and the first failing run on 6c9a1938; this PR's commit b097614b is between them.

Failing jobs (2):

If this PR is the cause, a fix or a revert would turn these jobs green again. If it isn't, please say so here so the attribution can be corrected.

Posted automatically by amd-bot, the AMD CI monitor. Confidence: HIGH.

It's model downloading timeout error, unrelated to the code change in this PR. Please ignore this.

nvcnvn added a commit to nvcnvn/sglang that referenced this pull request Nov 17, 2026
sgl-project#45205 lets one L3 key cover storage_pages_per_key indexer pages (DCP with a
replicated index-K). Such a pool stays packed under O_DIRECT: padding between
a key's pages would store it differently from a bounce slot, which holds the
pages back to back, so instances with different layouts would read each
other's keys wrong. Those keys use the padded staging slots; keys of one page
keep zero-copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
EricKing626 added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Nov 18, 2026
…l cache

sgl-project/sglang#45205 lets a DSA DCP decode group run on HiCache. Add a
TP8/EP1 DCP8 arm with a 256 GB/rank write-through host tier at concurrency
16, 20 and 24 to both FP8 configs. ROCm DSA DCP runs only on the triton
backends, so the arm overrides the tilelang default, and GLM-5.3 turns its
monokernel off there because it refuses context parallelism and KV offload.

GLM-5.2 FP8 concurrency 16 moves from the dense HiCache arm to DCP8 so the
two arms do not share an experiment name. GLM-5.3 FP8 gains
dram-utilization 0.8 for the host tier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amd deepseek hicache Hierarchical Caching for SGLang run-ci CI: run the baseline test suite on this PR run-ci-nv-extra CI: NVIDIA/shared Extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants