Skip to content

Commit 272e31c

Browse files
[Bugfix] Guard for negative counter metrics to prevent crash (vllm-project#10430)
Signed-off-by: Travis Johnson <[email protected]>
1 parent 74f8c2c commit 272e31c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

vllm/engine/llm_engine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ def _get_stats(self,
17161716
# not counted (to avoid double counting)
17171717
actual_num_batched_tokens = scheduler_outputs.num_batched_tokens # type: ignore
17181718

1719-
num_generation_tokens_from_prefill_groups = 0.
1719+
num_generation_tokens_from_prefill_groups = 0
17201720
# NOTE: if scheduler_outputs.num_prefill_groups > 0 and
17211721
# the len of scheduler_outputs.scheduled_seq_groups is !=
17221722
# scheduler_outputs.num_prefill_groups, this means that

vllm/engine/metrics.py

+5
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ def _log_gauge(self, gauge, data: Union[int, float]) -> None:
512512

513513
def _log_counter(self, counter, data: Union[int, float]) -> None:
514514
# Convenience function for logging to counter.
515+
# Prevent ValueError from negative increment
516+
if data < 0:
517+
logger.warning("Skipping negative increment of %g to %s", data,
518+
counter)
519+
return
515520
counter.labels(**self.labels).inc(data)
516521

517522
def _log_counter_labels(self, counter, data: CollectionsCounter,

0 commit comments

Comments
 (0)