Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions fastdeploy/engine/sched/resource_manager_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,12 @@ def _allocate_decode_and_extend():
self.cache_manager.num_cpu_blocks > 0
or self.config.cache_config.kvcache_storage_backend
):
if not self.cache_manager.can_allocate_gpu_blocks(
can_schedule_block_num_threshold = self._get_can_schedule_prefill_threshold_block(
(request.need_prefill_tokens + self.config.cache_config.block_size - 1)
// self.config.cache_config.block_size
)
if not self.cache_manager.can_allocate_gpu_blocks(
can_schedule_block_num_threshold
): # to prevent block allocation for matching in hierarchical cache and cause dead lock
break
success = self.get_prefix_cached_blocks(request)
Expand Down Expand Up @@ -1150,9 +1153,12 @@ def _allocate_decode_and_extend():
self.cache_manager.num_cpu_blocks > 0
or self.config.cache_config.kvcache_storage_backend
):
if not self.cache_manager.can_allocate_gpu_blocks(
can_schedule_block_num_threshold = self._get_can_schedule_prefill_threshold_block(
(request.need_prefill_tokens + self.config.cache_config.block_size - 1)
// self.config.cache_config.block_size
)
if not self.cache_manager.can_allocate_gpu_blocks(
can_schedule_block_num_threshold
): # to prevent block allocation for matching in hierarchical cache and cause dead lock
break
success = self.get_prefix_cached_blocks(request)
Expand Down Expand Up @@ -1196,6 +1202,7 @@ def _allocate_decode_and_extend():
)
request.status = RequestStatus.RUNNING_PREFILL
else:
# Warnig: _free_blocks before update_cache_blocks may cause storage blocks leak
if self.config.cache_config.enable_prefix_caching:
self._free_blocks(request)
break
Expand Down
Loading