[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:
co-authored by
Claude Opus 4.7
parent
4d91a4f3a1
commit
d6b28b4a69
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user