[Metrics] Count finished requests by watermark status (#58715)

Signed-off-by: Simon Veitner <sveitner@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
This commit is contained in:
simon-veitner-redhat
2026-10-12 17:21:22 +00:00
committed by GitHub
co-authored by Claude Lucas Wilkinson
parent 45bb710eca
commit a7b7bc1fbe
7 changed files with 203 additions and 1 deletions
+5 -1
View File
@@ -276,7 +276,7 @@ class RequestState:
output_kind = request.pooling_params.output_kind
assert request.external_req_id is not None
return cls(
state = cls(
request_id=request.request_id,
external_req_id=request.external_req_id,
parent_req=parent_req,
@@ -299,6 +299,10 @@ class RequestState:
stream_input=request.resumable,
remote_prefill_cached_tokens=remote_prefill_cached_tokens,
)
if state.stats is not None and sampling_params is not None:
state.stats.is_watermarked = bool(sampling_params.watermarking)
state.stats.is_watermark_skipped = sampling_params._watermarking_skipped
return state
def make_request_output(
self,
+30
View File
@@ -639,6 +639,25 @@ class PrometheusStatLogger(AggregateStatLoggerBase):
counter_corrupted_requests, per_engine_labelvalues
)
if vllm_config.watermark_config is not None:
counter_watermark_requests = self._counter_cls(
name="vllm:watermark_requests",
documentation=(
"Finished requests by watermark status "
"(only with watermark_config)."
),
labelnames=labelnames + ["status"],
)
self.counter_watermark_requests: dict[str, dict[int, Counter]] = {}
for status in ("watermarked", "skipped", "not_watermarked"):
per_engine_labelvalues_with_status = {
idx: labelvalues + [status]
for idx, labelvalues in per_engine_labelvalues.items()
}
self.counter_watermark_requests[status] = create_metric_per_engine(
counter_watermark_requests, per_engine_labelvalues_with_status
)
counter_prefix_cache_queries = self._counter_cls(
name="vllm:prefix_cache_queries",
documentation=(
@@ -1226,6 +1245,17 @@ class PrometheusStatLogger(AggregateStatLoggerBase):
self.counter_corrupted_requests[engine_idx].inc(
iteration_stats.num_corrupted_reqs
)
if self.vllm_config.watermark_config is not None:
counter_watermark = self.counter_watermark_requests
counter_watermark["watermarked"][engine_idx].inc(
iteration_stats.num_watermarked_reqs
)
counter_watermark["skipped"][engine_idx].inc(
iteration_stats.num_watermark_skipped_reqs
)
counter_watermark["not_watermarked"][engine_idx].inc(
iteration_stats.num_not_watermarked_reqs
)
self.counter_num_preempted_reqs[engine_idx].inc(
iteration_stats.num_preempted_reqs
)
+16
View File
@@ -277,6 +277,12 @@ class RequestStateStats:
# Track if this request is corrupted (NaNs in logits)
is_corrupted: bool = False
# Track if this request was sampled with the engine watermark
is_watermarked: bool = False
# Track if this request asked for the watermark but could not use it
is_watermark_skipped: bool = False
@dataclass
class FinishedRequestStats:
@@ -479,6 +485,9 @@ class IterationStats:
self.time_to_first_tokens_iter: list[float] = []
self.inter_token_latencies_iter: list[float] = []
self.num_corrupted_reqs: int = 0
self.num_watermarked_reqs: int = 0
self.num_watermark_skipped_reqs: int = 0
self.num_not_watermarked_reqs: int = 0
def __repr__(self) -> str:
field_to_value_str = ", ".join(f"{k}={v}" for k, v in vars(self).items())
@@ -624,6 +633,13 @@ class IterationStats:
if req_stats.is_corrupted:
self.num_corrupted_reqs += 1
if req_stats.is_watermarked:
self.num_watermarked_reqs += 1
elif req_stats.is_watermark_skipped:
self.num_watermark_skipped_reqs += 1
else:
self.num_not_watermarked_reqs += 1
class LoRAStats:
"""Tracks waiting and running request IDs for a single LoRA."""