[Metrics] Add audio SLOs + cross-stage transfer families + per-(stage, replica) wrap for upstream vllm:* (#3576)
Signed-off-by: vraiti <vraiti@redhat.com> Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com> Co-authored-by: vraiti <vraiti@redhat.com>
This commit is contained in:
1 parent
ee33601571
commit
41a795b5d6
29 files changed
+3377
-25
No files matched your search
@@ -7,6 +7,9 @@ import numpy as np
|
||||
import torch
|
||||
from torchaudio.functional import melscale_fbanks
|
||||
|
||||
from vllm_omni.metrics import definitions as _metric_defs
|
||||
from vllm_omni.outputs import OmniRequestOutput
|
||||
|
||||
|
||||
def mel_filter_bank(
|
||||
sr: int,
|
||||
@@ -66,3 +69,39 @@ def peak_normalize(
|
||||
return audio
|
||||
target = 10.0 ** (db_level / 20.0)
|
||||
return audio * (target / peak)
|
||||
|
||||
|
||||
def audio_chunk_pcm_bytes(omni_res: OmniRequestOutput) -> int:
|
||||
"""Best-effort PCM byte count of the last audio chunk in ``omni_res``.
|
||||
|
||||
Used by the audio-streaming continuity tracker to size the player buffer.
|
||||
Returns 0 when the chunk shape can't be interpreted — caller drops the
|
||||
sample rather than recording a wrong byte count.
|
||||
"""
|
||||
try:
|
||||
final_res = omni_res.request_output
|
||||
mm_output = final_res.outputs[0].multimodal_output
|
||||
audio_data = mm_output.get("audio")
|
||||
if isinstance(audio_data, list):
|
||||
if not audio_data:
|
||||
return 0
|
||||
audio_tensor = audio_data[-1]
|
||||
else:
|
||||
audio_tensor = audio_data
|
||||
if audio_tensor is None:
|
||||
return 0
|
||||
n_samples = int(audio_tensor.numel() if hasattr(audio_tensor, "numel") else audio_tensor.size)
|
||||
# PCM s16le mono → 2 bytes per sample. This matches what
|
||||
# _create_audio_choice serialises via CreateAudio (response_format="wav").
|
||||
return max(n_samples, 0) * 2
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
def audio_chunk_sample_rate(omni_res: OmniRequestOutput) -> int:
|
||||
"""Resolve audio sample rate for the request's audio stream."""
|
||||
try:
|
||||
mm_output = omni_res.request_output.outputs[0].multimodal_output
|
||||
except Exception:
|
||||
return _metric_defs.DEFAULT_AUDIO_SAMPLE_RATE
|
||||
return _metric_defs.resolve_audio_sample_rate(mm_output)
|
||||
Reference in new issue
Block a user