[Refactor] Remove dead key_convert_fn / convert_to_bigram_key (#25161)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
shuwenn
2026-05-13 13:54:36 -07:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 4d91a4f3a1
commit d6b28b4a69
3 changed files with 1 additions and 21 deletions
@@ -44,7 +44,7 @@ from sglang.srt.mem_cache.cache_init_params import CacheInitParams
from sglang.srt.mem_cache.events import KVCacheEventMixin
from sglang.srt.mem_cache.radix_cache import RadixKey
from sglang.srt.mem_cache.swa_memory_pool import SWATokenToKVPoolAllocator
from sglang.srt.mem_cache.utils import convert_to_bigram_key, split_node_hash_value
from sglang.srt.mem_cache.utils import split_node_hash_value
if TYPE_CHECKING:
from sglang.srt.managers.schedule_batch import Req
@@ -353,11 +353,6 @@ class SWARadixCache(KVCacheEventMixin, BasePrefixCache):
else:
self.device = torch.device("cpu")
if self.is_eagle:
self.key_convert_fn = convert_to_bigram_key
else:
self.key_convert_fn = lambda key: key
if params.enable_metrics:
self.init_metrics_collector()
@@ -37,7 +37,6 @@ from sglang.srt.mem_cache.unified_cache_components import (
TreeComponent,
get_and_increase_time_counter,
)
from sglang.srt.mem_cache.utils import convert_to_bigram_key
from sglang.srt.session.streaming_session import StreamingSession
if TYPE_CHECKING:
@@ -225,10 +224,6 @@ class UnifiedRadixCache(BasePrefixCache):
self.hicache_anchor_kv_shared_indices_pools: list[
tuple[PoolName, PoolHitPolicy]
] = []
if self.is_eagle:
self.key_convert_fn = convert_to_bigram_key
else:
self.key_convert_fn = lambda key: key
# Streaming session: embedded StreamingSession with self as inner.
# Always on -- zero overhead when no streaming session is open (the
-10
View File
@@ -373,16 +373,6 @@ def maybe_init_custom_mem_pool(
return False, None, None
def convert_to_bigram_key(tokens: List[int]) -> List[Tuple[int, int]]:
# EAGLE uses bigram keys in the radix tree since draft sequence is the one-token-shifted version of target
# [1, 2, 3, 4] -> [(1,2), (2,3), (3,4)]
if len(tokens) and isinstance(tokens[0], tuple):
return tokens
if len(tokens) < 2:
return []
return [(tokens[i], tokens[i + 1]) for i in range(len(tokens) - 1)]
def get_hash_str(token_ids: List[int], prior_hash: Optional[str] = None) -> str:
hasher = hashlib.sha256()