triton-model-analyzer 1.48.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- model_analyzer/__init__.py +15 -0
- model_analyzer/analyzer.py +448 -0
- model_analyzer/cli/__init__.py +15 -0
- model_analyzer/cli/cli.py +193 -0
- model_analyzer/config/__init__.py +15 -0
- model_analyzer/config/generate/__init__.py +15 -0
- model_analyzer/config/generate/automatic_model_config_generator.py +164 -0
- model_analyzer/config/generate/base_model_config_generator.py +352 -0
- model_analyzer/config/generate/brute_plus_binary_parameter_search_run_config_generator.py +164 -0
- model_analyzer/config/generate/brute_run_config_generator.py +154 -0
- model_analyzer/config/generate/concurrency_sweeper.py +75 -0
- model_analyzer/config/generate/config_generator_interface.py +52 -0
- model_analyzer/config/generate/coordinate.py +143 -0
- model_analyzer/config/generate/coordinate_data.py +86 -0
- model_analyzer/config/generate/generator_utils.py +116 -0
- model_analyzer/config/generate/manual_model_config_generator.py +187 -0
- model_analyzer/config/generate/model_config_generator_factory.py +92 -0
- model_analyzer/config/generate/model_profile_spec.py +74 -0
- model_analyzer/config/generate/model_run_config_generator.py +154 -0
- model_analyzer/config/generate/model_variant_name_manager.py +150 -0
- model_analyzer/config/generate/neighborhood.py +536 -0
- model_analyzer/config/generate/optuna_plus_concurrency_sweep_run_config_generator.py +141 -0
- model_analyzer/config/generate/optuna_run_config_generator.py +838 -0
- model_analyzer/config/generate/perf_analyzer_config_generator.py +312 -0
- model_analyzer/config/generate/quick_plus_concurrency_sweep_run_config_generator.py +130 -0
- model_analyzer/config/generate/quick_run_config_generator.py +753 -0
- model_analyzer/config/generate/run_config_generator_factory.py +329 -0
- model_analyzer/config/generate/search_config.py +112 -0
- model_analyzer/config/generate/search_dimension.py +73 -0
- model_analyzer/config/generate/search_dimensions.py +85 -0
- model_analyzer/config/generate/search_parameter.py +49 -0
- model_analyzer/config/generate/search_parameters.py +388 -0
- model_analyzer/config/input/__init__.py +15 -0
- model_analyzer/config/input/config_command.py +483 -0
- model_analyzer/config/input/config_command_profile.py +1747 -0
- model_analyzer/config/input/config_command_report.py +267 -0
- model_analyzer/config/input/config_defaults.py +236 -0
- model_analyzer/config/input/config_enum.py +83 -0
- model_analyzer/config/input/config_field.py +216 -0
- model_analyzer/config/input/config_list_generic.py +112 -0
- model_analyzer/config/input/config_list_numeric.py +151 -0
- model_analyzer/config/input/config_list_string.py +111 -0
- model_analyzer/config/input/config_none.py +71 -0
- model_analyzer/config/input/config_object.py +129 -0
- model_analyzer/config/input/config_primitive.py +81 -0
- model_analyzer/config/input/config_status.py +75 -0
- model_analyzer/config/input/config_sweep.py +83 -0
- model_analyzer/config/input/config_union.py +113 -0
- model_analyzer/config/input/config_utils.py +128 -0
- model_analyzer/config/input/config_value.py +243 -0
- model_analyzer/config/input/objects/__init__.py +15 -0
- model_analyzer/config/input/objects/config_model_profile_spec.py +325 -0
- model_analyzer/config/input/objects/config_model_report_spec.py +173 -0
- model_analyzer/config/input/objects/config_plot.py +198 -0
- model_analyzer/config/input/objects/config_protobuf_utils.py +101 -0
- model_analyzer/config/input/yaml_config_validator.py +82 -0
- model_analyzer/config/run/__init__.py +15 -0
- model_analyzer/config/run/model_run_config.py +313 -0
- model_analyzer/config/run/run_config.py +168 -0
- model_analyzer/constants.py +76 -0
- model_analyzer/device/__init__.py +15 -0
- model_analyzer/device/device.py +24 -0
- model_analyzer/device/gpu_device.py +87 -0
- model_analyzer/device/gpu_device_factory.py +248 -0
- model_analyzer/entrypoint.py +307 -0
- model_analyzer/log_formatter.py +65 -0
- model_analyzer/model_analyzer_exceptions.py +24 -0
- model_analyzer/model_manager.py +255 -0
- model_analyzer/monitor/__init__.py +15 -0
- model_analyzer/monitor/cpu_monitor.py +69 -0
- model_analyzer/monitor/dcgm/DcgmDiag.py +191 -0
- model_analyzer/monitor/dcgm/DcgmFieldGroup.py +83 -0
- model_analyzer/monitor/dcgm/DcgmGroup.py +815 -0
- model_analyzer/monitor/dcgm/DcgmHandle.py +141 -0
- model_analyzer/monitor/dcgm/DcgmJsonReader.py +69 -0
- model_analyzer/monitor/dcgm/DcgmReader.py +623 -0
- model_analyzer/monitor/dcgm/DcgmStatus.py +57 -0
- model_analyzer/monitor/dcgm/DcgmSystem.py +412 -0
- model_analyzer/monitor/dcgm/__init__.py +15 -0
- model_analyzer/monitor/dcgm/common/__init__.py +13 -0
- model_analyzer/monitor/dcgm/common/dcgm_client_cli_parser.py +194 -0
- model_analyzer/monitor/dcgm/common/dcgm_client_main.py +86 -0
- model_analyzer/monitor/dcgm/dcgm_agent.py +887 -0
- model_analyzer/monitor/dcgm/dcgm_collectd_plugin.py +369 -0
- model_analyzer/monitor/dcgm/dcgm_errors.py +395 -0
- model_analyzer/monitor/dcgm/dcgm_field_helpers.py +546 -0
- model_analyzer/monitor/dcgm/dcgm_fields.py +815 -0
- model_analyzer/monitor/dcgm/dcgm_fields_collectd.py +671 -0
- model_analyzer/monitor/dcgm/dcgm_fields_internal.py +29 -0
- model_analyzer/monitor/dcgm/dcgm_fluentd.py +45 -0
- model_analyzer/monitor/dcgm/dcgm_monitor.py +138 -0
- model_analyzer/monitor/dcgm/dcgm_prometheus.py +326 -0
- model_analyzer/monitor/dcgm/dcgm_structs.py +2357 -0
- model_analyzer/monitor/dcgm/dcgm_telegraf.py +65 -0
- model_analyzer/monitor/dcgm/dcgm_value.py +151 -0
- model_analyzer/monitor/dcgm/dcgmvalue.py +155 -0
- model_analyzer/monitor/dcgm/denylist_recommendations.py +573 -0
- model_analyzer/monitor/dcgm/pydcgm.py +47 -0
- model_analyzer/monitor/monitor.py +143 -0
- model_analyzer/monitor/remote_monitor.py +137 -0
- model_analyzer/output/__init__.py +15 -0
- model_analyzer/output/file_writer.py +63 -0
- model_analyzer/output/output_writer.py +42 -0
- model_analyzer/perf_analyzer/__init__.py +15 -0
- model_analyzer/perf_analyzer/genai_perf_config.py +206 -0
- model_analyzer/perf_analyzer/perf_analyzer.py +882 -0
- model_analyzer/perf_analyzer/perf_config.py +479 -0
- model_analyzer/plots/__init__.py +15 -0
- model_analyzer/plots/detailed_plot.py +266 -0
- model_analyzer/plots/plot_manager.py +224 -0
- model_analyzer/plots/simple_plot.py +213 -0
- model_analyzer/record/__init__.py +15 -0
- model_analyzer/record/gpu_record.py +68 -0
- model_analyzer/record/metrics_manager.py +887 -0
- model_analyzer/record/record.py +280 -0
- model_analyzer/record/record_aggregator.py +256 -0
- model_analyzer/record/types/__init__.py +15 -0
- model_analyzer/record/types/cpu_available_ram.py +93 -0
- model_analyzer/record/types/cpu_used_ram.py +93 -0
- model_analyzer/record/types/gpu_free_memory.py +96 -0
- model_analyzer/record/types/gpu_power_usage.py +107 -0
- model_analyzer/record/types/gpu_total_memory.py +96 -0
- model_analyzer/record/types/gpu_used_memory.py +96 -0
- model_analyzer/record/types/gpu_utilization.py +108 -0
- model_analyzer/record/types/inter_token_latency_avg.py +60 -0
- model_analyzer/record/types/inter_token_latency_base.py +74 -0
- model_analyzer/record/types/inter_token_latency_max.py +60 -0
- model_analyzer/record/types/inter_token_latency_min.py +60 -0
- model_analyzer/record/types/inter_token_latency_p25.py +60 -0
- model_analyzer/record/types/inter_token_latency_p50.py +60 -0
- model_analyzer/record/types/inter_token_latency_p75.py +60 -0
- model_analyzer/record/types/inter_token_latency_p90.py +60 -0
- model_analyzer/record/types/inter_token_latency_p95.py +60 -0
- model_analyzer/record/types/inter_token_latency_p99.py +60 -0
- model_analyzer/record/types/output_token_throughput.py +105 -0
- model_analyzer/record/types/perf_client_response_wait.py +97 -0
- model_analyzer/record/types/perf_client_send_recv.py +97 -0
- model_analyzer/record/types/perf_latency.py +111 -0
- model_analyzer/record/types/perf_latency_avg.py +60 -0
- model_analyzer/record/types/perf_latency_base.py +74 -0
- model_analyzer/record/types/perf_latency_p90.py +60 -0
- model_analyzer/record/types/perf_latency_p95.py +60 -0
- model_analyzer/record/types/perf_latency_p99.py +60 -0
- model_analyzer/record/types/perf_server_compute_infer.py +97 -0
- model_analyzer/record/types/perf_server_compute_input.py +97 -0
- model_analyzer/record/types/perf_server_compute_output.py +97 -0
- model_analyzer/record/types/perf_server_queue.py +97 -0
- model_analyzer/record/types/perf_throughput.py +105 -0
- model_analyzer/record/types/time_to_first_token_avg.py +60 -0
- model_analyzer/record/types/time_to_first_token_base.py +74 -0
- model_analyzer/record/types/time_to_first_token_max.py +60 -0
- model_analyzer/record/types/time_to_first_token_min.py +60 -0
- model_analyzer/record/types/time_to_first_token_p25.py +60 -0
- model_analyzer/record/types/time_to_first_token_p50.py +60 -0
- model_analyzer/record/types/time_to_first_token_p75.py +60 -0
- model_analyzer/record/types/time_to_first_token_p90.py +60 -0
- model_analyzer/record/types/time_to_first_token_p95.py +60 -0
- model_analyzer/record/types/time_to_first_token_p99.py +60 -0
- model_analyzer/reports/__init__.py +15 -0
- model_analyzer/reports/html_report.py +195 -0
- model_analyzer/reports/pdf_report.py +50 -0
- model_analyzer/reports/report.py +86 -0
- model_analyzer/reports/report_factory.py +62 -0
- model_analyzer/reports/report_manager.py +1376 -0
- model_analyzer/reports/report_utils.py +42 -0
- model_analyzer/result/__init__.py +15 -0
- model_analyzer/result/constraint_manager.py +150 -0
- model_analyzer/result/model_config_measurement.py +354 -0
- model_analyzer/result/model_constraints.py +105 -0
- model_analyzer/result/parameter_search.py +246 -0
- model_analyzer/result/result_manager.py +430 -0
- model_analyzer/result/result_statistics.py +159 -0
- model_analyzer/result/result_table.py +217 -0
- model_analyzer/result/result_table_manager.py +646 -0
- model_analyzer/result/result_utils.py +42 -0
- model_analyzer/result/results.py +277 -0
- model_analyzer/result/run_config_measurement.py +658 -0
- model_analyzer/result/run_config_result.py +210 -0
- model_analyzer/result/run_config_result_comparator.py +110 -0
- model_analyzer/result/sorted_results.py +151 -0
- model_analyzer/state/__init__.py +15 -0
- model_analyzer/state/analyzer_state.py +76 -0
- model_analyzer/state/analyzer_state_manager.py +215 -0
- model_analyzer/triton/__init__.py +15 -0
- model_analyzer/triton/client/__init__.py +15 -0
- model_analyzer/triton/client/client.py +234 -0
- model_analyzer/triton/client/client_factory.py +57 -0
- model_analyzer/triton/client/grpc_client.py +104 -0
- model_analyzer/triton/client/http_client.py +107 -0
- model_analyzer/triton/model/__init__.py +15 -0
- model_analyzer/triton/model/model_config.py +556 -0
- model_analyzer/triton/model/model_config_variant.py +29 -0
- model_analyzer/triton/server/__init__.py +15 -0
- model_analyzer/triton/server/server.py +76 -0
- model_analyzer/triton/server/server_config.py +269 -0
- model_analyzer/triton/server/server_docker.py +229 -0
- model_analyzer/triton/server/server_factory.py +306 -0
- model_analyzer/triton/server/server_local.py +158 -0
- triton_model_analyzer-1.48.0.dist-info/METADATA +52 -0
- triton_model_analyzer-1.48.0.dist-info/RECORD +204 -0
- triton_model_analyzer-1.48.0.dist-info/WHEEL +5 -0
- triton_model_analyzer-1.48.0.dist-info/entry_points.txt +2 -0
- triton_model_analyzer-1.48.0.dist-info/licenses/LICENSE +67 -0
- triton_model_analyzer-1.48.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
from typing import List
|
|
18
|
+
|
|
19
|
+
from model_analyzer.config.input.config_defaults import DEFAULT_MEASUREMENT_MODE
|
|
20
|
+
from model_analyzer.constants import SECONDS_TO_MILLISECONDS_MULTIPLIER
|
|
21
|
+
from model_analyzer.model_analyzer_exceptions import TritonModelAnalyzerException
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PerfAnalyzerConfig:
|
|
25
|
+
"""
|
|
26
|
+
A config class to set arguments to the perf_analyzer.
|
|
27
|
+
An argument set to None will use the perf_analyzer's default.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
perf_analyzer_args = [
|
|
31
|
+
"service-kind",
|
|
32
|
+
"model-signature-name",
|
|
33
|
+
"async",
|
|
34
|
+
"sync",
|
|
35
|
+
"measurement-interval",
|
|
36
|
+
"concurrency-range",
|
|
37
|
+
"request-rate-range",
|
|
38
|
+
"request-distribution",
|
|
39
|
+
"request-intervals",
|
|
40
|
+
"binary-search",
|
|
41
|
+
"num-of-sequences",
|
|
42
|
+
"latency-threshold",
|
|
43
|
+
"max-threads",
|
|
44
|
+
"stability-percentage",
|
|
45
|
+
"max-trials",
|
|
46
|
+
"percentile",
|
|
47
|
+
"input-data",
|
|
48
|
+
"shared-memory",
|
|
49
|
+
"output-shared-memory-size",
|
|
50
|
+
"shape",
|
|
51
|
+
"sequence-length",
|
|
52
|
+
"sequence-id-range",
|
|
53
|
+
"string-length",
|
|
54
|
+
"string-data",
|
|
55
|
+
"measurement-mode",
|
|
56
|
+
"measurement-request-count",
|
|
57
|
+
"streaming",
|
|
58
|
+
"grpc-compression-algorithm",
|
|
59
|
+
"triton-server-directory",
|
|
60
|
+
"model-repository",
|
|
61
|
+
"ssl-grpc-use-ssl",
|
|
62
|
+
"ssl-grpc-root-certifications-file",
|
|
63
|
+
"ssl-grpc-private-key-file",
|
|
64
|
+
"ssl-grpc-certificate-chain-file",
|
|
65
|
+
"ssl-https-verify-peer",
|
|
66
|
+
"ssl-https-verify-host",
|
|
67
|
+
"ssl-https-ca-certificates-file",
|
|
68
|
+
"ssl-https-client-certificate-type",
|
|
69
|
+
"ssl-https-client-certificate-file",
|
|
70
|
+
"ssl-https-private-key-type",
|
|
71
|
+
"ssl-https-private-key-file",
|
|
72
|
+
"collect-metrics",
|
|
73
|
+
"metrics-url",
|
|
74
|
+
"metrics-interval",
|
|
75
|
+
"bls-composing-models",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
input_to_options = [
|
|
79
|
+
"model-name",
|
|
80
|
+
"model-version",
|
|
81
|
+
"batch-size",
|
|
82
|
+
"url",
|
|
83
|
+
"protocol",
|
|
84
|
+
"latency-report-file",
|
|
85
|
+
"http-header",
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
input_to_verbose = ["verbose", "extra-verbose", "verbose-csv"]
|
|
89
|
+
|
|
90
|
+
additive_args = ["input-data", "shape"]
|
|
91
|
+
|
|
92
|
+
boolean_args = [
|
|
93
|
+
"streaming",
|
|
94
|
+
"async",
|
|
95
|
+
"sync",
|
|
96
|
+
"binary-search",
|
|
97
|
+
"ssl-grpc-use-ssl",
|
|
98
|
+
"collect-metrics",
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
def __init__(self):
|
|
102
|
+
"""
|
|
103
|
+
Construct a PerfAnalyzerConfig
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
self._args = {k: None for k in self.perf_analyzer_args}
|
|
107
|
+
|
|
108
|
+
self._options = {
|
|
109
|
+
"-m": None,
|
|
110
|
+
"-x": None,
|
|
111
|
+
"-b": None,
|
|
112
|
+
"-u": None,
|
|
113
|
+
"-i": None,
|
|
114
|
+
"-f": None,
|
|
115
|
+
"-H": None,
|
|
116
|
+
}
|
|
117
|
+
self._verbose = {"-v": None, "-v -v": None, "--verbose-csv": None}
|
|
118
|
+
|
|
119
|
+
self._input_to_options = {
|
|
120
|
+
"model-name": "-m",
|
|
121
|
+
"model-version": "-x",
|
|
122
|
+
"batch-size": "-b",
|
|
123
|
+
"url": "-u",
|
|
124
|
+
"protocol": "-i",
|
|
125
|
+
"latency-report-file": "-f",
|
|
126
|
+
"http-header": "-H",
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
self._input_to_verbose = {
|
|
130
|
+
"verbose": "-v",
|
|
131
|
+
"extra-verbose": "-v -v",
|
|
132
|
+
"verbose-csv": "--verbose-csv",
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
self._additive_args = {
|
|
136
|
+
(self._input_to_options[k] if k in self._input_to_options else k): None
|
|
137
|
+
for k in self.additive_args
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@classmethod
|
|
141
|
+
def allowed_keys(cls):
|
|
142
|
+
"""
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
list of str
|
|
146
|
+
The keys that are allowed to be
|
|
147
|
+
passed into perf_analyzer
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
return cls.perf_analyzer_args + cls.input_to_options + cls.input_to_verbose
|
|
151
|
+
|
|
152
|
+
@classmethod
|
|
153
|
+
def additive_keys(cls):
|
|
154
|
+
"""
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
list of str
|
|
158
|
+
The keys, within allowed_keys, that are additive
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
return cls.additive_args[:]
|
|
162
|
+
|
|
163
|
+
def update_config(self, params=None):
|
|
164
|
+
"""
|
|
165
|
+
Allows setting values from a params dict
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
params: dict
|
|
170
|
+
keys are allowed args to perf_analyzer
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
if params and type(params) is dict:
|
|
174
|
+
for key in params:
|
|
175
|
+
self[key] = params[key]
|
|
176
|
+
|
|
177
|
+
def update_config_from_profile_config(self, model_name, profile_config):
|
|
178
|
+
"""
|
|
179
|
+
Set common values based on the input profile config
|
|
180
|
+
|
|
181
|
+
Parameters
|
|
182
|
+
----------
|
|
183
|
+
model_name: str
|
|
184
|
+
The name of the model
|
|
185
|
+
profile_config: ConfigCommandProfile
|
|
186
|
+
The configuration of model analyzer for the profile step
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
params = {
|
|
190
|
+
"model-name": model_name,
|
|
191
|
+
"latency-report-file": model_name + "-results.csv",
|
|
192
|
+
"measurement-mode": DEFAULT_MEASUREMENT_MODE,
|
|
193
|
+
"verbose-csv": "--verbose-csv",
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if profile_config.triton_launch_mode == "c_api":
|
|
197
|
+
params.update(
|
|
198
|
+
{
|
|
199
|
+
"service-kind": "triton_c_api",
|
|
200
|
+
"triton-server-directory": profile_config.triton_install_path,
|
|
201
|
+
"model-repository": profile_config.output_model_repository_path,
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
else:
|
|
205
|
+
if profile_config.client_protocol == "http":
|
|
206
|
+
url = profile_config.triton_http_endpoint
|
|
207
|
+
else:
|
|
208
|
+
url = profile_config.triton_grpc_endpoint
|
|
209
|
+
|
|
210
|
+
params.update({"protocol": profile_config.client_protocol, "url": url})
|
|
211
|
+
|
|
212
|
+
metrics_interval = int(
|
|
213
|
+
profile_config.monitoring_interval * SECONDS_TO_MILLISECONDS_MULTIPLIER
|
|
214
|
+
)
|
|
215
|
+
params.update(
|
|
216
|
+
{
|
|
217
|
+
"collect-metrics": "True",
|
|
218
|
+
"metrics-url": profile_config.triton_metrics_url,
|
|
219
|
+
"metrics-interval": metrics_interval,
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
if profile_config.bls_composing_models:
|
|
224
|
+
bls_composing_model_names = ",".join(
|
|
225
|
+
[
|
|
226
|
+
bls_composing_model.model_name()
|
|
227
|
+
for bls_composing_model in profile_config.bls_composing_models
|
|
228
|
+
]
|
|
229
|
+
)
|
|
230
|
+
params.update({"bls-composing-models": bls_composing_model_names})
|
|
231
|
+
|
|
232
|
+
self.update_config(params)
|
|
233
|
+
|
|
234
|
+
@classmethod
|
|
235
|
+
def from_dict(cls, perf_config_dict):
|
|
236
|
+
perf_config = PerfAnalyzerConfig()
|
|
237
|
+
for key in [
|
|
238
|
+
"_args",
|
|
239
|
+
"_options",
|
|
240
|
+
"_verbose",
|
|
241
|
+
"_input_to_verbose",
|
|
242
|
+
"_input_to_options",
|
|
243
|
+
]:
|
|
244
|
+
if key in perf_config_dict:
|
|
245
|
+
setattr(perf_config, key, perf_config_dict[key])
|
|
246
|
+
return perf_config
|
|
247
|
+
|
|
248
|
+
def representation(self):
|
|
249
|
+
"""
|
|
250
|
+
Returns
|
|
251
|
+
-------
|
|
252
|
+
str
|
|
253
|
+
a string representation of the PA config
|
|
254
|
+
that removes values which can vary between
|
|
255
|
+
runs, but should be ignored when determining
|
|
256
|
+
if a previous (checkpointed) run can be used
|
|
257
|
+
"""
|
|
258
|
+
cli_string = self.to_cli_string()
|
|
259
|
+
cli_string = PerfAnalyzerConfig.remove_url_from_cli_string(cli_string)
|
|
260
|
+
cli_string = PerfAnalyzerConfig.remove_mrc_from_cli_string(cli_string)
|
|
261
|
+
|
|
262
|
+
return cli_string
|
|
263
|
+
|
|
264
|
+
def extract_model_specific_parameters(self):
|
|
265
|
+
"""
|
|
266
|
+
Returns a dictionary of the parameters (options+args) that can change
|
|
267
|
+
between the models (in a ModelRunConfig) within a RunConfig
|
|
268
|
+
Returns
|
|
269
|
+
-------
|
|
270
|
+
dict
|
|
271
|
+
A dictionary of parameters and their values
|
|
272
|
+
"""
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
"batch-size": self._options["-b"],
|
|
276
|
+
"concurrency-range": self._args["concurrency-range"],
|
|
277
|
+
"request-rate-range": self._args["request-rate-range"],
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@classmethod
|
|
281
|
+
def remove_url_from_cli_string(cls, cli_string):
|
|
282
|
+
"""
|
|
283
|
+
utility function strips the url from a cli
|
|
284
|
+
string representation
|
|
285
|
+
|
|
286
|
+
Parameters
|
|
287
|
+
----------
|
|
288
|
+
cli_string : str
|
|
289
|
+
The cli string representation
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
perf_str_tokens = cli_string.split(" ")
|
|
293
|
+
|
|
294
|
+
try:
|
|
295
|
+
url_index = perf_str_tokens.index("-u")
|
|
296
|
+
# remove -u and the element that comes after it
|
|
297
|
+
perf_str_tokens.pop(url_index)
|
|
298
|
+
perf_str_tokens.pop(url_index)
|
|
299
|
+
except ValueError:
|
|
300
|
+
# Ignore ValueError exception
|
|
301
|
+
pass
|
|
302
|
+
|
|
303
|
+
return " ".join(perf_str_tokens)
|
|
304
|
+
|
|
305
|
+
@classmethod
|
|
306
|
+
def remove_mrc_from_cli_string(cls, cli_string):
|
|
307
|
+
"""
|
|
308
|
+
utility function strips the measruement request count
|
|
309
|
+
from a cli string representation
|
|
310
|
+
|
|
311
|
+
Parameters
|
|
312
|
+
----------
|
|
313
|
+
cli_string : str
|
|
314
|
+
The cli string representation
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
perf_str_tokens = cli_string.split(" ")
|
|
318
|
+
|
|
319
|
+
mrc_index = [
|
|
320
|
+
i
|
|
321
|
+
for i, s in enumerate(perf_str_tokens)
|
|
322
|
+
if "--measurement-request-count" in s
|
|
323
|
+
]
|
|
324
|
+
|
|
325
|
+
if mrc_index:
|
|
326
|
+
perf_str_tokens.pop(mrc_index[0])
|
|
327
|
+
|
|
328
|
+
return " ".join(perf_str_tokens)
|
|
329
|
+
|
|
330
|
+
def to_cli_string(self, exclude_model_name: bool = False) -> str:
|
|
331
|
+
"""
|
|
332
|
+
Utility function to convert a config into a
|
|
333
|
+
string of arguments to the perf_analyzer with CLI.
|
|
334
|
+
|
|
335
|
+
Returns
|
|
336
|
+
-------
|
|
337
|
+
str
|
|
338
|
+
cli command string consisting of all arguments
|
|
339
|
+
to the perf_analyzer set in the config, without
|
|
340
|
+
the executable name.
|
|
341
|
+
"""
|
|
342
|
+
|
|
343
|
+
# single dashed options, then verbose flags, then main args
|
|
344
|
+
args = []
|
|
345
|
+
args.extend(self._parse_short_options(exclude_model_name))
|
|
346
|
+
args.extend(self._parse_verbose_options())
|
|
347
|
+
args.extend(self._parse_long_options())
|
|
348
|
+
|
|
349
|
+
return " ".join(args)
|
|
350
|
+
|
|
351
|
+
def _parse_short_options(self, exclude_model_name: bool = False) -> List:
|
|
352
|
+
"""
|
|
353
|
+
Parse the perf analyzer single dash options
|
|
354
|
+
"""
|
|
355
|
+
temp_args = []
|
|
356
|
+
for key, value in self._options.items():
|
|
357
|
+
if value:
|
|
358
|
+
if exclude_model_name and key == "-m":
|
|
359
|
+
continue
|
|
360
|
+
|
|
361
|
+
if key in self._additive_args:
|
|
362
|
+
for additive_value in value:
|
|
363
|
+
temp_args.append(f"{key} {additive_value}")
|
|
364
|
+
else:
|
|
365
|
+
temp_args.append(f"{key} {value}")
|
|
366
|
+
return temp_args
|
|
367
|
+
|
|
368
|
+
def _parse_verbose_options(self):
|
|
369
|
+
"""
|
|
370
|
+
Add the verbose flags to the args cli list
|
|
371
|
+
"""
|
|
372
|
+
return [k for k, v in self._verbose.items() if v]
|
|
373
|
+
|
|
374
|
+
def _parse_long_options(self):
|
|
375
|
+
"""
|
|
376
|
+
Parse the perf analyzer long args
|
|
377
|
+
"""
|
|
378
|
+
temp_args = []
|
|
379
|
+
for key, value in self._args.items():
|
|
380
|
+
if key in self.boolean_args:
|
|
381
|
+
temp_args = self._parse_boolean_args(key, value, temp_args)
|
|
382
|
+
elif value:
|
|
383
|
+
if key in self._additive_args:
|
|
384
|
+
if type(value) is list:
|
|
385
|
+
for additive_value in value:
|
|
386
|
+
temp_args.append(f"--{key}={additive_value}")
|
|
387
|
+
elif type(value) is str:
|
|
388
|
+
temp_args.append(f"--{key}={value}")
|
|
389
|
+
else:
|
|
390
|
+
raise TritonModelAnalyzerException(
|
|
391
|
+
f"Unexpected type {type(value)} for perf_analyzer_flag {key}."
|
|
392
|
+
)
|
|
393
|
+
else:
|
|
394
|
+
temp_args.append(f"--{key}={value}")
|
|
395
|
+
return temp_args
|
|
396
|
+
|
|
397
|
+
def _parse_boolean_args(self, key, value, temp_args):
|
|
398
|
+
"""
|
|
399
|
+
Parse perf analyzer long args that should not add a value to the cli string
|
|
400
|
+
"""
|
|
401
|
+
assert type(value) in [
|
|
402
|
+
str,
|
|
403
|
+
type(None),
|
|
404
|
+
], f"Data type for arg {key} must be a (boolean) string instead of {type(value)}"
|
|
405
|
+
if value != None and value.lower() == "true":
|
|
406
|
+
temp_args.append(f"--{key}")
|
|
407
|
+
return temp_args
|
|
408
|
+
|
|
409
|
+
def __getitem__(self, key):
|
|
410
|
+
"""
|
|
411
|
+
Gets an arguments value in config
|
|
412
|
+
|
|
413
|
+
Parameters
|
|
414
|
+
----------
|
|
415
|
+
key : str
|
|
416
|
+
The name of the argument to the perf config
|
|
417
|
+
|
|
418
|
+
Returns
|
|
419
|
+
-------
|
|
420
|
+
object
|
|
421
|
+
The value that the argument is set to in this config
|
|
422
|
+
|
|
423
|
+
Raises
|
|
424
|
+
------
|
|
425
|
+
KeyError
|
|
426
|
+
If argument not found in the config
|
|
427
|
+
"""
|
|
428
|
+
|
|
429
|
+
if key in self._args:
|
|
430
|
+
return self._args[key]
|
|
431
|
+
elif key in self._input_to_options:
|
|
432
|
+
return self._options[self._input_to_options[key]]
|
|
433
|
+
elif key in self._input_to_verbose:
|
|
434
|
+
return self._verbose[self._input_to_verbose[key]]
|
|
435
|
+
else:
|
|
436
|
+
raise TritonModelAnalyzerException(
|
|
437
|
+
f"Key {key} does not exist in perf_analyzer_flags."
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
def __setitem__(self, key, value):
|
|
441
|
+
"""
|
|
442
|
+
Sets an arguments value in config
|
|
443
|
+
after checking if defined/supported.
|
|
444
|
+
|
|
445
|
+
Parameters
|
|
446
|
+
----------
|
|
447
|
+
key : str
|
|
448
|
+
The name of the argument in perf_analyzer
|
|
449
|
+
value : (any)
|
|
450
|
+
The value to which the argument is being set
|
|
451
|
+
|
|
452
|
+
Raises
|
|
453
|
+
------
|
|
454
|
+
TritonModelAnalyzerException
|
|
455
|
+
If key is unsupported or undefined in the
|
|
456
|
+
config class
|
|
457
|
+
"""
|
|
458
|
+
|
|
459
|
+
if key in self._args:
|
|
460
|
+
self._args[key] = value
|
|
461
|
+
elif key in self._input_to_options:
|
|
462
|
+
self._options[self._input_to_options[key]] = value
|
|
463
|
+
elif key in self._input_to_verbose:
|
|
464
|
+
self._verbose[self._input_to_verbose[key]] = value
|
|
465
|
+
else:
|
|
466
|
+
raise TritonModelAnalyzerException(
|
|
467
|
+
f"The argument '{key}' to the perf_analyzer "
|
|
468
|
+
"is not supported by the model analyzer."
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
def __contains__(self, key):
|
|
472
|
+
"""
|
|
473
|
+
Returns
|
|
474
|
+
-------
|
|
475
|
+
True if key is in perf_config i.e. the key is a
|
|
476
|
+
perf config argument
|
|
477
|
+
"""
|
|
478
|
+
|
|
479
|
+
return key in PerfAnalyzerConfig.allowed_keys()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|