Repository navigation
[Feat] hisparse: Support Kimi-K3.1 DSA layers on PD decode with DFLASH - #50005
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
There is a draft KV memory-accounting gap in the newly enabled DFLASH + HiSparse PD path:
For example, with This can make automatic sizing exceed the intended memory budget and cause an OOM during draft pool initialization. The ring path does not avoid this issue: DFLASH draft KV rings are currently disabled for PD disaggregation. Please make the DFLASH memory charge match the host-expanded address space and add a sizing regression test with I verified the accounting mismatch through code inspection and an isolated execution of the sizing helper; I have not reproduced a GPU OOM. |
sgl-project#50005 makes a retracted request on a HiSparse decode pool go back to the prefill (retraction_needs_rebootstrap), but no test runs that path on the decode side. Before it, the cpu_tensor backup reached HiSparseTokenToKVPoolAllocator.get_cpu_copy and raised NotImplementedError. Check that backup_kv_cache and DecodePreallocQueue.add agree on which pools recompute (HiSparse and DeepSeek-V4 do, a host-copy pool does not), and that a HiSparse request the prefill cannot rebuild is not resumed. Refs sgl-project#40729 Signed-off-by: Jianliang Qi <[email protected]>
Resolves conflicts with sgl-project#50005 (Kimi-K3.1 DSA DFLASH) and the main-side hisparse gate tests: keep the branch's wiring comments and the stricter unvalidated-algorithm rejection test alongside main's spec-validation tests.
# Conflicts: # python/sglang/srt/managers/hisparse_coordinator.py # python/sglang/srt/mem_cache/kv_cache_configurator.py # python/sglang/srt/speculative/dflash_worker_v2.py # test/registered/unit/mem_cache/test_hisparse_allocator.py
…id pools The DSA backend passes a model layer id to the HiSparse swap-in, while the device and host buffers hold only the layers of this pipeline-parallel stage, or only the full-attention layers of a hybrid model. main (sgl-project#50005) maps hybrid pools through `_pool_layer_index` inside `swap_in_selected_pages`. This branch added a second entry point, `swap_in_selected_dsa_pages`, that subtracted the stage's start layer and range-checked against the device pool before calling it. After merging main the two stack: for a hybrid pool the dense full pool starts at 0 and has fewer layers than the model, so the range check rejects most layers. Keep one entry point and one table. `_pool_layer_index` now also covers a plain DSA pool on a stage with start_layer > 0, and is applied once at the top of `swap_in_selected_pages`. `swap_in_selected_dsa_pages` is removed and the DSA backend call sites match main again. DeepSeek-V4 (callers pass the compressed pool's layer index), MiniMax M3 (`swap_in_selected_blocks`) and stage 0 are unchanged. The test drives the real swap-in down to the kernel boundary and checks which layer's buffers it reaches, for PP stages, hybrid pools on stage 0 and on a later stage, and DeepSeek-V4. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Motivation
Port of the HiSparse part of #48414 to main.
Kimi-K3.1 rejects
--enable-hisparseon main. This enables HiSparse on the PD decode instance for K3.1's DSA layers, including DFLASH speculative decoding up to block size 8. The KDA recurrent state stays on GPU and is transferred as usual.The speculative swap kernel half of the change (2-8 steps, up to 16384 occurrences) is already on main from #49411.
Modifications
--enable-hisparseon CUDA. The DSA backend must beflashmla_kv;trtllmis rejected, since it is not on the HiSparse FP8 allow-list. ROCm still rejects it. DCP and the decode radix cache stay rejected with HiSparse by the existing checks.HiSparseDSATokenToKVPool(forwardinghost_to_device_ratio) and forwards the HiSparse mapping and translation API to it, asMiniMaxSparseKVPooldoes for its main pool.get_hisparse_kvcache()returns the dense DSA sub-pool of a hybrid linear pool, andswap_in_selected_pagesmaps the model layer id to the sub-pool's layer index. The spec swap limits readSPEC_SWAP_MAX_STEPS/SPEC_SWAP_MAX_OCCURRENCESfrom the kernel module instead of the stale 4 / 8192.prepare_spec_verifyonce the verify locs are assigned, andcommit_spec_accept_tokensafter accept, with accept indices in the EAGLE topk-1 layout.DFLASHjoinsHISPARSE_VALIDATED_SPEC_ALGORITHMS(added on main by [Feat] hisparse: reject unvalidated speculative algorithms by name #48846), since its worker now binds the HiSparse verify slots. This applies to every DSA model; only Kimi-K3.1 was run end to end.dsv4_needs_rebootstrapis renamed toretraction_needs_rebootstrap.Differences from the branch:
get_hisparse_kvcache()on the allocator, so the hybrid case goes there.Tests
test_hisparse_pool_mapping.py: a hybrid linear pool resolves to its DSA sub-pool.test_hisparse_allocator.py: a HiSparse allocator needs rebootstrap on retraction.test_model_overrides.py: K3.1 with HiSparse defaults toflashmla_kvand rejectstrtllm.test_server_args.py: HiSparse accepts DFLASH and still rejects an unvalidated algorithm.test_hisparse_unit.py,test_hisparse_spec_coordinator.pyandkernels/ops/kvcache/test_hisparse*.pygive the same pass and skip counts as main (51 passed, 10 skipped).End to end
Kimi-K3.1 1P1D on 4 GB300 nodes at 8b10ec7 (this PR before the merge of main): prefill TP8, decode TP8 with DFLASH block 8 and
--enable-linear-replayssm-spec, Mooncake over InfiniBand,--hisparse-config '{"top_k":2048,"device_buffer_size":4096,"host_to_device_ratio":4}'. The baseline is the same decode without--enable-hisparse, behind the same prefill. sgl-eval 0.1.3.CI States
Latest PR Test (Base): ⏳ Run #43177167348
Latest PR Test (Extra): ❌ Run #43177167024
Latest PR Test (AMD ROCm 10): ⏳ Run #43177167260
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: