perf(disaggregation): fast-path common decode result processing
This commit is contained in:
@@ -369,11 +369,27 @@ class SchedulerOutputProcessorMixin:
|
||||
result.can_run_cuda_graph,
|
||||
)
|
||||
|
||||
decode_fast_path = False
|
||||
if batch.spec_algorithm.is_none() or batch.is_spec_v2:
|
||||
if batch.is_spec_v2:
|
||||
next_token_ids = self._resolve_spec_overlap_token_ids(result, batch)
|
||||
else:
|
||||
next_token_ids = next_token_ids.tolist()
|
||||
if not batch.return_logprob:
|
||||
decode_fast_path = (
|
||||
logits_output.hidden_states is None
|
||||
and logits_output.customized_info is None
|
||||
and not self.server_args.disaggregation_decode_enable_offload_kvcache
|
||||
and not self.enable_hisparse
|
||||
and all(
|
||||
not req.return_hidden_states
|
||||
and req.grammar is None
|
||||
and req.token_ids_logprob is None
|
||||
and req.top_logprobs_num <= 0
|
||||
and req.multimodal_inputs is None
|
||||
for req in batch.reqs
|
||||
)
|
||||
)
|
||||
|
||||
if batch.return_logprob:
|
||||
next_token_logprobs = logits_output.next_token_logprobs.tolist()
|
||||
@@ -401,6 +417,38 @@ class SchedulerOutputProcessorMixin:
|
||||
|
||||
self.token_to_kv_pool_allocator.free_group_begin()
|
||||
|
||||
if decode_fast_path:
|
||||
for i, (req, next_token_id) in enumerate(zip(batch.reqs, next_token_ids)):
|
||||
req: Req
|
||||
|
||||
if self.enable_overlap and (req.finished() or req.is_retracted):
|
||||
continue
|
||||
|
||||
req.output_ids.append(next_token_id)
|
||||
|
||||
# Update Mamba last track seqlen
|
||||
self._mamba_prefix_cache_update(req, batch, result, i)
|
||||
|
||||
req.time_stats.set_last_decode_finish_time()
|
||||
req.check_finished(1)
|
||||
|
||||
if req.finished():
|
||||
self.maybe_collect_routed_experts(req)
|
||||
|
||||
release_kv_cache(req, self.tree_cache)
|
||||
req.time_stats.set_completion_time()
|
||||
|
||||
self.stream_output(batch.reqs, batch.return_logprob)
|
||||
self.token_to_kv_pool_allocator.free_group_end()
|
||||
|
||||
self.forward_ct_decode = (self.forward_ct_decode + 1) % (1 << 30)
|
||||
self.report_decode_stats(
|
||||
can_run_cuda_graph,
|
||||
running_batch=batch,
|
||||
num_accepted_tokens=result.num_accepted_tokens,
|
||||
)
|
||||
return
|
||||
|
||||
# NOTE: in any case, we should check finish here
|
||||
# if finished, also clean up committed kv cache and over-allocated kv cache here
|
||||
|
||||
|
||||
Reference in New Issue
Block a user