11#!/usr/bin/python
2- # Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+ # Copyright 2024-2025 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33#
44# Redistribution and use in source and binary forms, with or without
55# modification, are permitted provided that the following conditions
@@ -114,7 +114,7 @@ def callback(user_data, result, error):
114114 def test_ensemble_decoupled (self ):
115115 wait_secs = 1
116116 responses_per_req = 3
117- total_reqs = 3
117+ total_iters = 3
118118 delta = 0.2
119119
120120 # Infer
@@ -133,7 +133,7 @@ def test_ensemble_decoupled(self):
133133 inputs [1 ].set_data_from_numpy (input_data_1 )
134134
135135 # Send requests to ensemble decoupled model
136- for request_num in range (1 , total_reqs + 1 ):
136+ for iter_cnt in range (1 , total_iters + 1 ):
137137 ensemble_model_name = "ensemble"
138138 decoupled_model_name = "async_execute_decouple"
139139 non_decoupled_model_name = "async_execute"
@@ -144,40 +144,40 @@ def test_ensemble_decoupled(self):
144144 # Checks metrics output
145145 histogram_dict = self .get_histogram_metrics (FIRST_RESPONSE_HISTOGRAM )
146146
147- def check_existing_metrics (model_name , wait_secs_per_req , delta ):
148- metric_count = get_histogram_metric_key (
147+ def check_histogram (model_name , request_cnt , wait_secs_per_req , delta ):
148+ histogram_count_key = get_histogram_metric_key (
149149 FIRST_RESPONSE_HISTOGRAM , model_name , "1" , "count"
150150 )
151- metric_sum = get_histogram_metric_key (
151+ histogram_sum_key = get_histogram_metric_key (
152152 FIRST_RESPONSE_HISTOGRAM , model_name , "1" , "sum"
153153 )
154154 # Test histogram count
155- self .assertIn (metric_count , histogram_dict )
156- self .assertEqual (histogram_dict [metric_count ], request_num )
155+ self .assertIn (histogram_count_key , histogram_dict )
156+ self .assertEqual (
157+ histogram_dict [histogram_count_key ], request_cnt * iter_cnt
158+ )
157159 # Test histogram sum
158- self .assertIn (metric_sum , histogram_dict )
160+ self .assertIn (histogram_sum_key , histogram_dict )
159161 self .assertTrue (
160- wait_secs_per_req * MILLIS_PER_SEC * request_num
161- <= histogram_dict [metric_sum ]
162- < (wait_secs_per_req + delta ) * MILLIS_PER_SEC * request_num
162+ wait_secs_per_req * MILLIS_PER_SEC * request_cnt * iter_cnt
163+ <= histogram_dict [histogram_sum_key ]
164+ < (wait_secs_per_req + delta )
165+ * MILLIS_PER_SEC
166+ * request_cnt
167+ * iter_cnt
163168 )
164169 # Prometheus histogram buckets are tested in metrics_api_test.cc::HistogramAPIHelper
165170
166171 # Test ensemble model metrics
167- check_existing_metrics (ensemble_model_name , 2 * wait_secs , 2 * delta )
172+ check_histogram (ensemble_model_name , 1 , wait_secs * 2 , 2 * delta )
168173
169174 # Test decoupled model metrics
170- check_existing_metrics (decoupled_model_name , wait_secs , delta )
175+ check_histogram (decoupled_model_name , 1 , wait_secs , delta )
171176
172177 # Test non-decoupled model metrics
173- non_decoupled_model_count = get_histogram_metric_key (
174- FIRST_RESPONSE_HISTOGRAM , non_decoupled_model_name , "1" , "count"
175- )
176- non_decoupled_model_sum = get_histogram_metric_key (
177- FIRST_RESPONSE_HISTOGRAM , non_decoupled_model_name , "1" , "sum"
178+ check_histogram (
179+ non_decoupled_model_name , responses_per_req , wait_secs , delta
178180 )
179- self .assertNotIn (non_decoupled_model_count , histogram_dict )
180- self .assertNotIn (non_decoupled_model_sum , histogram_dict )
181181
182182 def test_buckets_override (self ):
183183 model_name = "async_execute_decouple"
0 commit comments