Skip to content

[UnifiedTree]: Fix UnifiedRadixCache device match semantics with HiCache - #25277

Merged
ispobock merged 5 commits into
sgl-project:mainfrom
hzh0425:hybrid_tree/fix-last-device-node-define
May 15, 2026
Merged

ispobock merged 5 commits into
sgl-project:mainfrom
hzh0425:hybrid_tree/fix-last-device-node-define

Conversation

@hzh0425

@hzh0425 hzh0425 commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Motivation

This PR clarifies UnifiedRadixCache match semantics when HiCache is enabled:

  • separates best_match_node from the device-resident match anchor used as last_device_node
  • tracks last_device_node as the deepest node whose active components are all device-resident
  • disables Mamba branching seqlen under HiCache for now
  • updates init_load_back tests to validate prefix index delta collection, aux-only load-back, and fallback behavior

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test: Run #25925574846
Latest PR Test (Extra): ⚠️ Not enabled — add run-ci-extra label to opt in.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the UnifiedRadixCache to support HiCache by distinguishing between host-backed and device-resident matches. Key changes include updating component match validators with a match_device_only flag, tracking separate device anchors during prefix matching, removing the unused readonly match helper, and refactoring init_load_back to gather prefix indices after a load operation. Review feedback suggests optimizing the _all_valid helper with a generator expression, correcting a return type hint, and removing dead code in the init_load_back logic.

Comment thread python/sglang/srt/mem_cache/unified_radix_cache.py
Comment thread python/sglang/srt/mem_cache/unified_radix_cache.py Outdated
Comment thread python/sglang/srt/mem_cache/unified_radix_cache.py
@hzh0425
hzh0425 force-pushed the hybrid_tree/fix-last-device-node-define branch from c825ed0 to 327fcb3 Compare May 14, 2026 11:55
@hzh0425

hzh0425 commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

@sgl-project sgl-project deleted a comment from github-actions Bot May 15, 2026
@github-actions github-actions Bot added the hicache Hierarchical Caching for SGLang label May 15, 2026
@hzh0425

hzh0425 commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/radix_cache/test_unified_radix_hicache_kl.py

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

🚀 8-gpu-h200 (1 test): ✅ View workflow run

cd test/ && python3 registered/radix_cache/test_unified_radix_hicache_kl.py

@hzh0425

hzh0425 commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author
image Almost all CI jobs passed in the last run.

@ispobock
ispobock merged commit 21b3ac5 into sgl-project:main May 15, 2026
105 of 134 checks passed
SpencerGarnets added a commit to ai-blaise/optimization-playground that referenced this pull request May 16, 2026
Merging upstream sgl-project/sglang main (d523ae1, 52 commits) into
ai-blaise/optimization-playground main, preserving the full custom stack
(IndexCache + TurboQuant 2.5-bit + SMC-SD, NVFP4 IndexCache+HISA 4:1,
HIGGS dense 2-bit MLA KV, HF config dispatcher with indexcache-hisa,
LayerSplit, NCCLX collective, Warp Decode, TokenSpeed/SMC/indexer
server_args defaults, W4A4 MoE WarpDecode).

Conflict resolutions (3 files):

1. python/sglang/srt/mem_cache/hybrid_cache/hybrid_pool_assembler.py
   COMPOSE - kept custom override_kv_cache_dim=compressed_mla_host_dim(kv)
   semantics; adopted upstream function rename (build_shared_anchor_stack
   -> build_anchor_sidecar_stack from PR sgl-project#25277 UnifiedRadixCache device
   match semantics). The renamed function still accepts override_kv_cache_dim
   (verified at hybrid_pool_assembler.py:583), so this is backwards
   compatible. The full call site at L946 already feeds the override into
   the kwarg.

2. sgl-kernel/cmake/flashmla.cmake
   TAKE UPSTREAM - upstream PR sgl-project#24130 (fix sm90 compile flashmla failed)
   renamed the FlashMLA-internal SM100 gate from SGL_KERNEL_ENABLE_SM100A
   to FLASHMLA_ENABLE_SM100 and re-introduced the SM100 source list under
   the new macro. HEADs older SGL_KERNEL_ENABLE_SM100A source-list block
   was a duplicate of upstreams new FLASHMLA_ENABLE_SM100 block; dropped
   the duplicate to avoid CMake emitting the same source files twice. The
   outer SGL_KERNEL_ENABLE_SM100A cmake option in CMakeLists.txt is
   preserved as it gates additional sgl-kernel targets beyond FlashMLA.

3. sgl-kernel/csrc/flashmla_extension.cc
   TAKE UPSTREAM - upstream PR sgl-project#24130 switched the FlashMLA-internal
   #ifdef gate at L94 from SGL_KERNEL_ENABLE_SM100A to FLASHMLA_ENABLE_SM100.
   flashmla.cmake (post-resolution 2) emits target_compile_definitions
   PRIVATE FLASHMLA_ENABLE_SM100 at L173, so the new macro is the one
   actually defined at FlashMLA extension compile time. The unrelated
   #ifndef SGL_KERNEL_ENABLE_SM100A at L21 (different code path) is left
   untouched.

Verification gates:

  GATE 1 git diff --check                                PASS
  GATE 2 no conflict markers                             PASS
  GATE 3 python3.12 -m compileall srt/jit_kernel/ci      PASS
  GATE 4 cargo check sgl-model-gateway -j1               PASS
  GATE 5 test_quantization_config_dispatch (33 tests)    PASS 33/33
  GATE 6 test_nsa_layersplit (26 tests)                  PASS 26/26
  GATE 7 test_higgs_dense_2bit_kv unit                   BLOCKED (GPU
         saturation: 8x H200 fully occupied by sglang::scheduler_TP0-7
         from another job; CUDA error: devices busy or unavailable.
         File compiles cleanly, imports succeed, not merge-induced.)
  GATE 8 test_higgs_dense_2bit_kv_integration            BLOCKED (same)
  GATE 9 test_torchcomms_ncclx CPU subset                PASS 4/4
         (remaining 8 are CUDA-only, expected skip on busy GPU)
  GATE 10 focused custom-stack CPU subset                PASS
         GPU-dependent tests (HiCache transfer, pool host integration)
         BLOCKED on same GPU saturation - reproduced identical
         cudaErrorDevicesUnavailable across all GPU-touching tests.

Custom-stack file integrity check (all 10 sentinel files present):
  layersplit.py, higgs_dense_2bit_kv.cuh, higgs_dense_2bit.py,
  torchcomms_ncclx.py, nvfp4_indexer_quant.cuh, nvfp4_indexer.py,
  hisa_tilelang_kernels/hisa.py, indexer_policy.py,
  indexer_quantization.py, turboquant_dense_kv.cuh.

Custom server_args defaults preserved (verified by grep): tokenspeed_mla,
nsa_indexer_mode, nsa_indexcache_freq, enable_nsa_nvfp4_hisa,
enable_turboquant_dense_kv_cache, enable_higgs_dense_2bit_kv_cache,
enable_hisparse, torchcomms_ncclx_*, enable_return_indexer_topk,
enable_nsa_prefill_context_parallel.

Upstream additions accepted into shared infra (no custom regression):
  - Multi-detokenizer worker support (PR sgl-project#24944, server_args.py).
  - SGLANG_OPT_FP8_WO_A_GEMM auto-disable on non-Blackwell
    (PR sgl-project#25181, server_args.py).
  - SpeculativeAlgorithm.supports_target_verify_for_draft +
    create_future_map extension points (PR sgl-project#24999, spec_info.py).
  - Frozen-KV MTP bonus_tokens=None fix (PR sgl-project#25204,
    frozen_kv_mtp_utils.py - uses existing draft_input.input_ids
    fallback; spec-decoding naming rule still satisfied).
  - HiCache UnifiedRadixCache device match semantics
    (PR sgl-project#25277, hybrid_pool_assembler function rename).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hicache Hierarchical Caching for SGLang run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants