2525 OptunaRunConfigGenerator ,
2626)
2727from model_analyzer .config .generate .search_parameters import SearchParameters
28- from model_analyzer .config .input .config_defaults import DEFAULT_BATCH_SIZES
28+ from model_analyzer .config .input .config_defaults import (
29+ DEFAULT_BATCH_SIZES ,
30+ DEFAULT_RUN_CONFIG_MIN_REQUEST_RATE ,
31+ )
2932from model_analyzer .config .input .objects .config_model_profile_spec import (
3033 ConfigModelProfileSpec ,
3134)
@@ -174,9 +177,9 @@ def test_min_number_of_configs_to_search_both(self):
174177 # Since both are specified we will use the larger of the two (trials=6)
175178 self .assertEqual (min_configs_to_search , 6 )
176179
177- def test_create_default_run_config (self ):
180+ def test_create_default_run_config_with_concurrency (self ):
178181 """
179- Test that a default run config is properly created
182+ Test that a default run config with concurrency is properly created
180183 """
181184 default_run_config = self ._rcg ._create_default_run_config ()
182185
@@ -190,9 +193,50 @@ def test_create_default_run_config(self):
190193 perf_config ["concurrency-range" ], 2 * self ._default_max_batch_size
191194 )
192195
193- def test_create_objective_based_run_config (self ):
196+ def test_create_default_run_config_with_request_rate (self ):
197+ """
198+ Test that a default run config with request rate is properly created
199+ """
200+ config = self ._create_config (["--request-rate-search-enable" ])
201+ mock_model_config = MockModelConfig ()
202+ mock_model_config .start ()
203+ model = ModelProfileSpec (
204+ config .profile_models [0 ], config , MagicMock (), MagicMock ()
205+ )
206+ mock_model_config .stop ()
207+ search_parameters = SearchParameters (
208+ model = model ,
209+ config = config ,
210+ )
211+
212+ rcg = OptunaRunConfigGenerator (
213+ config = config ,
214+ state_manager = MagicMock (),
215+ gpu_count = 1 ,
216+ models = self ._mock_models ,
217+ composing_models = [],
218+ model_variant_name_manager = ModelVariantNameManager (),
219+ search_parameters = {"add_sub" : search_parameters },
220+ composing_search_parameters = {},
221+ user_seed = 100 ,
222+ )
223+
224+ default_run_config = rcg ._create_default_run_config ()
225+ self .assertEqual (len (default_run_config .model_run_configs ()), 1 )
226+
227+ model_config = default_run_config .model_run_configs ()[0 ].model_config ()
228+ perf_config = default_run_config .model_run_configs ()[0 ].perf_config ()
229+
230+ self .assertEqual (model_config .to_dict ()["name" ], self ._test_config_dict ["name" ])
231+ self .assertEqual (perf_config ["batch-size" ], DEFAULT_BATCH_SIZES )
232+ self .assertEqual (
233+ perf_config ["request-rate-range" ], DEFAULT_RUN_CONFIG_MIN_REQUEST_RATE
234+ )
235+ self .assertEqual (perf_config ["concurrency-range" ], None )
236+
237+ def test_create_objective_based_run_config_with_concurrency (self ):
194238 """
195- Test that an objective based run config is properly created
239+ Test that an objective based run config with concurrency is properly created
196240 """
197241 trial = self ._rcg ._study .ask ()
198242 trial_objectives = self ._rcg ._create_trial_objectives (trial )
@@ -215,6 +259,47 @@ def test_create_objective_based_run_config(self):
215259 self .assertEqual (perf_config ["batch-size" ], DEFAULT_BATCH_SIZES )
216260 self .assertEqual (perf_config ["concurrency-range" ], 64 )
217261
262+ def test_create_objective_based_run_config_with_request_rate (self ):
263+ """
264+ Test that an objective based run config with request rate is properly created
265+ """
266+ config = self ._create_config (["--request-rate" , "1024,2048" ])
267+ mock_model_config = MockModelConfig ()
268+ mock_model_config .start ()
269+ model = ModelProfileSpec (
270+ config .profile_models [0 ], config , MagicMock (), MagicMock ()
271+ )
272+ mock_model_config .stop ()
273+ search_parameters = SearchParameters (
274+ model = model ,
275+ config = config ,
276+ )
277+
278+ rcg = OptunaRunConfigGenerator (
279+ config = config ,
280+ state_manager = MagicMock (),
281+ gpu_count = 1 ,
282+ models = self ._mock_models ,
283+ composing_models = [],
284+ model_variant_name_manager = ModelVariantNameManager (),
285+ search_parameters = {"add_sub" : search_parameters },
286+ composing_search_parameters = {},
287+ user_seed = 100 ,
288+ )
289+
290+ trial = rcg ._study .ask ()
291+ trial_objectives = rcg ._create_trial_objectives (trial )
292+ run_config = rcg ._create_objective_based_run_config (trial_objectives , None )
293+
294+ model_config = run_config .model_run_configs ()[0 ].model_config ()
295+ perf_config = run_config .model_run_configs ()[0 ].perf_config ()
296+
297+ # These values are the result of using a fixed seed of 100
298+ self .assertEqual (model_config .to_dict ()["name" ], self ._test_config_dict ["name" ])
299+ self .assertEqual (perf_config ["batch-size" ], DEFAULT_BATCH_SIZES )
300+ self .assertEqual (perf_config ["request-rate-range" ], 2048 )
301+ self .assertEqual (perf_config ["concurrency-range" ], None )
302+
218303 def test_create_run_config_with_concurrency_formula (self ):
219304 """
220305 Tests that the concurrency formula option is used correctly
@@ -284,12 +369,10 @@ def test_create_run_bls_config(self):
284369 config = config ,
285370 )
286371 add_search_parameters = SearchParameters (
287- model = add_model ,
288- config = config ,
372+ model = add_model , config = config , is_composing_model = True
289373 )
290374 sub_search_parameters = SearchParameters (
291- model = sub_model ,
292- config = config ,
375+ model = sub_model , config = config , is_composing_model = True
293376 )
294377 rcg = OptunaRunConfigGenerator (
295378 config = config ,
@@ -331,16 +414,16 @@ def test_create_run_bls_config(self):
331414 self .assertEqual (add_model_config .to_dict ()["instanceGroup" ][0 ]["count" ], 3 )
332415 self .assertEqual (
333416 add_model_config .to_dict ()["dynamicBatching" ]["maxQueueDelayMicroseconds" ],
334- "300 " ,
417+ "100 " ,
335418 )
336419
337420 # SUB (composing model)
338421 # =====================================================================
339422 self .assertEqual (sub_model_config .to_dict ()["name" ], "sub" )
340- self .assertEqual (sub_model_config .to_dict ()["instanceGroup" ][0 ]["count" ], 5 )
423+ self .assertEqual (sub_model_config .to_dict ()["instanceGroup" ][0 ]["count" ], 4 )
341424 self .assertEqual (
342425 sub_model_config .to_dict ()["dynamicBatching" ]["maxQueueDelayMicroseconds" ],
343- "500 " ,
426+ "400 " ,
344427 )
345428
346429 def test_create_run_multi_model_config (self ):
0 commit comments