[PD metrics] Add latency Histogram metrics of each stage for generate requests (#8710)
This commit is contained in:
@@ -42,7 +42,12 @@ from sglang.srt.disaggregation.utils import (
|
||||
poll_and_all_reduce,
|
||||
prepare_abort,
|
||||
)
|
||||
from sglang.srt.managers.schedule_batch import FINISH_LENGTH, Req, ScheduleBatch
|
||||
from sglang.srt.managers.schedule_batch import (
|
||||
FINISH_LENGTH,
|
||||
Req,
|
||||
RequestStage,
|
||||
ScheduleBatch,
|
||||
)
|
||||
from sglang.srt.model_executor.forward_batch_info import ForwardMode, PPProxyTensors
|
||||
from sglang.srt.utils import (
|
||||
DynamicGradMode,
|
||||
@@ -170,6 +175,7 @@ class PrefillBootstrapQueue:
|
||||
pp_rank=self.pp_rank,
|
||||
)
|
||||
self._process_req(req)
|
||||
req.add_latency(RequestStage.PREFILL_PREPARE)
|
||||
self.queue.append(req)
|
||||
|
||||
def extend(self, reqs: List[Req], num_kv_heads: int) -> None:
|
||||
@@ -256,6 +262,8 @@ class PrefillBootstrapQueue:
|
||||
|
||||
num_pages = kv_to_page_num(num_kv_indices, self.token_to_kv_pool.page_size)
|
||||
req.disagg_kv_sender.init(num_pages, req.metadata_buffer_index)
|
||||
|
||||
req.add_latency(RequestStage.PREFILL_BOOTSTRAP)
|
||||
bootstrapped_reqs.append(req)
|
||||
indices_to_remove.add(i)
|
||||
|
||||
@@ -404,6 +412,7 @@ class SchedulerDisaggregationPrefillMixin:
|
||||
# There is no output_ids for prefill
|
||||
req.output_ids.append(next_token_id)
|
||||
self.tree_cache.cache_unfinished_req(req) # update the tree and lock
|
||||
req.add_latency(RequestStage.PREFILL_FORWARD)
|
||||
self.disagg_prefill_inflight_queue.append(req)
|
||||
if (
|
||||
logits_output is not None
|
||||
@@ -539,6 +548,7 @@ class SchedulerDisaggregationPrefillMixin:
|
||||
)
|
||||
for req in done_reqs:
|
||||
req: Req
|
||||
req.add_latency(RequestStage.PREFILL_TRANSFER_KV_CACHE)
|
||||
self.req_to_metadata_buffer_idx_allocator.free(req.metadata_buffer_index)
|
||||
req.metadata_buffer_index = -1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user