@@ -245,11 +245,11 @@ def get_new_block_nums(self, request: Request, num_new_tokens: int):
245245 block_num = (
246246 request .num_computed_tokens + num_new_tokens + self .config .cache_config .block_size - 1
247247 ) // self .config .cache_config .block_size - len (request .block_tables )
248- block_num = max (block_num , 0 )
249248 if self .config .speculative_config .method is not None :
250249 block_num = min (block_num + 1 , self .config .cache_config .max_block_num_per_seq )
251250 else :
252251 block_num = min (block_num , self .config .cache_config .max_block_num_per_seq )
252+ block_num = max (block_num , 0 )
253253 return block_num
254254
255255 def _is_decoding (self , request ) -> bool :
@@ -488,6 +488,9 @@ def _get_running_request_reserve_blocks(self, request: Request) -> int:
488488
489489 def _get_can_schedule_prefill_threshold_block (self , num_chunk_new_block ):
490490 """Compute the minimum free blocks required to admit a new prefill request."""
491+ if self .config .scheduler_config .splitwise_role != "mixed" :
492+ return num_chunk_new_block
493+
491494 if self .use_new_token_ratio_reserve :
492495 reserve_blocks = sum (self ._get_running_request_reserve_blocks (req ) for req in self .running )
493496 can_schedule_block_num_threshold = num_chunk_new_block + reserve_blocks
@@ -1002,13 +1005,7 @@ def _allocate_decode_and_extend():
10021005 req_index += 1
10031006 continue
10041007 num_new_block = self .get_new_block_nums (request , num_new_tokens )
1005- if self .config .scheduler_config .splitwise_role == "prefill" :
1006- # for prefill instance, do not set threshold for running requests
1007- can_schedule_block_num_threshold = num_new_block
1008- else :
1009- can_schedule_block_num_threshold = self ._get_can_schedule_prefill_threshold_block (
1010- num_new_block
1011- )
1008+ can_schedule_block_num_threshold = self ._get_can_schedule_prefill_threshold_block (num_new_block )
10121009 # Allocate blocks to prefill
10131010 if self .cache_manager .can_allocate_gpu_blocks (can_schedule_block_num_threshold ):
10141011 request .block_tables .extend (
0 commit comments