Skip to content

Commit 219c177

Browse files
authored
[PROTON] Add metric percentage features (#4836)
Add Proton feature to print percentage of total model for non-exclusive metrics.
1 parent b8d8ce9 commit 219c177

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

third_party/proton/proton/viewer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def get_min_time_bytes(df, device_info):
105105
def derive_metrics(gf, metrics, raw_metrics, device_info):
106106
derived_metrics = []
107107
original_metrics = []
108+
exclusive_metrics = ["util"] + list(derivable_metrics.keys()) + list(avg_time_factor_dict.factor.keys())
108109
internal_frame_indices = gf.dataframe["device_id"].isna()
109110

110111
def get_time_seconds(df):
@@ -133,6 +134,7 @@ def get_time_seconds(df):
133134
gf.dataframe[f"{metric} (inc)"] = (get_time_seconds(gf.dataframe) /
134135
time_factor_dict.factor[metric_time_unit])
135136
derived_metrics.append(f"{metric} (inc)")
137+
metric_name = match_available_metrics([time_factor_dict.name], raw_metrics)[0]
136138
elif metric in avg_time_factor_dict.factor:
137139
metric_time_unit = avg_time_factor_dict.name + "/" + metric.split("/")[1]
138140
gf.dataframe[f"{metric} (inc)"] = (get_time_seconds(gf.dataframe) / gf.dataframe['count'] /
@@ -141,7 +143,12 @@ def get_time_seconds(df):
141143
derived_metrics.append(f"{metric} (inc)")
142144
else:
143145
original_metrics.append(metric)
144-
146+
if metric not in exclusive_metrics:
147+
single_frame = gf.dataframe[metric_name]
148+
total = gf.dataframe[metric_name].iloc[0]
149+
metric = metric.split("/")[0]
150+
gf.dataframe[f"{metric}/% (inc)"] = (single_frame / total) * 100.0
151+
derived_metrics.append(f"{metric}/% (inc)")
145152
if original_metrics:
146153
original_metrics = match_available_metrics(original_metrics, raw_metrics)
147154
return derived_metrics + original_metrics
@@ -227,6 +234,10 @@ def main():
227234
- flop[<8/16/32/64>]/s, gflop[<8/16/32/64>]/s, tflop[<8/16/32/64>]/s: flops / time
228235
- byte/s, gbyte/s, tbyte/s: bytes / time
229236
- util: max(sum(flops<width>) / peak_flops<width>_time, sum(bytes) / peak_bandwidth_time)
237+
238+
For inclusive metrics (e.g. time) an additional column is printed showing the percentage
239+
each frame is of the full model.
240+
230241
""",
231242
)
232243
argparser.add_argument(

third_party/proton/test/test_viewer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ def test_util():
118118
def test_time_derivation():
119119
derivation_metrics_test(
120120
metrics=["time/s", "time/ms", "time/us", "time/ns"], expected_data={
121-
'time/s (inc)': [0.0004096, 0.0002048, 0.0002048], 'time/ms (inc)': [0.4096, 0.2048, 0.2048],
122-
'time/us (inc)': [409.6, 204.8, 204.8], 'time/ns (inc)': [409600.0, 204800.0, 204800.0]
121+
'time/s (inc)': [0.0004096, 0.0002048, 0.0002048],
122+
'time/ms (inc)': [0.4096, 0.2048, 0.2048],
123+
'time/us (inc)': [409.6, 204.8, 204.8],
124+
'time/ns (inc)': [409600.0, 204800.0, 204800.0],
125+
'time/% (inc)': [100.0, 50.0, 50.0],
123126
}, sample_file=cuda_example_file)
124127

125128

0 commit comments

Comments
 (0)