@@ -76,11 +76,14 @@ def __init__(self, labels: List[str], max_model_len: int):
7676 description = "Number of generation tokens processed." ,
7777 kind = pb_utils .MetricFamily .HISTOGRAM ,
7878 )
79- self .histogram_best_of_request_family = pb_utils .MetricFamily (
80- name = "vllm:request_params_best_of" ,
81- description = "Histogram of the best_of request parameter." ,
82- kind = pb_utils .MetricFamily .HISTOGRAM ,
83- )
79+ # TODO: Remove best_of_request when upgrading vLLM >= 0.6.3
80+ self .histogram_best_of_request_family = None
81+ if "best_of_requests" in getattr (VllmStats , "__dataclass_fields__" , {}):
82+ self .histogram_best_of_request_family = pb_utils .MetricFamily (
83+ name = "vllm:request_params_best_of" ,
84+ description = "Histogram of the best_of request parameter." ,
85+ kind = pb_utils .MetricFamily .HISTOGRAM ,
86+ )
8487 self .histogram_n_request_family = pb_utils .MetricFamily (
8588 name = "vllm:request_params_n" ,
8689 description = "Histogram of the n request parameter." ,
@@ -159,10 +162,14 @@ def __init__(self, labels: List[str], max_model_len: int):
159162 buckets = build_1_2_5_buckets (max_model_len ),
160163 )
161164 )
162- self .histogram_best_of_request = self .histogram_best_of_request_family .Metric (
163- labels = labels ,
164- buckets = [1 , 2 , 5 , 10 , 20 ],
165- )
165+ self .histogram_best_of_request = None
166+ if self .histogram_best_of_request_family is not None :
167+ self .histogram_best_of_request = (
168+ self .histogram_best_of_request_family .Metric (
169+ labels = labels ,
170+ buckets = [1 , 2 , 5 , 10 , 20 ],
171+ )
172+ )
166173 self .histogram_n_request = self .histogram_n_request_family .Metric (
167174 labels = labels ,
168175 buckets = [1 , 2 , 5 , 10 , 20 ],
@@ -247,9 +254,12 @@ def log(self, stats: VllmStats) -> None:
247254 self .metrics .histogram_num_generation_tokens_request ,
248255 stats .num_generation_tokens_requests ,
249256 ),
250- (self .metrics .histogram_best_of_request , stats .best_of_requests ),
251257 (self .metrics .histogram_n_request , stats .n_requests ),
252258 ]
259+ if self .metrics .histogram_best_of_request is not None :
260+ histogram_metrics .append (
261+ (self .metrics .histogram_best_of_request , stats .best_of_requests )
262+ )
253263
254264 for metric , data in counter_metrics :
255265 self ._log_counter (metric , data )
0 commit comments