text and image metric (#6150)
Signed-off-by: zhuhh97 <zhuhonghan@huawei.com> Signed-off-by: Gao Han <hgaoaf@connect.ust.hk> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
33 files changed
+1802
-162
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -56,6 +56,11 @@ from vllm_omni.diffusion.sched.interface import DiffusionRequestStatus
|
||||
from vllm_omni.diffusion.worker.utils import BaseRunnerOutput, BatchRunnerOutput, RunnerOutput
|
||||
from vllm_omni.errors import client_error_from_metadata, is_client_error_status
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams, OmniTextPrompt
|
||||
from vllm_omni.metrics.utils import (
|
||||
diffusion_scheduler_waiting_metrics,
|
||||
extract_diffusion_denoise_ms,
|
||||
extract_diffusion_vae_decode_ms,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm_omni.outputs import OmniRequestOutput
|
||||
@@ -375,6 +380,9 @@ class DiffusionEngine:
|
||||
self._shutdown_complete = False
|
||||
self.abort_queue: queue.Queue[str] = queue.Queue()
|
||||
self._rpc_queue: queue.Queue[_RpcTask] = queue.Queue()
|
||||
# Copied onto the existing output metrics payload so queue monitoring
|
||||
# reuses the normal diffusion result path without additional IPC.
|
||||
self._scheduler_num_waiting_reqs = 0
|
||||
|
||||
def _init_execute_fn(self) -> None:
|
||||
if self.execution_mode == DiffusionExecutionMode.STEP_BATCH:
|
||||
@@ -444,7 +452,14 @@ class DiffusionEngine:
|
||||
)
|
||||
raise
|
||||
postprocess_start_time = time.perf_counter()
|
||||
formatted_outputs = self.postprocess_output(request, output)
|
||||
scheduler_metrics = diffusion_scheduler_waiting_metrics(getattr(self, "_scheduler_num_waiting_reqs", 0))
|
||||
try:
|
||||
formatted_outputs = self.postprocess_output(request, output)
|
||||
except Exception as exc:
|
||||
# Preserve the latest scheduler snapshot across terminal
|
||||
# abort/error paths, which do not produce formatted outputs.
|
||||
setattr(exc, "diffusion_metrics", scheduler_metrics)
|
||||
raise
|
||||
postprocess_time = time.perf_counter() - postprocess_start_time
|
||||
step_total_ms = (time.perf_counter() - diffusion_engine_start_time) * 1000
|
||||
logger.debug(
|
||||
@@ -456,14 +471,24 @@ class DiffusionEngine:
|
||||
step_total_ms,
|
||||
)
|
||||
for request_output in formatted_outputs:
|
||||
request_output.metrics.update(
|
||||
{
|
||||
"preprocess_time_ms": preprocess_time * 1000,
|
||||
"diffusion_engine_exec_time_ms": exec_total_time * 1000,
|
||||
"diffusion_engine_total_time_ms": step_total_ms,
|
||||
"postprocess_time_ms": postprocess_time * 1000,
|
||||
}
|
||||
)
|
||||
metrics_update = {
|
||||
"preprocess_time_ms": preprocess_time * 1000,
|
||||
"diffusion_engine_exec_time_ms": exec_total_time * 1000,
|
||||
"postprocess_time_ms": postprocess_time * 1000,
|
||||
**scheduler_metrics,
|
||||
}
|
||||
if request.scheduler_queue_wait_ms is not None:
|
||||
metrics_update["scheduler_queue_wait_ms"] = request.scheduler_queue_wait_ms
|
||||
vae_decode_ms = extract_diffusion_vae_decode_ms(output)
|
||||
if vae_decode_ms is not None:
|
||||
metrics_update["vae_decode_time_ms"] = vae_decode_ms
|
||||
forward_ms = extract_diffusion_denoise_ms(output)
|
||||
if forward_ms is not None:
|
||||
metrics_update["forward_time_ms"] = forward_ms
|
||||
kv_recv_ms = getattr(output, "kv_recv_ms", 0.0)
|
||||
if kv_recv_ms > 0:
|
||||
metrics_update["kv_recv_time_ms"] = kv_recv_ms
|
||||
request_output.metrics.update(metrics_update)
|
||||
yield formatted_outputs
|
||||
|
||||
async def step(self, request: OmniDiffusionRequest) -> list[OmniRequestOutput]:
|
||||
@@ -554,6 +579,7 @@ class DiffusionEngine:
|
||||
self._wait_for_admission_if_needed_locked()
|
||||
|
||||
sched_output = self.scheduler.schedule()
|
||||
self._scheduler_num_waiting_reqs = max(int(sched_output.num_waiting_reqs), 0)
|
||||
|
||||
if sched_output.is_empty:
|
||||
self._emit_finished_outputs(sched_output.finished_req_ids, None)
|
||||
|
||||
Reference in new issue
Block a user