Repository navigation
[HiCache] Compact DSA indexer host storage to producer layers - #38426
anish-shanbhag wants to merge 22 commits into
Conversation
45c3a5c to
35fc49c
Compare
35fc49c to
98bb500
Compare
|
/rerun-tests test/registered/radix_cache/unified_radix_tree/test_unified_radix_cache_kl_glm52.py |
|
Results for 🚀 |
|
/tag-and-rerun-ci |
|
@anish-shanbhag Could you fix this real pipeline failure? |
|
@nvpohanh Fixed in 8b0a4b72b8. This test fixture constructs |
|
/rerun-failed-ci |
|
[by Codex] @anish-shanbhag, the relevant CI failure appears to be caused by this PR: https://github.com/sgl-project/sglang/actions/runs/34558027928/job/103137031714. |
|
/rerun-failed-ci |
|
/rerun-tests test/registered/e2e/models/test_glm53_flash_b200.py |
|
Results for 🚀 |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
@anish-shanbhag could you fix the conflicts? |
…dex/pr-38426-merge # Conflicts: # python/sglang/srt/mem_cache/hybrid_cache/hybrid_pool_assembler.py
|
/rerun-failed-ci |
|
Let's use #41769 instead |
Resolves the conflicts in the DSA indexer host pool. main has since grown its own producer-layer compaction: the host pool declaration now carries `owned_device_layers`, built in pool_host/dsa.py from `skip_topk_layers`, and DSAIndexerPoolHost derives `_live_target_layers` / `_device_to_host_layer` / `target_layer_num` from it. That supersedes the host-pool half this branch carried from sgl-project#38426 (closed in favour of this PR), so the conflicting files take main's version: - mem_cache/pool_host/dsa.py - mem_cache/hybrid_cache/hybrid_pool_assembler.py - test/registered/unit/mem_cache/test_hicache_staged_write_back_dispatch.py - test/registered/unit/mem_cache/test_dsa_pool_host_unit.py - test/registered/unit/mem_cache/test_hicache_host_register.py `get_dsa_hicache_indexer_layers` and the `hicache_indexer_layers` assignment it fed are removed as dead code -- main derives the same producer set directly from `skip_topk_layers`, without re-deriving it from the model config. The `_should_elide_dsa_index_k` docstring now points at that declaration instead. What this branch still contributes, unchanged: - `_should_elide_dsa_index_k` drops the `enable_hierarchical_cache` and `disaggregation_mode == "null"` conditions, so device index-K elision also applies under HiCache and PD disaggregation. - The Mooncake PD transfer tolerates the resulting zero-length entries: it aligns the peers' layer spans before comparing, drops entries elided on both peers, raises when an entry is elided on exactly one, and refuses to register or queue a zero-length region. Net against main: 2 files, +80/-2. Co-Authored-By: Claude Opus 5 <[email protected]>
Problem this solves
HiCache currently allocates and transfers a host-side DSA index-K slot for every target transformer layer, including layers that never produce index-K state. Some DSA models compute top-k indices only on selected producer layers and carry those indices through intervening shared-top-k layers. Keeping a host index-K copy for the shared layers wastes memory without preserving additional state.
This is significant for long-context GLM-5.2 NVFP4 serving. With
index_topk_freq=4andindex_skip_topk_offset=3, only 21 of 78 target layers produce top-k indices; the other 57 reuse the preceding producer's indices. The current host sidecar nevertheless reserves all 78 index-K layers.For the measured configuration, the per-token host allocation was:
The change saves 7,524 bytes per cached token, or 13.48% of total host-cache bytes per token. In full disaggregated workload runs, this made a 170 GiB HiCache setting feasible: prefill-node RSS was approximately 719.5–726.7 GiB, versus about 827 GiB estimated for the previous all-layer allocation. A 180 GiB setting still reached approximately 759.3 GiB and OOMed, so this removes a specific source of over-allocation rather than providing unlimited headroom.
What changes
dsa_layer_skips_topkpredicate used by model execution.This only changes the DSA index-K host sidecar. It does not compact ordinary MLA KV, target device KV/index-K allocation, model weights, attention math, indexer math, logits, or packed draft state.
Why the mapping is expected to preserve model behavior
dsa_layer_skips_topk(config, layer_id)is the canonical predicate for layers that reuse an earlier layer's top-k result. Such layers do not run the indexer and therefore do not create independent index-K state to offload. Producer layers keep a one-to-one device-to-host association through an explicit compact mapping, and every producer buffer remains present in bulk and per-layer transfer paths.Current SGLang already uses the same skip predicate to create zero-row device index-K placeholders when hierarchical cache, disaggregation, and external linking are disabled. Those modes currently prevent that device-side elision because the HiCache transfer layout assumes one host slot per layer. This change addresses that transfer/layout assumption while retaining full device allocation in the affected modes.
MTP drafts are handled separately: target producer buffers are packed first, followed by every draft buffer. The controller continues to expose the original target-layer span, maps draft transfer layers after that span, and the host pool translates them to slots immediately after the compact target section.
Workload evidence
Two full GLM-5.2 NVFP4 workload validations using the compact sidecar scored GSM8K exact-match values of 0.9697 and 0.9613, both above a 0.9 acceptance gate. The same runs exercised realistic prefix-cache traffic and completed with the expected 21-of-78 producer mapping.
These scores rule out a gross end-to-end accuracy regression in those runs, but they do not prove bitwise or numerical equivalence. They were not patched-versus-unpatched twins on identical requests, and GSM8K does not guarantee that every evaluated request crossed a host eviction/restore boundary.
Tests
Added or strengthened coverage for:
Checks run in the development environment:
The targeted pytest module could not be collected in the available login environment. The local Python has no PyTorch; the available CUDA PyTorch environment first had an incompatible Transformers version, and with the required Transformers version overlaid, importing torchaudio failed because
libcudart.so.12was unavailable on the login host. No GPU-capable worker was available for a real eviction/restore test, so the added GPU transfer coverage is left to CI.Limitations and follow-up
index_topk_freq=4,index_skip_topk_offset=3, PP1, and the standard DSA execution path. Other producer patterns use the same predicate but were not exercised end to end here.CI States
Latest PR Test (Base): ⏳ Run #36780642759
Latest PR Test (Extra): ❌ Run #36780642642
Latest PR Test (AMD ROCm 10): ⏳ Run #36780642928