Repository navigation
[Feat] [AMD] hicache: Enable HiCache for DSA DCP with a packed MTP draft - #45205
Conversation
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.
…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
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
/rerun-failed-ci |
This comment has been minimized.
This comment has been minimized.
|
/rerun-failed-ci |
2 similar comments
|
/rerun-failed-ci |
|
/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.
|
Conflict with #45019. Resolved conflicts |
|
/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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
|
@HaiShaw could you help reviewing this? Thanks |
|
@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 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. |
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]>
…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.
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_sizeof its pages instead of one page per rank.Result (GLM-5.2-MXFP4, TP4/EP4 + DCP4, MI355X, AgentX):
Scope
dcp_size > 1. On CUDA, DSA DCP + HiCache is still rejected; nothing changes without DCP.buffer_onlyhost memory is still rejected under DCP.--speculative-eagle-topkother than 1.Correctness
MI355X,
amd/GLM-5.2-MXFP4, TP4 + DCP4, fp8 KV, MTP (EAGLE), HiCachewrite_through.Result: all pass.
test_hicache_dcp_host_pool.py(DCP host pool, L3 page span, L3 extra-pool guard)test_hicache_mtp_state.py(packed draft state)test_hicache_dsa_dcp_gate.py(argument gate)test_dcp_layout_unit.pytest_glm52_dcp4_hicache_amd.pyE2E details:
cached_tokens_details["host"] > 0).logprobs_matchprefill_cache_hit_branchingdecode_cache_hit_branchingL3 details (same checks on both backends):
cached_tokens_details["storage"] = 2816, device 0, host 0).Performance
glm5.2-fp4-mi355x-sglang-agentic-mtpagentic 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)
Checklist
pre-commiton changed filestest_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)test_glm52_dcp4_hicache_amd.py(9 pass, including the forced-eviction host reload)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-testto run the tests your change touches, or copy this prompt for an agent: