【hicache】Optimize HiCache prefetch logic: adapt to remaining available memory when memory is insufficient (#16370)
Signed-off-by: CLFutureX <chenyongqyl@163.com> Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
This commit is contained in:
co-authored by
Zhiqiang Xie
parent
27659ea8c8
commit
4a04a9818e
@@ -1287,6 +1287,14 @@ class HiRadixCache(RadixCache):
|
|||||||
self.evict_host(prefetch_length)
|
self.evict_host(prefetch_length)
|
||||||
host_indices = self.cache_controller.mem_pool_host.alloc(prefetch_length)
|
host_indices = self.cache_controller.mem_pool_host.alloc(prefetch_length)
|
||||||
if host_indices is None:
|
if host_indices is None:
|
||||||
|
avaliable_size = self.cache_controller.mem_pool_host.available_size()
|
||||||
|
prefetch_length = avaliable_size - (avaliable_size % self.page_size)
|
||||||
|
if prefetch_length >= self.prefetch_threshold:
|
||||||
|
new_input_tokens = new_input_tokens[:prefetch_length]
|
||||||
|
host_indices = self.cache_controller.mem_pool_host.alloc(
|
||||||
|
prefetch_length
|
||||||
|
)
|
||||||
|
else:
|
||||||
last_host_node.release_host()
|
last_host_node.release_host()
|
||||||
# no sufficient host memory for prefetch
|
# no sufficient host memory for prefetch
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user