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,243 @@
|
|
|
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.
|
|
16
|
+
|
|
17
|
+
from abc import ABC, abstractmethod
|
|
18
|
+
|
|
19
|
+
from model_analyzer.constants import CONFIG_PARSER_FAILURE, CONFIG_PARSER_SUCCESS
|
|
20
|
+
from model_analyzer.model_analyzer_exceptions import TritonModelAnalyzerException
|
|
21
|
+
|
|
22
|
+
from .config_status import ConfigStatus
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ConfigValue(ABC):
|
|
26
|
+
"""
|
|
27
|
+
Parent class for all the types used in the ConfigField.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
preprocess=None,
|
|
33
|
+
required=False,
|
|
34
|
+
validator=None,
|
|
35
|
+
output_mapper=None,
|
|
36
|
+
name=None,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
preprocess : callable or None
|
|
42
|
+
Function be called before setting new values.
|
|
43
|
+
required : bool
|
|
44
|
+
Whether a given config is required or not.
|
|
45
|
+
validator : callable or None
|
|
46
|
+
A validator for the value of the field.
|
|
47
|
+
output_mapper: callable or None
|
|
48
|
+
This callable unifies the output value of this field.
|
|
49
|
+
name : str
|
|
50
|
+
Fully qualified name for this field.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
self._preprocess = preprocess
|
|
54
|
+
self._is_sweepable = False
|
|
55
|
+
self._required = required
|
|
56
|
+
self._validator = validator
|
|
57
|
+
self._output_mapper = output_mapper
|
|
58
|
+
self._name = name
|
|
59
|
+
|
|
60
|
+
@abstractmethod
|
|
61
|
+
def set_value(self, value):
|
|
62
|
+
"""
|
|
63
|
+
Set the value for this field. This method must be implemented in each
|
|
64
|
+
subclass.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
if self._validator:
|
|
68
|
+
config_status = self._validator(value)
|
|
69
|
+
if config_status.status() == CONFIG_PARSER_FAILURE:
|
|
70
|
+
return config_status
|
|
71
|
+
|
|
72
|
+
self._value = value
|
|
73
|
+
|
|
74
|
+
return ConfigStatus(status=CONFIG_PARSER_SUCCESS)
|
|
75
|
+
|
|
76
|
+
def value(self):
|
|
77
|
+
"""
|
|
78
|
+
Get the value of the config field.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
object
|
|
83
|
+
The value of the config field.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
return_result = self._value
|
|
87
|
+
if self._output_mapper:
|
|
88
|
+
return_result = self._output_mapper(return_result)
|
|
89
|
+
|
|
90
|
+
if type(return_result) is dict:
|
|
91
|
+
final_return_result = {}
|
|
92
|
+
for key, value_ in return_result.items():
|
|
93
|
+
if hasattr(value_, "value"):
|
|
94
|
+
final_return_result[key] = value_.value()
|
|
95
|
+
else:
|
|
96
|
+
raise TritonModelAnalyzerException(
|
|
97
|
+
"ConfigObject should always have a "
|
|
98
|
+
'"value" attribute for each value.'
|
|
99
|
+
)
|
|
100
|
+
return_result = final_return_result
|
|
101
|
+
elif type(return_result) is list:
|
|
102
|
+
return_results = []
|
|
103
|
+
for item in return_result:
|
|
104
|
+
if hasattr(item, "value"):
|
|
105
|
+
return_results.append(item.value())
|
|
106
|
+
else:
|
|
107
|
+
return_results.append(item)
|
|
108
|
+
return_result = return_results
|
|
109
|
+
elif hasattr(return_result, "value"):
|
|
110
|
+
return_result = return_result.value()
|
|
111
|
+
|
|
112
|
+
return return_result
|
|
113
|
+
|
|
114
|
+
def raw_value(self):
|
|
115
|
+
return self._value
|
|
116
|
+
|
|
117
|
+
def _is_primitive(self, value):
|
|
118
|
+
"""
|
|
119
|
+
Is the value a primitive type.
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
value : object
|
|
124
|
+
Value to be checked
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
-------
|
|
128
|
+
bool
|
|
129
|
+
True if yes, False if no
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
return not (self._is_dict(value) or self._is_list(value))
|
|
133
|
+
|
|
134
|
+
def _is_string(self, value):
|
|
135
|
+
"""
|
|
136
|
+
Is the value a string.
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
value : object
|
|
141
|
+
Value to be checked
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
bool
|
|
146
|
+
True if yes, False if no
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
return type(value) is str
|
|
150
|
+
|
|
151
|
+
def _is_dict(self, value):
|
|
152
|
+
"""
|
|
153
|
+
Is the value a dictionary.
|
|
154
|
+
|
|
155
|
+
Parameters
|
|
156
|
+
----------
|
|
157
|
+
value : object
|
|
158
|
+
Value to be checked
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
bool
|
|
163
|
+
True if yes, False if no
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
return type(value) is dict
|
|
167
|
+
|
|
168
|
+
def _is_list(self, value):
|
|
169
|
+
"""
|
|
170
|
+
Is the value a list.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
value : object
|
|
175
|
+
Value to be checked
|
|
176
|
+
|
|
177
|
+
Returns
|
|
178
|
+
-------
|
|
179
|
+
bool
|
|
180
|
+
True if yes, False if no
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
return type(value) is list
|
|
184
|
+
|
|
185
|
+
def cli_type(self):
|
|
186
|
+
"""
|
|
187
|
+
Get the corresponding CLI type for this field.
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
-------
|
|
191
|
+
type
|
|
192
|
+
Type to be used for the CLI.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
return self._cli_type
|
|
196
|
+
|
|
197
|
+
def container_type(self):
|
|
198
|
+
"""
|
|
199
|
+
Get the container type for this field.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
ConfigValue
|
|
204
|
+
Container type for the field.
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
return self._type
|
|
208
|
+
|
|
209
|
+
def required(self):
|
|
210
|
+
"""
|
|
211
|
+
Get the 'required' field value
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
bool
|
|
216
|
+
Whether the config field is required or not.
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
return self._required
|
|
220
|
+
|
|
221
|
+
def name(self):
|
|
222
|
+
"""
|
|
223
|
+
Get the fully qualified name for this field.
|
|
224
|
+
|
|
225
|
+
Returns
|
|
226
|
+
-------
|
|
227
|
+
str or None
|
|
228
|
+
Fully qualified name for this field.
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
return self._name
|
|
232
|
+
|
|
233
|
+
def set_name(self, name):
|
|
234
|
+
"""
|
|
235
|
+
Set the name for this field.
|
|
236
|
+
|
|
237
|
+
Parameters
|
|
238
|
+
----------
|
|
239
|
+
name : str
|
|
240
|
+
New name to be set for this field.
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
self._name = name
|
|
@@ -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.
|
|
@@ -0,0 +1,325 @@
|
|
|
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.
|
|
16
|
+
|
|
17
|
+
from model_analyzer.result.model_constraints import ModelConstraints
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ConfigModelProfileSpec:
|
|
21
|
+
"""
|
|
22
|
+
A class representing the configuration used for
|
|
23
|
+
a single model.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
model_name,
|
|
29
|
+
cpu_only=False,
|
|
30
|
+
objectives=None,
|
|
31
|
+
constraints=None,
|
|
32
|
+
weighting=None,
|
|
33
|
+
parameters=None,
|
|
34
|
+
model_config_parameters=None,
|
|
35
|
+
perf_analyzer_flags=None,
|
|
36
|
+
genai_perf_flags=None,
|
|
37
|
+
triton_server_flags=None,
|
|
38
|
+
triton_server_environment=None,
|
|
39
|
+
triton_docker_args=None,
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
model_name : str
|
|
45
|
+
Name used for the model
|
|
46
|
+
cpu_only: bool
|
|
47
|
+
Whether this model should be run on CPU only
|
|
48
|
+
objectives : None or list
|
|
49
|
+
List of the objectives required by the model
|
|
50
|
+
constraints : None or dict
|
|
51
|
+
Constraints required by the model
|
|
52
|
+
weighting: int
|
|
53
|
+
Model weighting
|
|
54
|
+
parameters : None or dict
|
|
55
|
+
Constraints on batch_size and concurrency values need to be
|
|
56
|
+
specified here.
|
|
57
|
+
model_config_parameters : None or dict
|
|
58
|
+
Model config parameters that is used for this model
|
|
59
|
+
perf_analyzer_flags : dict
|
|
60
|
+
The custom perf analyzer configuration
|
|
61
|
+
for this model
|
|
62
|
+
genai_perf_flags : dict
|
|
63
|
+
The custom GenAI perf configuration
|
|
64
|
+
for this model
|
|
65
|
+
triton_server_flags : dict
|
|
66
|
+
The configuration for the triton server instance launched
|
|
67
|
+
for this model
|
|
68
|
+
triton_server_environment: dict
|
|
69
|
+
The environment variables to be set for the tritonserver instances
|
|
70
|
+
launched by model analyzer
|
|
71
|
+
triton_docker_args: dict
|
|
72
|
+
The docker args to be set for the tritonserver instances
|
|
73
|
+
launched by model analyzer
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
self._model_name = model_name
|
|
77
|
+
self._cpu_only = cpu_only
|
|
78
|
+
self._objectives = objectives
|
|
79
|
+
self._constraints = ModelConstraints(constraints)
|
|
80
|
+
self._weighting = weighting
|
|
81
|
+
|
|
82
|
+
self._parameters = parameters
|
|
83
|
+
self._model_config_parameters = model_config_parameters
|
|
84
|
+
self._perf_analyzer_flags = perf_analyzer_flags
|
|
85
|
+
self._genai_perf_flags = genai_perf_flags
|
|
86
|
+
self._triton_server_flags = triton_server_flags
|
|
87
|
+
self._triton_server_environment = triton_server_environment
|
|
88
|
+
self._triton_docker_args = triton_docker_args
|
|
89
|
+
|
|
90
|
+
def cpu_only(self):
|
|
91
|
+
"""
|
|
92
|
+
Returns
|
|
93
|
+
-------
|
|
94
|
+
bool
|
|
95
|
+
Whether this model is run on cpu only
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
return self._cpu_only
|
|
99
|
+
|
|
100
|
+
def objectives(self):
|
|
101
|
+
"""
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
list or None
|
|
105
|
+
A list containing the objectives.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
return self._objectives
|
|
109
|
+
|
|
110
|
+
def constraints(self):
|
|
111
|
+
"""
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
ModelConstraints
|
|
115
|
+
A ModelConstraints object containing the constraints
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
return self._constraints
|
|
119
|
+
|
|
120
|
+
def weighting(self) -> int:
|
|
121
|
+
"""
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
int
|
|
125
|
+
The model weighting
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
return self._weighting
|
|
129
|
+
|
|
130
|
+
def parameters(self):
|
|
131
|
+
"""
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
dict or None
|
|
135
|
+
A dictionary containing the parameters
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
return self._parameters
|
|
139
|
+
|
|
140
|
+
def model_config_parameters(self):
|
|
141
|
+
"""
|
|
142
|
+
Returns
|
|
143
|
+
-------
|
|
144
|
+
dict or None
|
|
145
|
+
A dictionary containing the model config parameters.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
return self._model_config_parameters
|
|
149
|
+
|
|
150
|
+
def model_name(self):
|
|
151
|
+
"""
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
str
|
|
155
|
+
The model name used for this config.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
return self._model_name
|
|
159
|
+
|
|
160
|
+
def perf_analyzer_flags(self):
|
|
161
|
+
"""
|
|
162
|
+
Returns
|
|
163
|
+
-------
|
|
164
|
+
dict:
|
|
165
|
+
the perf_analyzer_flags
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
return self._perf_analyzer_flags
|
|
169
|
+
|
|
170
|
+
def genai_perf_flags(self):
|
|
171
|
+
"""
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
dict:
|
|
175
|
+
the genai_perf_flags
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
return self._genai_perf_flags
|
|
179
|
+
|
|
180
|
+
def triton_server_flags(self):
|
|
181
|
+
"""
|
|
182
|
+
Returns
|
|
183
|
+
-------
|
|
184
|
+
dict:
|
|
185
|
+
the triton_server_flags
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
return self._triton_server_flags
|
|
189
|
+
|
|
190
|
+
def triton_server_environment(self):
|
|
191
|
+
"""
|
|
192
|
+
Returns
|
|
193
|
+
-------
|
|
194
|
+
dict
|
|
195
|
+
The triton server environment
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
return self._triton_server_environment
|
|
199
|
+
|
|
200
|
+
def triton_docker_args(self):
|
|
201
|
+
"""
|
|
202
|
+
Returns
|
|
203
|
+
-------
|
|
204
|
+
dict
|
|
205
|
+
The triton docker args
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
return self._triton_docker_args
|
|
209
|
+
|
|
210
|
+
@staticmethod
|
|
211
|
+
def model_object_to_config_model_profile_spec(value):
|
|
212
|
+
"""
|
|
213
|
+
Converts a ConfigObject to ConfigModelProfileSpec.
|
|
214
|
+
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
value : dict
|
|
218
|
+
A dictionary where the keys are model names
|
|
219
|
+
and the values are ConfigObjects.
|
|
220
|
+
|
|
221
|
+
Returns
|
|
222
|
+
-------
|
|
223
|
+
list
|
|
224
|
+
A list of ConfigModelProfileSpec objects.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
models = []
|
|
228
|
+
for model_name, model_properties in value.items():
|
|
229
|
+
models.append(
|
|
230
|
+
ConfigModelProfileSpec(model_name, **model_properties.value())
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
return models
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
def model_str_to_config_model_profile_spec(model_name):
|
|
237
|
+
"""
|
|
238
|
+
Constructs a ConfigModelProfileSpec from a given
|
|
239
|
+
model_name.
|
|
240
|
+
|
|
241
|
+
Parameters
|
|
242
|
+
----------
|
|
243
|
+
model_name : str
|
|
244
|
+
Name of the model
|
|
245
|
+
|
|
246
|
+
Returns
|
|
247
|
+
-------
|
|
248
|
+
ConfigModelProfileSpec
|
|
249
|
+
ConfigModelProfileSpec object with the given model name.
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
return ConfigModelProfileSpec(model_name)
|
|
253
|
+
|
|
254
|
+
@staticmethod
|
|
255
|
+
def model_list_to_config_model_profile_spec(profile_models):
|
|
256
|
+
"""
|
|
257
|
+
Construct ConfigModelProfileSpec objects from a list of strings.
|
|
258
|
+
|
|
259
|
+
Parameters
|
|
260
|
+
----------
|
|
261
|
+
profile_models : list
|
|
262
|
+
A list of strings containing model names.
|
|
263
|
+
|
|
264
|
+
Returns
|
|
265
|
+
-------
|
|
266
|
+
list
|
|
267
|
+
A list of ConfigModelProfileSpec objects.
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
models = []
|
|
271
|
+
for model_name in profile_models:
|
|
272
|
+
models.append(ConfigModelProfileSpec(model_name))
|
|
273
|
+
return models
|
|
274
|
+
|
|
275
|
+
@staticmethod
|
|
276
|
+
def model_mixed_to_config_model_profile_spec(models):
|
|
277
|
+
"""
|
|
278
|
+
Unifies a mixed list of ConfigModelProfileSpec objects
|
|
279
|
+
and list of ConfigModelProfileSpec objects.
|
|
280
|
+
|
|
281
|
+
Parameters
|
|
282
|
+
----------
|
|
283
|
+
models : list
|
|
284
|
+
A mixed list containing lists or ConfigModelProfileSpec objects.
|
|
285
|
+
|
|
286
|
+
Returns
|
|
287
|
+
-------
|
|
288
|
+
list
|
|
289
|
+
A list only containing ConfigModelProfileSpec objects.
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
new_models = []
|
|
293
|
+
for model in models:
|
|
294
|
+
if type(model.value()) is list:
|
|
295
|
+
for model_i in model.value():
|
|
296
|
+
new_models.append(model_i)
|
|
297
|
+
else:
|
|
298
|
+
new_models.append(model.value())
|
|
299
|
+
return new_models
|
|
300
|
+
|
|
301
|
+
def __repr__(self):
|
|
302
|
+
model_object = {"model_name": self._model_name}
|
|
303
|
+
model_object["cpu_only"] = self._cpu_only
|
|
304
|
+
if self._objectives:
|
|
305
|
+
model_object["objectives"] = self._objectives
|
|
306
|
+
|
|
307
|
+
if self._parameters:
|
|
308
|
+
model_object["parameters"] = self._parameters
|
|
309
|
+
|
|
310
|
+
if self._constraints:
|
|
311
|
+
model_object["constraints"] = self._constraints
|
|
312
|
+
|
|
313
|
+
if self._weighting:
|
|
314
|
+
model_object["weighting"] = self._weighting
|
|
315
|
+
|
|
316
|
+
if self._model_config_parameters:
|
|
317
|
+
model_object["model_config_parameters"] = self._model_config_parameters
|
|
318
|
+
|
|
319
|
+
if self._perf_analyzer_flags:
|
|
320
|
+
model_object["perf_analyzer_flags"] = self._perf_analyzer_flags
|
|
321
|
+
|
|
322
|
+
if self._genai_perf_flags:
|
|
323
|
+
model_object["genai_perf_flags"] = self._genai_perf_flags
|
|
324
|
+
|
|
325
|
+
return str(model_object)
|