From 7e9d5046506a36607ce2e60bec13923b2244a9c9 Mon Sep 17 00:00:00 2001 From: Liwansi Date: Tue, 8 Sep 2026 16:33:29 +0800 Subject: [PATCH] skip duplicates host evict --- python/sglang/srt/environ.py | 1 + .../srt/mem_cache/unified_cache/unified_tree_core.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.py index 1239dd34dead..31fa2151f8c4 100644 --- a/python/sglang/srt/environ.py +++ b/python/sglang/srt/environ.py @@ -722,6 +722,7 @@ class Envs: SGLANG_HICACHE_HOST_REGISTER_CHUNK_GB = EnvInt(256) SGLANG_HICACHE_HF3FS_CONFIG_PATH = EnvStr(None) SGLANG_HICACHE_DECODE_OFFLOAD_STRIDE = EnvInt(None) + SGLANG_HICACHE_SKIP_HOST_DUPLICATE_RECLAIM = EnvBool(False) SGLANG_HICACHE_FILE_BACKEND_STORAGE_DIR = EnvStr(None) # File-backend LRU eviction (opt-in; sizes accept SI/IEC suffixes, "0" disables). SGLANG_HICACHE_FILE_BACKEND_MAX_SIZE = EnvStr(None) diff --git a/python/sglang/srt/mem_cache/unified_cache/unified_tree_core.py b/python/sglang/srt/mem_cache/unified_cache/unified_tree_core.py index 14d909b8893a..938511004cd0 100644 --- a/python/sglang/srt/mem_cache/unified_cache/unified_tree_core.py +++ b/python/sglang/srt/mem_cache/unified_cache/unified_tree_core.py @@ -27,6 +27,7 @@ import torch from sglang.srt.disaggregation.kv_events import StorageMedium +from sglang.srt.environ import envs from sglang.srt.mem_cache.base_prefix_cache import ( DecLockRefParams, DecLockRefResult, @@ -1490,11 +1491,16 @@ def drive_host_eviction( self, component_type: ComponentType, num_tokens: int ) -> DriveHostEvictionResult: """Evict a component's host-side resources; no-op if absent. Under - write_back, FULL pressure reclaims redundant Full host copies first.""" + write_back, FULL pressure reclaims redundant Full host copies first + (skipped if SGLANG_HICACHE_SKIP_HOST_DUPLICATE_RECLAIM=1).""" result = DriveHostEvictionResult() comp = self.components_by_type.get(component_type) if comp is not None: - if self.is_write_back and component_type == BASE_COMPONENT_TYPE: + if ( + not envs.SGLANG_HICACHE_SKIP_HOST_DUPLICATE_RECLAIM.get() + and self.is_write_back + and component_type == BASE_COMPONENT_TYPE + ): self._reclaim_full_host_duplicates( num_tokens, result.tracker,