Skip to content

Commit b30e061

Browse files
authored
Create detailed reports after profile (#691)
* Added new config option to create default detailed reports * Adding documentation * Detailed reports run after profile. Added unit testing * Fix typo * Changing to skip-detailed-reports * Fixing errors in report.md documentation * Changing detailed report sentence
1 parent 66bb4f3 commit b30e061

File tree

8 files changed

+59
-22
lines changed

8 files changed

+59
-22
lines changed

docs/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ cpu_only_composing_models: <comma-delimited-string-list>
230230
# Skips the generation of summary reports and tables
231231
[ skip_summary_reports: <bool> | default: false]
232232
233+
# Skips the generation of detailed reports and tables
234+
[ skip_detailed_reports: <bool> | default: false]
235+
233236
# Number of top configs to show in summary plots
234237
[ num_configs_per_model: <int> | default: 3]
235238

docs/report.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ $ model-analyzer profile --profile-models <list of model names> --checkpoint-dir
3333
The export directory will, by default, contain 3 subdirectories. The summary
3434
report for a model will be located in `[export-path]/reports/summaries/<model name>`. The report will look like the one shown [_here_](../examples/online_summary.pdf).
3535

36-
To disable summary report generation use `--summarize=false` or set the
37-
`summarize` yaml option to `false`.
36+
To disable summary report generation use `--skip-summary-reports` or set the
37+
`skip_summary_reports` yaml option to `false`.
3838

3939
## Detailed Reports
4040

@@ -57,3 +57,7 @@ look like the one shown [_here_](../examples/online_detailed_report.pdf).
5757
See the [**configuring model
5858
analyzer**](./config.md) section for more details on how to configure these
5959
reports.
60+
61+
Detailed reports for the top-N (based on the value of `--num-configs-per-model`) configurations are also generated at the end of `profile`.
62+
To disable detailed report generation after `profile` use `--skip-detailed-reports` or set the
63+
`skip_detailed_reports` yaml option to `false`.

model_analyzer/analyzer.py

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from typing import List, Union, Optional
16-
import sys
16+
import os, sys
1717
from model_analyzer.constants import LOGGER_NAME, PA_ERROR_LOG_FILENAME
1818
from .model_manager import ModelManager
1919
from .result.result_manager import ResultManager
@@ -126,17 +126,9 @@ def profile(self, client: TritonClient, gpus: List[GPUDevice], mode: str,
126126
if not self._config.skip_summary_reports:
127127
self._create_summary_tables(verbose)
128128
self._create_summary_reports(mode)
129+
self._create_detailed_reports()
129130

130-
# TODO-TMA-650: Detailed reporting not supported for multi-model
131-
if not self._config.run_config_profile_models_concurrently_enable:
132-
for model in self._config.profile_models:
133-
logger.info(
134-
self._get_report_command_help_string(
135-
model.model_name()))
136-
137-
if self._metrics_manager.encountered_perf_analyzer_error():
138-
logger.warning(f"Perf Analyzer encountered an error when profiling one or more configurations. " \
139-
f"See {self._config.export_path}/{PA_ERROR_LOG_FILENAME} for further details.\n")
131+
self._check_for_perf_analyzer_errors()
140132

141133
def report(self, mode: str) -> None:
142134
"""
@@ -280,18 +272,28 @@ def _get_num_profiled_configs(self):
280272
])
281273

282274
def _get_report_command_help_string(self, model_name: str) -> str:
283-
top_3_model_config_names = self._get_top_n_model_config_names(
284-
n=3, model_name=model_name)
275+
top_n_model_config_names = self._get_top_n_model_config_names(
276+
n=self._config.num_configs_per_model, model_name=model_name)
285277
return (
286278
f'To generate detailed reports for the '
287-
f'{len(top_3_model_config_names)} best {model_name} configurations, run '
288-
f'`{self._get_report_command_string(top_3_model_config_names)}`')
279+
f'{len(top_n_model_config_names)} best {model_name} configurations, run '
280+
f'`{self._get_report_command_string(top_n_model_config_names)}`')
281+
282+
def _run_report_command(self, model_name: str) -> None:
283+
top_n_model_config_names = self._get_top_n_model_config_names(
284+
n=self._config.num_configs_per_model, model_name=model_name)
285+
top_n_string = ','.join(top_n_model_config_names)
286+
logger.info(
287+
f'Generating detailed reports for the best configurations {top_n_string}:'
288+
)
289+
os.system(
290+
f'{self._get_report_command_string(top_n_model_config_names)}')
289291

290292
def _get_report_command_string(self,
291-
top_3_model_config_names: List[str]) -> str:
293+
top_n_model_config_names: List[str]) -> str:
292294
report_command_string = (f'model-analyzer report '
293295
f'--report-model-configs '
294-
f'{",".join(top_3_model_config_names)}')
296+
f'{",".join(top_n_model_config_names)}')
295297

296298
if self._config.export_path is not None:
297299
report_command_string += (f' --export-path '
@@ -336,3 +338,19 @@ def _multiple_models_in_report_model_config(self) -> bool:
336338
]
337339

338340
return len(set(model_names)) > 1
341+
342+
def _check_for_perf_analyzer_errors(self) -> None:
343+
if self._metrics_manager.encountered_perf_analyzer_error():
344+
logger.warning(f"Perf Analyzer encountered an error when profiling one or more configurations. " \
345+
f"See {self._config.export_path}/{PA_ERROR_LOG_FILENAME} for further details.\n")
346+
347+
def _create_detailed_reports(self) -> None:
348+
# TODO-TMA-650: Detailed reporting not supported for multi-model
349+
if not self._config.run_config_profile_models_concurrently_enable:
350+
for model in self._config.profile_models:
351+
if not self._config.skip_detailed_reports:
352+
self._run_report_command(model.model_name())
353+
else:
354+
logger.info(
355+
self._get_report_command_help_string(
356+
model.model_name()))

model_analyzer/config/input/config_command_profile.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
DEFAULT_FILENAME_SERVER_ONLY, DEFAULT_NUM_CONFIGS_PER_MODEL, DEFAULT_NUM_TOP_MODEL_CONFIGS, \
4747
DEFAULT_INFERENCE_OUTPUT_FIELDS, DEFAULT_REQUEST_RATE_INFERENCE_OUTPUT_FIELDS, \
4848
DEFAULT_GPU_OUTPUT_FIELDS, DEFAULT_REQUEST_RATE_GPU_OUTPUT_FIELDS, DEFAULT_SERVER_OUTPUT_FIELDS, \
49-
DEFAULT_ONLINE_OBJECTIVES, DEFAULT_ONLINE_PLOTS, DEFAULT_OFFLINE_PLOTS, DEFAULT_MODEL_WEIGHTING
49+
DEFAULT_ONLINE_OBJECTIVES, DEFAULT_ONLINE_PLOTS, DEFAULT_OFFLINE_PLOTS, DEFAULT_MODEL_WEIGHTING, \
50+
DEFAULT_SKIP_DETAILED_REPORTS
5051

5152
from model_analyzer.constants import LOGGER_NAME
5253
from model_analyzer.triton.server.server_config import \
@@ -223,6 +224,15 @@ def _fill_config(self):
223224
default_value=DEFAULT_SKIP_SUMMARY_REPORTS,
224225
description=
225226
'Skips the generation of analysis summary reports and tables.'))
227+
self._add_config(
228+
ConfigField(
229+
'skip_detailed_reports',
230+
flags=['--skip-detailed-reports'],
231+
field_type=ConfigPrimitive(bool),
232+
parser_args={'action': 'store_true'},
233+
default_value=DEFAULT_SKIP_DETAILED_REPORTS,
234+
description=
235+
"Skips the generation of detailed summary reports and tables."))
226236

227237
self._add_repository_configs()
228238
self._add_client_configs()

model_analyzer/config/input/config_defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
DEFAULT_LOG_LEVEL = 'INFO'
3434
DEFAULT_GPUS = 'all'
3535
DEFAULT_SKIP_SUMMARY_REPORTS = False
36+
DEFAULT_SKIP_DETAILED_REPORTS = False
3637
DEFAULT_OUTPUT_MODEL_REPOSITORY = os.path.join(os.getcwd(),
3738
'output_model_repository')
3839
DEFAULT_OVERRIDE_OUTPUT_REPOSITORY_FLAG = False

qa/L0_profile/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --triton-metrics-url http://localhost:
5454
MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --output-model-repository-path $OUTPUT_MODEL_REPOSITORY --override-output-model-repository"
5555
MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS -e $EXPORT_PATH --filename-server-only=$FILENAME_SERVER_ONLY"
5656
MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --filename-model-inference=$FILENAME_INFERENCE_MODEL --filename-model-gpu=$FILENAME_GPU_MODEL"
57-
MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --skip-summary-reports"
5857
MODEL_ANALYZER_SUBCOMMAND="profile"
5958
run_analyzer
6059
if [ $? -ne 0 ]; then

tests/test_analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def mock_get_list_of_models(self):
6464
_create_metrics_manager=MagicMock(),
6565
_create_model_manager=MagicMock(),
6666
_get_server_only_metrics=MagicMock(),
67-
_profile_models=MagicMock())
67+
_profile_models=MagicMock(),
68+
_check_for_perf_analyzer_errors=MagicMock())
6869
def test_profile_skip_summary_reports(self, **mocks):
6970
"""
7071
Tests when the skip_summary_reports config option is turned on,

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def get_test_options():
6767
OptionStruct("bool", "profile","--reload-model-disable"),
6868
OptionStruct("bool", "profile","--early-exit-enable"),
6969
OptionStruct("bool", "profile","--skip-summary-reports"),
70+
OptionStruct("bool", "profile","--skip-detailed-reports"),
7071
#Int/Float options
7172
# Options format:
7273
# (int/float, MA step, long_option, short_option, test_value, expected_default_value)

0 commit comments

Comments
 (0)