tensorboard-plugin-profile 2.19.2__cp312-none-win_amd64.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.
- tensorboard_plugin_profile/__init__.py +22 -0
- tensorboard_plugin_profile/convert/_pywrap_profiler_plugin.so +0 -0
- tensorboard_plugin_profile/convert/dcn_collective_stats_proto_to_gviz.py +142 -0
- tensorboard_plugin_profile/convert/diagnostics.py +47 -0
- tensorboard_plugin_profile/convert/inference_stats_proto_to_gviz.py +327 -0
- tensorboard_plugin_profile/convert/input_pipeline_proto_to_gviz.py +567 -0
- tensorboard_plugin_profile/convert/kernel_stats_proto_to_gviz.py +111 -0
- tensorboard_plugin_profile/convert/overview_page_proto_to_gviz.py +310 -0
- tensorboard_plugin_profile/convert/raw_to_tool_data.py +217 -0
- tensorboard_plugin_profile/convert/roofline_model_proto_to_gviz.py +392 -0
- tensorboard_plugin_profile/convert/tf_stats_proto_to_gviz.py +122 -0
- tensorboard_plugin_profile/convert/trace_events_json.py +105 -0
- tensorboard_plugin_profile/integration_tests/tf_mnist.py +100 -0
- tensorboard_plugin_profile/integration_tests/tf_profiler_session.py +40 -0
- tensorboard_plugin_profile/integration_tests/tpu/tensorflow/tpu_tf2_keras_test.py +184 -0
- tensorboard_plugin_profile/profile_plugin.py +1004 -0
- tensorboard_plugin_profile/profile_plugin_loader.py +82 -0
- tensorboard_plugin_profile/protobuf/dcn_collective_info_pb2.py +33 -0
- tensorboard_plugin_profile/protobuf/dcn_slack_analysis_pb2.py +31 -0
- tensorboard_plugin_profile/protobuf/diagnostics_pb2.py +25 -0
- tensorboard_plugin_profile/protobuf/hardware_types_pb2.py +29 -0
- tensorboard_plugin_profile/protobuf/hlo_stats_pb2.py +27 -0
- tensorboard_plugin_profile/protobuf/inference_stats_pb2.py +75 -0
- tensorboard_plugin_profile/protobuf/input_pipeline_pb2.py +41 -0
- tensorboard_plugin_profile/protobuf/kernel_stats_pb2.py +27 -0
- tensorboard_plugin_profile/protobuf/memory_profile_pb2.py +43 -0
- tensorboard_plugin_profile/protobuf/memory_viewer_preprocess_pb2.py +37 -0
- tensorboard_plugin_profile/protobuf/op_metrics_pb2.py +53 -0
- tensorboard_plugin_profile/protobuf/op_profile_pb2.py +37 -0
- tensorboard_plugin_profile/protobuf/op_stats_pb2.py +59 -0
- tensorboard_plugin_profile/protobuf/overview_page_pb2.py +53 -0
- tensorboard_plugin_profile/protobuf/pod_stats_pb2.py +34 -0
- tensorboard_plugin_profile/protobuf/pod_viewer_pb2.py +50 -0
- tensorboard_plugin_profile/protobuf/power_metrics_pb2.py +27 -0
- tensorboard_plugin_profile/protobuf/roofline_model_pb2.py +30 -0
- tensorboard_plugin_profile/protobuf/steps_db_pb2.py +65 -0
- tensorboard_plugin_profile/protobuf/task_pb2.py +26 -0
- tensorboard_plugin_profile/protobuf/tf_data_stats_pb2.py +61 -0
- tensorboard_plugin_profile/protobuf/tf_function_pb2.py +41 -0
- tensorboard_plugin_profile/protobuf/tf_stats_pb2.py +29 -0
- tensorboard_plugin_profile/protobuf/tfstreamz_pb2.py +29 -0
- tensorboard_plugin_profile/protobuf/topology_pb2.py +39 -0
- tensorboard_plugin_profile/protobuf/tpu_input_pipeline_pb2.py +32 -0
- tensorboard_plugin_profile/protobuf/trace_events_old_pb2.py +43 -0
- tensorboard_plugin_profile/protobuf/trace_events_pb2.py +53 -0
- tensorboard_plugin_profile/protobuf/trace_events_raw_pb2.py +34 -0
- tensorboard_plugin_profile/server.py +135 -0
- tensorboard_plugin_profile/standalone/base_plugin.py +52 -0
- tensorboard_plugin_profile/standalone/context.py +22 -0
- tensorboard_plugin_profile/standalone/data_provider.py +32 -0
- tensorboard_plugin_profile/standalone/plugin_asset_util.py +94 -0
- tensorboard_plugin_profile/standalone/plugin_event_multiplexer.py +184 -0
- tensorboard_plugin_profile/standalone/tensorboard_shim.py +31 -0
- tensorboard_plugin_profile/static/bundle.js +124285 -0
- tensorboard_plugin_profile/static/index.html +64 -0
- tensorboard_plugin_profile/static/index.js +3 -0
- tensorboard_plugin_profile/static/materialicons.woff2 +0 -0
- tensorboard_plugin_profile/static/styles.css +1 -0
- tensorboard_plugin_profile/static/trace_viewer_index.html +3902 -0
- tensorboard_plugin_profile/static/trace_viewer_index.js +21534 -0
- tensorboard_plugin_profile/static/zone.js +3558 -0
- tensorboard_plugin_profile/version.py +17 -0
- tensorboard_plugin_profile-2.19.2.dist-info/METADATA +129 -0
- tensorboard_plugin_profile-2.19.2.dist-info/RECORD +67 -0
- tensorboard_plugin_profile-2.19.2.dist-info/WHEEL +5 -0
- tensorboard_plugin_profile-2.19.2.dist-info/entry_points.txt +5 -0
- tensorboard_plugin_profile-2.19.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Entry point for the TensorBoard plugin package for performance profiling.
|
|
16
|
+
|
|
17
|
+
Public submodules:
|
|
18
|
+
summary: Summary-writing ops.
|
|
19
|
+
Private submodules:
|
|
20
|
+
metadata: Global constants and the like.
|
|
21
|
+
plugin: TensorBoard backend plugin.
|
|
22
|
+
"""
|
|
Binary file
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""For conversion of Dcn Collective Stats page protos to GViz DataTables.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
gviz_data_tables = generate_all_chart_tables(dcn_slack_analysis)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import absolute_import
|
|
22
|
+
from __future__ import division
|
|
23
|
+
from __future__ import print_function
|
|
24
|
+
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
import gviz_api
|
|
28
|
+
|
|
29
|
+
from tensorboard_plugin_profile.protobuf import dcn_slack_analysis_pb2
|
|
30
|
+
|
|
31
|
+
_BYTES_TO_GIGABITS_CONVERSION_FACTOR = 8e-9
|
|
32
|
+
_MICRO_TO_SECONDS_CONVERSION_FACTOR = 1e-6
|
|
33
|
+
_BANDWIDTH_CONVERSION_FACTOR = (
|
|
34
|
+
_BYTES_TO_GIGABITS_CONVERSION_FACTOR / _MICRO_TO_SECONDS_CONVERSION_FACTOR
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def convert_bytes_to_human_readable_format(value):
|
|
39
|
+
"""Convert number of bytes to a human readable format (e.g. 10 KB).
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
value: bytes to convert.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
str: Human readable representation of data.
|
|
46
|
+
"""
|
|
47
|
+
suffix_list = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
48
|
+
|
|
49
|
+
base = 1000
|
|
50
|
+
actual_bytes = float(value)
|
|
51
|
+
abs_bytes = abs(actual_bytes)
|
|
52
|
+
|
|
53
|
+
if abs_bytes == 1:
|
|
54
|
+
return "%d Byte" % actual_bytes
|
|
55
|
+
|
|
56
|
+
if abs_bytes < base:
|
|
57
|
+
return "%d Bytes" % actual_bytes
|
|
58
|
+
|
|
59
|
+
unit = base**2
|
|
60
|
+
suffix = suffix_list[0]
|
|
61
|
+
index = 0
|
|
62
|
+
while index < len(suffix_list):
|
|
63
|
+
unit = base ** (index + 2)
|
|
64
|
+
suffix = suffix_list[index]
|
|
65
|
+
if abs_bytes < unit:
|
|
66
|
+
break
|
|
67
|
+
index += 1
|
|
68
|
+
|
|
69
|
+
return "{0} {1}".format(base * actual_bytes / unit, suffix)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def get_dcn_collective_stats_table_args(dcn_slack_analysis):
|
|
73
|
+
"""Creates a gviz DataTable object from DcnSlackAnalysis proto.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
dcn_slack_analysis: dcn_slack_analysis_pb2.DcnSlackAnalysis.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Returns a gviz_api.DataTable
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
table_description = [
|
|
83
|
+
("dcnCollectiveName", "string", "DCN Collective Name"),
|
|
84
|
+
("recvOpName", "string", "Recv Op Name"),
|
|
85
|
+
("sendOpName", "string", "Send Op Name"),
|
|
86
|
+
("slackTime", "number", "Slack Time (ms)"),
|
|
87
|
+
("observedDuration", "number", "Observed Duration (ms)"),
|
|
88
|
+
("stallDuration", "number", "Stall Duration (ms)"),
|
|
89
|
+
("occurrences", "number", "Occurrences"),
|
|
90
|
+
("totalStallDuration", "number", "Aggregated Total Stall (ms)"),
|
|
91
|
+
("dataTransmittedSize", "string", "Data Transmitted Size"),
|
|
92
|
+
("requiredBandwidth", "number", "Required Bandwidth (Gbps)"),
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
data = []
|
|
96
|
+
for slack in dcn_slack_analysis.dcn_slack_summary:
|
|
97
|
+
row = [
|
|
98
|
+
slack.rendezvous,
|
|
99
|
+
slack.recv_op_name,
|
|
100
|
+
slack.send_op_name,
|
|
101
|
+
slack.slack_us / 1000,
|
|
102
|
+
slack.observed_duration_us / 1000,
|
|
103
|
+
slack.stall_duration_us / 1000,
|
|
104
|
+
slack.occurrences,
|
|
105
|
+
(slack.stall_duration_us * slack.occurrences) / 1000,
|
|
106
|
+
convert_bytes_to_human_readable_format(
|
|
107
|
+
slack.bytes_transmitted_over_network
|
|
108
|
+
),
|
|
109
|
+
]
|
|
110
|
+
if slack.slack_us == 0:
|
|
111
|
+
row.append(float(sys.maxsize))
|
|
112
|
+
else:
|
|
113
|
+
row.append(
|
|
114
|
+
(slack.bytes_transmitted_over_network / slack.slack_us)
|
|
115
|
+
* _BANDWIDTH_CONVERSION_FACTOR
|
|
116
|
+
)
|
|
117
|
+
data.append(row)
|
|
118
|
+
|
|
119
|
+
return (table_description, data, [])
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def generate_dcn_collective_stats_table(dcn_slack_analysis):
|
|
123
|
+
(table_description, data, custom_properties) = (
|
|
124
|
+
get_dcn_collective_stats_table_args(dcn_slack_analysis)
|
|
125
|
+
)
|
|
126
|
+
return gviz_api.DataTable(table_description, data, custom_properties)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def generate_all_chart_tables(dcn_slack_analysis):
|
|
130
|
+
"""Converts a DcnSlackAnalysis proto to gviz DataTables."""
|
|
131
|
+
return [
|
|
132
|
+
generate_dcn_collective_stats_table(dcn_slack_analysis),
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def to_json(raw_data):
|
|
137
|
+
"""Converts a serialized DcnCollectiveAnalysis string to json."""
|
|
138
|
+
dcn_slack_analysis = dcn_slack_analysis_pb2.DcnSlackAnalysis()
|
|
139
|
+
dcn_slack_analysis.ParseFromString(raw_data)
|
|
140
|
+
all_chart_tables = generate_all_chart_tables(dcn_slack_analysis)
|
|
141
|
+
json_join = ",".join(x.ToJSon() if x else "{}" for x in all_chart_tables)
|
|
142
|
+
return "[" + json_join + "]"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""For conversion of diagnostics protos to GViz DataTables.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
gviz_data_tables = generate_diagnostics_tables(diag)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import absolute_import
|
|
22
|
+
from __future__ import division
|
|
23
|
+
from __future__ import print_function
|
|
24
|
+
|
|
25
|
+
import gviz_api
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def generate_diagnostics_table(diag):
|
|
29
|
+
"""Creates a diagnostics table from Diagnostics proto.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
diag: An diagnostics_pb2.Diagnostics.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Returns a gviz_api.DataTable
|
|
36
|
+
"""
|
|
37
|
+
table_description = [("severity", "string", "severity"),
|
|
38
|
+
("message", "string", "message")]
|
|
39
|
+
data = []
|
|
40
|
+
for info in diag.info:
|
|
41
|
+
data.append(["INFO", info])
|
|
42
|
+
for warning in diag.warnings:
|
|
43
|
+
data.append(["WARNING", warning])
|
|
44
|
+
for error in diag.errors:
|
|
45
|
+
data.append(["ERROR", error])
|
|
46
|
+
|
|
47
|
+
return gviz_api.DataTable(table_description, data)
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""For conversion of InferenceStats proto to gviz tables.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
gviz_data_tables = generate_all_chart_tables(inference_stats)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import absolute_import
|
|
22
|
+
from __future__ import division
|
|
23
|
+
from __future__ import print_function
|
|
24
|
+
|
|
25
|
+
import gviz_api
|
|
26
|
+
|
|
27
|
+
from tensorboard_plugin_profile.protobuf import inference_stats_pb2
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def pico_to_milli(ps: float) -> float:
|
|
31
|
+
"""Converts picoseconds to milliseconds."""
|
|
32
|
+
return ps / 1e9
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _add_request_details(
|
|
36
|
+
request_detail: inference_stats_pb2.RequestDetail,
|
|
37
|
+
percentile: str,
|
|
38
|
+
request_id: str,
|
|
39
|
+
has_batching: bool,
|
|
40
|
+
is_tpu: bool,
|
|
41
|
+
throughput: str,
|
|
42
|
+
):
|
|
43
|
+
"""Generates the request details row."""
|
|
44
|
+
row = [
|
|
45
|
+
percentile,
|
|
46
|
+
request_id,
|
|
47
|
+
pico_to_milli(request_detail.end_time_ps - request_detail.start_time_ps),
|
|
48
|
+
]
|
|
49
|
+
if has_batching:
|
|
50
|
+
row.append(request_detail.batching_request_size)
|
|
51
|
+
row.append(pico_to_milli(request_detail.batching_request_delay_ps))
|
|
52
|
+
row.append(throughput)
|
|
53
|
+
if is_tpu:
|
|
54
|
+
row.append(pico_to_milli(request_detail.host_preprocessing_ps))
|
|
55
|
+
row.append(pico_to_milli(request_detail.host_runtime_ps))
|
|
56
|
+
row.append(pico_to_milli(request_detail.write_to_device_time_ps))
|
|
57
|
+
row.append(pico_to_milli(request_detail.read_from_device_time_ps))
|
|
58
|
+
row.append(pico_to_milli(request_detail.device_time_ps))
|
|
59
|
+
row.append(pico_to_milli(request_detail.host_postprocessing_ps))
|
|
60
|
+
row.append(pico_to_milli(request_detail.idle_time_ps))
|
|
61
|
+
return row
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _create_request_table(
|
|
65
|
+
per_model_stats: inference_stats_pb2.PerModelInferenceStats,
|
|
66
|
+
sampled_per_model_stats: inference_stats_pb2.SampledPerModelInferenceStatsProto,
|
|
67
|
+
has_batching: bool,
|
|
68
|
+
is_tpu: bool,
|
|
69
|
+
):
|
|
70
|
+
"""Generates the request table."""
|
|
71
|
+
columns = [
|
|
72
|
+
("percentile", "string", "Percentile"),
|
|
73
|
+
("request_id", "string", "Request ID"),
|
|
74
|
+
("latency_ms", "number", "Latency (ms)"),
|
|
75
|
+
]
|
|
76
|
+
if has_batching:
|
|
77
|
+
columns.append(("batching_request_size", "number", "Batching Request Size"))
|
|
78
|
+
columns.append(
|
|
79
|
+
("host_batch_information", "number", "Host Batch Information")
|
|
80
|
+
)
|
|
81
|
+
columns.append(("throughput", "string", "Throughput"))
|
|
82
|
+
if is_tpu:
|
|
83
|
+
columns.append(("host_preprocessing", "number", "Host Preprocessing"))
|
|
84
|
+
columns.append(("host_runtime", "number", "Host Runtime"))
|
|
85
|
+
columns.append(("data_transfer_h2d", "number", "Data transfer H2D"))
|
|
86
|
+
columns.append(("data_transfer_d2h", "number", "Data transfer D2H"))
|
|
87
|
+
columns.append(("device_compute", "number", "Device compute"))
|
|
88
|
+
columns.append(("host_postprocess", "number", "Host Postprocessing"))
|
|
89
|
+
columns.append(("idle_time", "number", "Idle Time"))
|
|
90
|
+
data = []
|
|
91
|
+
for request_detail in sampled_per_model_stats.sampled_requests:
|
|
92
|
+
data.append(
|
|
93
|
+
_add_request_details(
|
|
94
|
+
request_detail,
|
|
95
|
+
"{:.3f}".format(request_detail.percentile),
|
|
96
|
+
"N/A",
|
|
97
|
+
has_batching,
|
|
98
|
+
is_tpu,
|
|
99
|
+
"N/A",
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
for request_detail in per_model_stats.per_batch_size_aggregated_result:
|
|
103
|
+
data.append(
|
|
104
|
+
_add_request_details(
|
|
105
|
+
request_detail.aggregated_request_result,
|
|
106
|
+
"Batch Size {}".format(request_detail.batch_size),
|
|
107
|
+
"N/A",
|
|
108
|
+
has_batching,
|
|
109
|
+
is_tpu,
|
|
110
|
+
"{:.1f}".format(request_detail.batch_throughput),
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
data.append(
|
|
114
|
+
_add_request_details(
|
|
115
|
+
per_model_stats.aggregated_request_detail,
|
|
116
|
+
"Aggregated",
|
|
117
|
+
"N/A",
|
|
118
|
+
has_batching,
|
|
119
|
+
is_tpu,
|
|
120
|
+
"{:.1f}".format(per_model_stats.request_throughput),
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
custom_properties = {
|
|
124
|
+
"throughput": "{:.1f}".format(per_model_stats.request_throughput),
|
|
125
|
+
"averageLatencyMs": "{:.3f}".format(
|
|
126
|
+
per_model_stats.request_average_latency_us / 1e3
|
|
127
|
+
),
|
|
128
|
+
}
|
|
129
|
+
return gviz_api.DataTable(columns, data, custom_properties)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _generate_batch_details(
|
|
133
|
+
batch_detail: inference_stats_pb2.BatchDetail,
|
|
134
|
+
percentile: str,
|
|
135
|
+
batch_id: str,
|
|
136
|
+
throughput: str,
|
|
137
|
+
):
|
|
138
|
+
"""Generates the batch details row."""
|
|
139
|
+
return [
|
|
140
|
+
percentile,
|
|
141
|
+
batch_id,
|
|
142
|
+
pico_to_milli(batch_detail.end_time_ps - batch_detail.start_time_ps),
|
|
143
|
+
batch_detail.padding_amount,
|
|
144
|
+
batch_detail.batch_size_after_padding,
|
|
145
|
+
(batch_detail.batch_size_after_padding - batch_detail.padding_amount)
|
|
146
|
+
/ batch_detail.batch_size_after_padding,
|
|
147
|
+
pico_to_milli(batch_detail.batch_delay_ps),
|
|
148
|
+
throughput,
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _generate_batch_table(
|
|
153
|
+
per_model_stats: inference_stats_pb2.PerModelInferenceStats,
|
|
154
|
+
sampled_per_model_stats: inference_stats_pb2.SampledPerModelInferenceStatsProto,
|
|
155
|
+
model_id_database: inference_stats_pb2.ModelIdDatabase,
|
|
156
|
+
model_id: str,
|
|
157
|
+
):
|
|
158
|
+
"""Generates the batch table."""
|
|
159
|
+
columns = [
|
|
160
|
+
("percentile", "string", "Percentile"),
|
|
161
|
+
("batch_id", "string", "Batch ID"),
|
|
162
|
+
("latency", "number", "Latency (ms)"),
|
|
163
|
+
("padding_amount", "number", "Padding Amount"),
|
|
164
|
+
("batch_size_after_padding", "number", "Batch Size After Padding"),
|
|
165
|
+
("batching_efficiency", "number", "Batch Efficiency"),
|
|
166
|
+
("batch_delay_ms", "number", "Batch Delay (ms)"),
|
|
167
|
+
("throughput", "string", "Throughput"),
|
|
168
|
+
]
|
|
169
|
+
data = []
|
|
170
|
+
properties = {}
|
|
171
|
+
properties["throughput"] = "{:.1f}".format(per_model_stats.batch_throughput)
|
|
172
|
+
properties["averageLatencyMs"] = "{:.3f}".format(
|
|
173
|
+
per_model_stats.batch_average_latency_us / 1e3
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
if model_id in model_id_database.id_to_batching_params:
|
|
177
|
+
params = model_id_database.id_to_batching_params[model_id]
|
|
178
|
+
properties["hasBatchingParam"] = "true"
|
|
179
|
+
properties["batchingParamNumBatchThreads"] = str(params.num_batch_threads)
|
|
180
|
+
properties["batchingParamMaxBatchSize"] = str(params.max_batch_size)
|
|
181
|
+
properties["batchingParamBatchTimeoutMicros"] = str(
|
|
182
|
+
params.batch_timeout_micros
|
|
183
|
+
)
|
|
184
|
+
properties["batchingParamMaxEnqueuedBatches"] = str(
|
|
185
|
+
params.max_enqueued_batches
|
|
186
|
+
)
|
|
187
|
+
properties["batchingParamAllowedBatchSizes"] = str(
|
|
188
|
+
params.allowed_batch_sizes
|
|
189
|
+
)
|
|
190
|
+
else:
|
|
191
|
+
properties["hasBatchingParam"] = "false"
|
|
192
|
+
for batch_detail in sampled_per_model_stats.sampled_batches:
|
|
193
|
+
data.append(
|
|
194
|
+
_generate_batch_details(
|
|
195
|
+
batch_detail,
|
|
196
|
+
"{:.3f}".format(batch_detail.percentile),
|
|
197
|
+
"N/A",
|
|
198
|
+
"N/A",
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
for batch_detail in per_model_stats.per_batch_size_aggregated_result:
|
|
202
|
+
data.append(
|
|
203
|
+
_generate_batch_details(
|
|
204
|
+
batch_detail.aggregated_batch_result,
|
|
205
|
+
"Batch Size {}".format(batch_detail.batch_size),
|
|
206
|
+
"N/A",
|
|
207
|
+
"{:.1f}".format(batch_detail.batch_throughput),
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
data.append(
|
|
211
|
+
_generate_batch_details(
|
|
212
|
+
per_model_stats.aggregated_batch_detail,
|
|
213
|
+
"Aggregated",
|
|
214
|
+
"N/A",
|
|
215
|
+
"{:.1f}".format(per_model_stats.batch_throughput),
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
return gviz_api.DataTable(columns, data, properties)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _generate_tensor_pattern_table(
|
|
222
|
+
per_model_inference_stats: inference_stats_pb2.PerModelInferenceStats,
|
|
223
|
+
tensor_pattern_db: inference_stats_pb2.TensorPatternDatabase,
|
|
224
|
+
):
|
|
225
|
+
"""Generates the tensor pattern table."""
|
|
226
|
+
table_description = [
|
|
227
|
+
("id", "number", "ID"),
|
|
228
|
+
("tensor_pattern", "string", "Tensor Pattern"),
|
|
229
|
+
("count", "number", "Number of Occurrence"),
|
|
230
|
+
("percentile", "string", "Linearize/Delinearize latency"),
|
|
231
|
+
]
|
|
232
|
+
data = []
|
|
233
|
+
for counter, aggregated_result in enumerate(
|
|
234
|
+
per_model_inference_stats.tensor_transfer_aggregated_result.tensor_pattern_results
|
|
235
|
+
):
|
|
236
|
+
tensor_pattern = tensor_pattern_db.tensor_pattern[
|
|
237
|
+
aggregated_result.tensor_pattern_index
|
|
238
|
+
]
|
|
239
|
+
data.append([
|
|
240
|
+
counter,
|
|
241
|
+
tensor_pattern,
|
|
242
|
+
aggregated_result.count,
|
|
243
|
+
aggregated_result.linearize_delinearize_percentile_time,
|
|
244
|
+
])
|
|
245
|
+
return gviz_api.DataTable(table_description, data)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _generate_per_model_inference_table(
|
|
249
|
+
inference_stats: inference_stats_pb2.InferenceStats,
|
|
250
|
+
sorted_model_ids: list[str],
|
|
251
|
+
has_batching: bool,
|
|
252
|
+
is_tpu: bool,
|
|
253
|
+
):
|
|
254
|
+
"""Generates the per model inference table."""
|
|
255
|
+
tables = []
|
|
256
|
+
for model_id in sorted_model_ids:
|
|
257
|
+
try:
|
|
258
|
+
model_index = inference_stats.model_id_db.id_to_index[model_id]
|
|
259
|
+
per_model_stats = inference_stats.inference_stats_per_model[model_index]
|
|
260
|
+
sampled_per_model_stats = inference_stats.sampled_inference_stats.sampled_inference_stats_per_model[
|
|
261
|
+
model_index
|
|
262
|
+
]
|
|
263
|
+
tables.append(
|
|
264
|
+
_create_request_table(
|
|
265
|
+
per_model_stats, sampled_per_model_stats, has_batching, is_tpu
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
if has_batching:
|
|
269
|
+
tables.append(
|
|
270
|
+
_generate_batch_table(
|
|
271
|
+
per_model_stats,
|
|
272
|
+
sampled_per_model_stats,
|
|
273
|
+
inference_stats.model_id_db,
|
|
274
|
+
model_id,
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
if inference_stats.tensor_pattern_db.tensor_pattern:
|
|
278
|
+
tables.append(
|
|
279
|
+
_generate_tensor_pattern_table(
|
|
280
|
+
per_model_stats, inference_stats.tensor_pattern_db
|
|
281
|
+
)
|
|
282
|
+
)
|
|
283
|
+
except KeyError:
|
|
284
|
+
continue
|
|
285
|
+
return tables
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def generate_all_chart_tables(
|
|
289
|
+
inference_stats: inference_stats_pb2.InferenceStats,
|
|
290
|
+
):
|
|
291
|
+
"""Converts a InferenceStats proto to gviz DataTables."""
|
|
292
|
+
sorted_model_ids = [x for x in inference_stats.model_id_db.ids]
|
|
293
|
+
sorted_model_ids.sort()
|
|
294
|
+
has_batching = False
|
|
295
|
+
for _, per_model_stats in inference_stats.inference_stats_per_model.items():
|
|
296
|
+
if per_model_stats.batch_details:
|
|
297
|
+
has_batching = True
|
|
298
|
+
break
|
|
299
|
+
is_tpu = True
|
|
300
|
+
table_properties = {
|
|
301
|
+
"hasBatching": "{}".format(has_batching).lower(),
|
|
302
|
+
"hasTensorPattern": "false",
|
|
303
|
+
}
|
|
304
|
+
columns = [
|
|
305
|
+
("model_name", "string", "Model Name"),
|
|
306
|
+
]
|
|
307
|
+
data = []
|
|
308
|
+
for model_id in sorted_model_ids:
|
|
309
|
+
data.append([model_id])
|
|
310
|
+
return [
|
|
311
|
+
gviz_api.DataTable(columns, data, table_properties),
|
|
312
|
+
*_generate_per_model_inference_table(
|
|
313
|
+
inference_stats,
|
|
314
|
+
sorted_model_ids,
|
|
315
|
+
has_batching,
|
|
316
|
+
is_tpu,
|
|
317
|
+
),
|
|
318
|
+
]
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def to_json(raw_data):
|
|
322
|
+
"""Converts a serialized DcnCollectiveAnalysis string to json."""
|
|
323
|
+
inference_stats = inference_stats_pb2.InferenceStats()
|
|
324
|
+
inference_stats.ParseFromString(raw_data)
|
|
325
|
+
all_chart_tables = generate_all_chart_tables(inference_stats)
|
|
326
|
+
json_join = ",".join(x.ToJSon() if x else "{}" for x in all_chart_tables)
|
|
327
|
+
return "[" + json_join + "]"
|