@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 06a60d3dd0
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 4, 03:45 UTC

Fix spec decode benchmark metrics (#41916)

Signed-off-by: noobhappylife <aratar1991@hotmail.com>

noobHappylife committed May 8, 2026 at 00:23 UTC 06a60d3dd08b689f381ffd6384b8123371b2f250
1 file changed +23 -19
vllm/benchmarks/serve.py
+23 -19
@@ -128,26 +128,30 @@ async def fetch_spec_decode_metrics(
128 continue
129
130 if line.startswith("vllm:spec_decode"):
131 + # Extract metric name (before labels) to avoid matching
132 + # substrings inside label values.
133 + parts = line.split(None, 1)
134 + metric_name = parts[0].split("{")[0]
135 + if not metric_name.endswith("_total"):
136 + continue
137 found_spec_decode = True
132 - parts = line.split()
133 - if parts:
134 - with contextlib.suppress(ValueError):
135 - if "num_drafts" in line:
136 - num_drafts += int(float(parts[-1]))
137 - elif "num_draft_tokens" in line:
138 - num_draft_tokens += int(float(parts[-1]))
139 - elif "num_accepted_tokens_per_pos" in line:
140 - pos_label = 'position="'
141 - if pos_label in line:
142 - start = line.index(pos_label) + len(pos_label)
143 - end = line.index('"', start)
144 - pos = int(line[start:end])
145 - val = int(float(parts[-1]))
146 - accepted_per_pos[pos] = (
147 - accepted_per_pos.get(pos, 0) + val
148 - )
149 - elif "num_accepted_tokens" in line:
150 - num_accepted_tokens += int(float(parts[-1]))
138 + with contextlib.suppress(ValueError):
139 + if "num_drafts" in metric_name:
140 + num_drafts += int(float(parts[-1]))
141 + elif "num_draft_tokens" in metric_name:
142 + num_draft_tokens += int(float(parts[-1]))
143 + elif "num_accepted_tokens_per_pos" in metric_name:
144 + pos_label = 'position="'
145 + if pos_label in line:
146 + start = line.index(pos_label) + len(pos_label)
147 + end = line.index('"', start)
148 + pos = int(line[start:end])
149 + val = int(float(parts[-1]))
150 + accepted_per_pos[pos] = (
151 + accepted_per_pos.get(pos, 0) + val
152 + )
153 + elif "num_accepted_tokens" in metric_name:
154 + num_accepted_tokens += int(float(parts[-1]))
155
156 if not found_spec_decode:
157 return None