Negotiate PrefillDelayer only after KV-budget admission checks (#31835)
This commit is contained in:
@@ -845,6 +845,17 @@ class PrefillAdder:
|
||||
return req
|
||||
_rem_tokens = self.rem_chunk_tokens
|
||||
|
||||
# A mid-chunk rank prefills this pass regardless of the delayer
|
||||
# verdict, so report prefillable=True and ignore the result.
|
||||
if self.prefill_delayer_single_pass is not None:
|
||||
self.prefill_delayer_single_pass.negotiate_should_allow_prefill(
|
||||
local_prefillable=True,
|
||||
running_batch=self.running_batch.batch_size(),
|
||||
max_prefill_bs=self.max_prefill_bs,
|
||||
max_running_requests=self.max_running_requests,
|
||||
waiting_queue_len=self.waiting_queue_len,
|
||||
)
|
||||
|
||||
cand_extend_input_len = len(req.full_untruncated_fill_ids) - len(
|
||||
req.prefix_indices
|
||||
)
|
||||
@@ -1001,16 +1012,6 @@ class PrefillAdder:
|
||||
def add_one_req(
|
||||
self, req: Req, has_chunked_req: bool, truncation_align_size: Optional[int]
|
||||
):
|
||||
if (self.prefill_delayer_single_pass is not None) and (
|
||||
not self.prefill_delayer_single_pass.negotiate_should_allow_prefill(
|
||||
local_prefillable=True,
|
||||
running_batch=self.running_batch.batch_size(),
|
||||
max_prefill_bs=self.max_prefill_bs,
|
||||
max_running_requests=self.max_running_requests,
|
||||
waiting_queue_len=self.waiting_queue_len,
|
||||
)
|
||||
):
|
||||
return AddReqResult.OTHER
|
||||
# TODO support cp with multiple requests
|
||||
# Enabling context parallelism currently presents precision issues;
|
||||
# therefore, the prefill-batch setting is temporarily set to 1.
|
||||
@@ -1086,6 +1087,20 @@ class PrefillAdder:
|
||||
return AddReqResult.NO_TOKEN
|
||||
chunk_tokens_limit = min(self.rem_chunk_tokens, swa_cap)
|
||||
|
||||
# Negotiate only after every KV-budget gate (a NO_TOKEN rank must
|
||||
# report not-prefillable via finalize()) and before init_load_back
|
||||
# (a delay verdict must not start KV load-back).
|
||||
if (self.prefill_delayer_single_pass is not None) and (
|
||||
not self.prefill_delayer_single_pass.negotiate_should_allow_prefill(
|
||||
local_prefillable=True,
|
||||
running_batch=self.running_batch.batch_size(),
|
||||
max_prefill_bs=self.max_prefill_bs,
|
||||
max_running_requests=self.max_running_requests,
|
||||
waiting_queue_len=self.waiting_queue_len,
|
||||
)
|
||||
):
|
||||
return AddReqResult.OTHER
|
||||
|
||||
if req.needs_host_load_back():
|
||||
new_indices, req.last_node = self.tree_cache.init_load_back(
|
||||
InitLoadBackParams(
|
||||
|
||||
Reference in New Issue
Block a user