1515from experiments .experiment_data import ExperimentData
1616from model_analyzer .state .analyzer_state_manager import AnalyzerStateManager
1717from unittest .mock import MagicMock
18+ from copy import deepcopy
1819
1920
2021class CheckpointExperimentData (ExperimentData ):
@@ -24,18 +25,31 @@ class CheckpointExperimentData(ExperimentData):
2425
2526 def __init__ (self , config ):
2627 super ().__init__ ()
28+ self ._default_run_config = None
2729 self ._load_checkpoint (config )
2830
31+ def get_default_config_dict (self ):
32+ ret = self ._default_run_config .model_run_configs ()[0 ].model_config (
33+ ).to_dict ()
34+ ret = deepcopy (ret )
35+ del ret ["cpu_only" ]
36+ return ret
37+
2938 def _load_checkpoint (self , config ):
3039 state_manager = AnalyzerStateManager (config , MagicMock ())
3140 state_manager .load_checkpoint (checkpoint_required = True )
3241
3342 results = state_manager .get_state_variable ('ResultManager.results' )
43+
3444 model_name = "," .join ([x .model_name () for x in config .profile_models ])
3545 model_measurements = results .get_model_measurements_dict (model_name )
3646 for (run_config ,
3747 run_config_measurements ) in model_measurements .values ():
3848
49+ if run_config .model_variants_name (
50+ ) == model_name + "_config_default" :
51+ self ._default_run_config = run_config
52+
3953 # Due to the way that data is stored in the AnalyzerStateManager, the
4054 # run_config only represents the model configuration used. The
4155 # perf_analyzer information for each measurement associated with it
@@ -46,6 +60,46 @@ def _load_checkpoint(self, config):
4660 for (perf_analyzer_string ,
4761 run_config_measurement ) in run_config_measurements .items ():
4862
63+ run_config_measurement .set_model_config_constraints (
64+ model_config_constraints = [config .constraints ])
65+ run_config_measurement .set_metric_weightings (
66+ metric_objectives = [config .objectives ])
4967 pa_key = self ._make_pa_key_from_cli_string (perf_analyzer_string )
50- self ._add_run_config_measurement_from_keys (
51- ma_key , pa_key , run_config , run_config_measurement )
68+
69+ existing_measurement = self ._get_run_config_measurement_from_keys (
70+ ma_key , pa_key , skip_warn = True )
71+ if not existing_measurement or run_config_measurement > existing_measurement :
72+ self ._add_run_config_measurement_from_keys (
73+ ma_key , pa_key , run_config , run_config_measurement )
74+
75+ if self ._default_run_config is None :
76+ print (f"No default config for { model_name } " )
77+ exit (1 )
78+
79+ self ._print_map ()
80+
81+ def _print_map (self ):
82+ for i in range (0 , 10 ):
83+ row_str = ""
84+ for j in range (0 , 10 ):
85+ instance_count = j + 1
86+ max_batch_size = 2 ** i
87+
88+ ma_key = f"instance_count={ instance_count } ,max_batch_size={ max_batch_size } "
89+
90+ clamped_int = self ._clamp_to_power_of_two (2 * instance_count *
91+ max_batch_size )
92+
93+ pa_key = str (clamped_int )
94+
95+ measurement = self ._get_run_config_measurement_from_keys (
96+ ma_key , pa_key , skip_warn = True )
97+ tput = 0
98+ lat = 0
99+ if measurement :
100+ tput = measurement .get_non_gpu_metric_value (
101+ 'perf_throughput' )
102+ lat = measurement .get_non_gpu_metric_value (
103+ 'perf_latency_p99' )
104+ row_str += f"\t { tput :4.1f} :{ lat :4.1f} "
105+ print (row_str )
0 commit comments