Repository navigation
[Fix][DCP] Localize widened KV ids in MLA retraction CPU backup/restore - #39487
Conversation
…store `MLATokenToKVPool.get_cpu_copy` / `load_cpu_copy` indexed `kv_buffer` with the widened `req_to_token` ids under DCP, so decode retraction on a DCP > 1 PD decode node read past this rank's rows (device-side assert) or copied the wrong token's row. Keep the ids this rank owns and collapse them to rows, following the pool's existing `write_loc_is_dcp_resolved` contract so the unified pool's physical ids pass through untouched. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…he MLA pool Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d PD retraction Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
/rerun-test test/registered/unit/mem_cache/test_hicache_dcp_host_pool.py test/registered/unit/mem_cache/test_decode_retraction_backup.py test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_dcp.py test/registered/disaggregation/test_kimi_linear_pd_dcp4.py test/registered/e2e/disaggregation/test_kimi_linear_pd_dcp4_dspark.py |
|
Results for 🚀 🚀 🚀 🚀 |
ShangmingCai
left a comment
There was a problem hiding this comment.
This minor fix looks good to me.
Motivation
Fixes #38645 (related draft: #38790). On a PD decode node with
--dcp-size > 1,retract_decodebacks up the retracted request's KV throughMLATokenToKVPool.get_cpu_copy, which indexeskv_bufferwith the widenedreq_to_tokenids. Ids past this rank's rows trip a CUDA device-side assert; in-range ones back up and restore the wrong token's row.Modifications
HostKVCache.maybe_dcp_kernel_indicesmoves tolayers/dcp/layout.pyas a pure functionmaybe_dcp_kernel_indices(indices, dcp_size, dcp_rank)next to the other DCP index math; the HiCache MLA host pool and the PD retraction path both call it. Its whole-widened-page assert is dropped because a retracted prefix (seqlen - 1tokens) is ragged; the strided select only needs the run to start page-aligned.test_ragged_run_is_rejectedgoes with it.MLATokenToKVPool.get_cpu_copy/load_cpu_copyrun their ids through it withdcp_size = _write_loc_dcp_span, so the unified pool's already-physical ids (write_loc_is_dcp_resolved) pass through untouched. Mamba/KDA state indices are not touched.test/registered/unit/mem_cache/test_decode_retraction_backup.py: the DCP backup/restore round-trip fails onmainwith an out-of-range row index, and the resolved-pool case guards against double translation.Testing
TestDcpRetractionBackupcases intest_decode_retraction_backup.pypass here and the round-trip case fails onmain;test_hicache_dcp_host_pool.pyindex cases pass.SGLANG_TEST_RETRACT=1 SGLANG_TEST_RETRACT_INTERVAL=6on the decode node, 48 concurrent requests x 256 tokens, decode--max-total-tokens 122880so widened ids exceed the per-rank row count:main(433c999): CUDAindex out of boundsdevice-side assert inMLATokenToKVPool.load_cpu_copyon the first round (~12 retractions in).--dcp-size 1on the same PD setup, so it is a separate retraction issue, not DCP.🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #34913372976
Latest PR Test (Extra): ❌ Run #34913372667
Latest PR Test (AMD ROCm 10): ❌ Run #34913372787