EAGLE cache fix for HiCache (#11215)
This commit is contained in:
@@ -583,6 +583,7 @@ class PrefillAdder:
|
||||
req.prefix_indices = torch.cat([req.prefix_indices, new_indices])
|
||||
req.extend_input_len = len(req.fill_ids) - len(req.prefix_indices)
|
||||
prefix_len = len(req.prefix_indices)
|
||||
req.last_matched_prefix_len = prefix_len
|
||||
|
||||
input_tokens = self.ceil_paged_tokens(req.extend_input_len)
|
||||
|
||||
|
||||
@@ -762,6 +762,7 @@ class Scheduler(
|
||||
hicache_storage_prefetch_policy=server_args.hicache_storage_prefetch_policy,
|
||||
model_name=server_args.served_model_name,
|
||||
storage_backend_extra_config=server_args.hicache_storage_backend_extra_config,
|
||||
is_eagle=self.spec_algorithm.is_eagle(),
|
||||
)
|
||||
self.tp_worker.register_hicache_layer_transfer_counter(
|
||||
self.tree_cache.cache_controller.layer_done_counter
|
||||
|
||||
@@ -44,6 +44,7 @@ class HiRadixCache(RadixCache):
|
||||
hicache_storage_prefetch_policy: Optional[str] = "best_effort",
|
||||
model_name: Optional[str] = None,
|
||||
storage_backend_extra_config: Optional[str] = None,
|
||||
is_eagle: bool = False,
|
||||
):
|
||||
|
||||
if hicache_io_backend == "direct":
|
||||
@@ -135,6 +136,7 @@ class HiRadixCache(RadixCache):
|
||||
page_size,
|
||||
disable=False,
|
||||
eviction_policy=eviction_policy,
|
||||
is_eagle=is_eagle,
|
||||
)
|
||||
|
||||
def _parse_storage_backend_extra_config(
|
||||
@@ -658,6 +660,7 @@ class HiRadixCache(RadixCache):
|
||||
|
||||
def match_prefix(self, key: RadixKey, **kwargs):
|
||||
empty_value = torch.empty((0,), dtype=torch.int64, device=self.device)
|
||||
key.token_ids = self.key_convert_fn(key.token_ids)
|
||||
if self.disable or len(key) == 0:
|
||||
return MatchResult(
|
||||
device_indices=empty_value,
|
||||
@@ -820,9 +823,15 @@ class HiRadixCache(RadixCache):
|
||||
return new_node
|
||||
|
||||
def insert(self, key: RadixKey, value=None, chunked=False):
|
||||
key.token_ids = self.key_convert_fn(key.token_ids)
|
||||
|
||||
if len(key) == 0:
|
||||
return 0
|
||||
|
||||
if self.is_eagle and value is not None:
|
||||
# Make sure the value len equal to the EAGLE bigram key len
|
||||
value = value[: len(key)]
|
||||
|
||||
node = self.root_node
|
||||
child_key = self.get_child_key_fn(key)
|
||||
total_prefix_length = 0
|
||||
|
||||
Reference in New Issue
Block a user