Repository navigation
[HiCache] fix: clear storage reset state - #26009
Merged
Merged
Conversation
alphabetc1
requested review from
Ying1123,
hnyls2002,
merrymercy and
xiezhq-hermann
as code owners
May 21, 2026 17:06
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
xiezhq-hermann
approved these changes
Jun 13, 2026
hzwzwzw
added a commit
to hzwzwzw/sglang
that referenced
this pull request
Jul 13, 2026
…gg abort + double-free + DSv4 PP SWA + HiSparse tail Seven upstream-merged bug/stability fixes for HiCache and DSv4 PP. All adapted where our fork's structure differs (HostKVCache lives inline in memory_pool_host.py rather than pool_host/base.py; some fill_ids semantics differ). - sgl-project#29823 (1e80d93) fix draft host pool allocator type kv_cache_builder.py: pass allocator_type=server_args.hicache_storage_backend into the draft host pool kwargs so the draft path uses the same allocator kind as target (was defaulting to None -> wrong allocator under storage-backed setups). - sgl-project#26009 (f4029d0) clear storage reset state cache_controller.py reset(): also clear host_mem_release_queue and reset prefetch_tokens_occupied so no stale credit / stale slots survive a scheduler reset. - sgl-project#27291 (b7ae714) fix SWA L3 cache miss due to prefetch/hit len mismatch scheduler.py: prefetch computes new_input_tokens up to _compute_max_prefix_len(len(fill_ids)) rather than the raw tail -- the storage prefetch key was overshooting SWA-window match_prefix by up to page_size, causing systematic L3 misses on full-prefix reuse. Upstream uses full_untruncated_fill_ids; our fork uses fill_ids (equivalent surface, no _untruncated variant). - sgl-project#30053 (48ba79c) release HiCache prefetch resources on disagg-prefill bootstrap-queue abort scheduler.py: when aborting a bootstrap-queued disagg-prefill req, also call tree_cache.release_aborted_request(req.rid) so its in-flight L2/L3 prefetch resources are released. Previously they leaked until process shutdown. - sgl-project#29310 (bd2a5db) detect double-free / double-alloc in HostKVCache memory_pool_host.py HostKVCache: track a per-slot slot_used bool tensor; alloc asserts none of the returned slots is already used, free asserts every freed slot is currently used. Turns silent double-free (which corrupts the free_slots list and eventually causes phantom slot reuse) into a loud assertion at the call site. - sgl-project#29106 (c1b5c7e) fix DSv4 PP HiCache SWA allocation and layer mapping deepseek_v4_memory_pool.py: size the SWA sub-pool by stage_layer_num (= len(stage_ratios)) instead of the model-global layer_num, matching the c4/c128 sub-pools which are already stage-local; add get_swa_raw_buffer(layer_id) helper that goes through _swa_local_layer_id for consistency. hybrid_pool_assembler.py: assert that swa_kv_pool.kv_buffer length matches transfer_layer_num (catches the mismatch that sgl-project#29106 fixes at the source); rename the misnamed c4_state_global_layers list -- previously it held LOCAL layer ids but was later indexed with compress_state_pools[layer_id + start_layer]. Introduce a proper c4_state_local_layers (for c4_state_mapping keys) and a true c4_state_global_layers list, and index compress_state_pools / indexer_compress_state_pools by the real global id (no offset). Drop unused c128_state_mapping / c128_state_global_layers now that C128 is not registered with HiCache (upstream sgl-project#27293, already in base). - sgl-project#30408 (1d8e3c2) fix DSV4 HiSparse SWA tail allocation forwarding disaggregation/decode.py DecodePreallocQueue: - Admission-control available_size for hisparse now uses logical_attn_allocator.full_available_size() when the SWA-tail prealloc path is active and that method exists, matching the allocation actually issued below. - _pre_alloc direct-to-host branch now routes through alloc_extend_swa_tail (with swa_tail_len and swa_evicted_seqlen bookkeeping) when the SWA-tail path is active; falls back to the original alloc_logical_only otherwise. Keeps our fork's mem_pool_host.alloc(fill_len) call (upstream uses alloc_paged_token_slots but our host pool exposes .alloc()). Verified: AST parse OK, compileall OK across managers + mem_cache trees. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
HiCacheController.reset()is expected to bring the controller back to a clean state after/flush_cacheor other reset paths. However, when HiCache storage is enabled, the base controller did not clearhost_mem_release_queueor resetprefetch_tokens_occupied.This can leave stale host-memory release entries from before reset. Since
HiRadixCache.reset()clears the host KV pool after resetting the controller, those stale entries may later be drained and freed again, causing duplicated indices in the host pool free list. It can also leave stale prefetch accounting behind, makingprefetch_rate_limited()reject future storage prefetches even though there is no active prefetch operation.HybridCacheController.reset()already clears both states. This PR applies the same cleanup to the baseHiCacheController.reset()path so base HiCache and Hybrid HiCache have consistent reset semantics.Modifications
Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #27051318911
Latest PR Test (Extra): ❌ Run #27051318881