Fix spec decode benchmark metrics (#41916)
Signed-off-by: noobhappylife <aratar1991@hotmail.com>
This commit is contained in:
+23
-19
@@ -128,26 +128,30 @@ async def fetch_spec_decode_metrics(
|
||||
continue
|
||||
|
||||
if line.startswith("vllm:spec_decode"):
|
||||
# Extract metric name (before labels) to avoid matching
|
||||
# substrings inside label values.
|
||||
parts = line.split(None, 1)
|
||||
metric_name = parts[0].split("{")[0]
|
||||
if not metric_name.endswith("_total"):
|
||||
continue
|
||||
found_spec_decode = True
|
||||
parts = line.split()
|
||||
if parts:
|
||||
with contextlib.suppress(ValueError):
|
||||
if "num_drafts" in line:
|
||||
num_drafts += int(float(parts[-1]))
|
||||
elif "num_draft_tokens" in line:
|
||||
num_draft_tokens += int(float(parts[-1]))
|
||||
elif "num_accepted_tokens_per_pos" in line:
|
||||
pos_label = 'position="'
|
||||
if pos_label in line:
|
||||
start = line.index(pos_label) + len(pos_label)
|
||||
end = line.index('"', start)
|
||||
pos = int(line[start:end])
|
||||
val = int(float(parts[-1]))
|
||||
accepted_per_pos[pos] = (
|
||||
accepted_per_pos.get(pos, 0) + val
|
||||
)
|
||||
elif "num_accepted_tokens" in line:
|
||||
num_accepted_tokens += int(float(parts[-1]))
|
||||
with contextlib.suppress(ValueError):
|
||||
if "num_drafts" in metric_name:
|
||||
num_drafts += int(float(parts[-1]))
|
||||
elif "num_draft_tokens" in metric_name:
|
||||
num_draft_tokens += int(float(parts[-1]))
|
||||
elif "num_accepted_tokens_per_pos" in metric_name:
|
||||
pos_label = 'position="'
|
||||
if pos_label in line:
|
||||
start = line.index(pos_label) + len(pos_label)
|
||||
end = line.index('"', start)
|
||||
pos = int(line[start:end])
|
||||
val = int(float(parts[-1]))
|
||||
accepted_per_pos[pos] = (
|
||||
accepted_per_pos.get(pos, 0) + val
|
||||
)
|
||||
elif "num_accepted_tokens" in metric_name:
|
||||
num_accepted_tokens += int(float(parts[-1]))
|
||||
|
||||
if not found_spec_decode:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user