Spaces:
Running
Running
Commit
·
e77bee6
1
Parent(s):
c035eb4
Update files
Browse files- app.py +82 -12
- results_il-common.csv +0 -0
app.py
CHANGED
@@ -7,11 +7,15 @@ import gradio as gr
|
|
7 |
|
8 |
DATASETS = []
|
9 |
BENCHMARKS = {
|
|
|
10 |
"Parameters": (None, None, None),
|
11 |
-
"
|
12 |
-
"CPU
|
13 |
-
"
|
14 |
-
"
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
|
@@ -35,11 +39,53 @@ def plot_acc_param(param_compare_results_df: pl.DataFrame, width: int = 1000, he
|
|
35 |
return chart.properties(title="Accuray vs Parameter Count", width=width, height=height).configure_scale(zero=False)
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
def plot_acc_rate(rate_compare_results_df: pl.DataFrame, width: int = 1000, height: int = 680) -> alt.LayerChart:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
df = rate_compare_results_df.select(
|
44 |
"Model name",
|
45 |
"Model type",
|
@@ -100,7 +146,9 @@ def update_data(
|
|
100 |
param_compare_results_df = param_compare_results_df.with_columns(
|
101 |
pl.col("Accuracy").cum_max().alias("Pareto frontier (p)")
|
102 |
)
|
103 |
-
param_compare_results_df = param_compare_results_df.drop(
|
|
|
|
|
104 |
chart = plot_acc_param(param_compare_results_df)
|
105 |
|
106 |
x_max = param_compare_results_df["Parameters (M)"].quantile(0.9)
|
@@ -108,18 +156,40 @@ def update_data(
|
|
108 |
chart.layer[0].encoding.x.scale = alt.Scale(domain=[x_min, x_max], type=x_scale_type)
|
109 |
output_df = param_compare_results_df
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
# Rate
|
112 |
else:
|
113 |
(device, amp_enabled, compiled) = BENCHMARKS[benchmark]
|
114 |
-
df = compare_results_df.
|
|
|
115 |
device_compare_results_df = df.unique(subset=["Model name"]).sort("ms / sample", descending=False)
|
|
|
116 |
device_compare_results_df = device_compare_results_df.with_columns(
|
117 |
pl.col("Accuracy").cum_max().alias("Pareto frontier (ms)")
|
118 |
)
|
119 |
chart = plot_acc_rate(device_compare_results_df)
|
120 |
|
121 |
-
x_max = device_compare_results_df["ms / sample"].quantile(0.95)
|
122 |
-
x_min = device_compare_results_df["ms / sample"].min()
|
|
|
|
|
|
|
|
|
123 |
chart.layer[0].encoding.x.scale = alt.Scale(domain=[x_min, x_max], type=x_scale_type)
|
124 |
output_df = device_compare_results_df
|
125 |
|
|
|
7 |
|
8 |
DATASETS = []
|
9 |
BENCHMARKS = {
|
10 |
+
# Name: (device, AMP, compile)
|
11 |
"Parameters": (None, None, None),
|
12 |
+
"GPU Memory": (None, None, None),
|
13 |
+
"CPU rate": ("cpu", False, False),
|
14 |
+
"CPU rate with compile": ("cpu", False, True),
|
15 |
+
"CPU rate AMP with compile": ("cpu", True, True),
|
16 |
+
"CUDA rate": ("cuda", False, False),
|
17 |
+
"CUDA rate with compile": ("cuda", False, True),
|
18 |
+
"CUDA rate AMP with compile": ("cuda", True, True),
|
19 |
}
|
20 |
|
21 |
|
|
|
39 |
return chart.properties(title="Accuray vs Parameter Count", width=width, height=height).configure_scale(zero=False)
|
40 |
|
41 |
|
42 |
+
def plot_acc_memory(memory_compare_results_df: pl.DataFrame, width: int = 900, height: int = 640) -> alt.LayerChart:
|
43 |
+
df = memory_compare_results_df.select(
|
44 |
+
"Model name",
|
45 |
+
"Model type",
|
46 |
+
"Accuracy",
|
47 |
+
"Top-3 accuracy",
|
48 |
+
"Resolution",
|
49 |
+
"Peak GPU memory (MB)",
|
50 |
+
"Parameters (M)",
|
51 |
+
"Pareto frontier (mem)",
|
52 |
+
)
|
53 |
+
base = df.plot.point(
|
54 |
+
x="Peak GPU memory (MB)",
|
55 |
+
y="Accuracy",
|
56 |
+
color="Model type",
|
57 |
+
shape="Resolution:N",
|
58 |
+
tooltip=[
|
59 |
+
"Peak GPU memory (MB)",
|
60 |
+
"Parameters (M)",
|
61 |
+
"Accuracy",
|
62 |
+
"Top-3 accuracy",
|
63 |
+
"Model name",
|
64 |
+
"Model type",
|
65 |
+
"Resolution",
|
66 |
+
],
|
67 |
+
)
|
68 |
+
text = base.mark_text(align="center", baseline="middle", dy=-10).encode(text="Model name")
|
69 |
+
frontier = df.plot.line(x="Peak GPU memory (MB)", y="Pareto frontier (mem)").mark_line(
|
70 |
+
interpolate="step-after", color="red", strokeWidth=0.3, strokeDash=(2, 2)
|
71 |
+
)
|
72 |
+
|
73 |
+
chart = base + text + frontier
|
74 |
+
return chart.properties(title="Accuray vs GPU Memory", width=width, height=height).configure_scale(zero=False)
|
75 |
+
|
76 |
+
|
77 |
def plot_acc_rate(rate_compare_results_df: pl.DataFrame, width: int = 1000, height: int = 680) -> alt.LayerChart:
|
78 |
+
if len(rate_compare_results_df) > 0:
|
79 |
+
device = rate_compare_results_df["device"][0]
|
80 |
+
compiled = rate_compare_results_df["compile"][0]
|
81 |
+
batch_size = rate_compare_results_df["batch_size"][0]
|
82 |
+
amp = rate_compare_results_df["amp"][0]
|
83 |
+
else:
|
84 |
+
device = ""
|
85 |
+
compiled = ""
|
86 |
+
batch_size = ""
|
87 |
+
amp = ""
|
88 |
+
|
89 |
df = rate_compare_results_df.select(
|
90 |
"Model name",
|
91 |
"Model type",
|
|
|
146 |
param_compare_results_df = param_compare_results_df.with_columns(
|
147 |
pl.col("Accuracy").cum_max().alias("Pareto frontier (p)")
|
148 |
)
|
149 |
+
param_compare_results_df = param_compare_results_df.drop(
|
150 |
+
"Samples / sec", "device", "ms / sample", "Peak GPU memory (MB)"
|
151 |
+
)
|
152 |
chart = plot_acc_param(param_compare_results_df)
|
153 |
|
154 |
x_max = param_compare_results_df["Parameters (M)"].quantile(0.9)
|
|
|
156 |
chart.layer[0].encoding.x.scale = alt.Scale(domain=[x_min, x_max], type=x_scale_type)
|
157 |
output_df = param_compare_results_df
|
158 |
|
159 |
+
# Peak memory
|
160 |
+
elif benchmark == "GPU Memory":
|
161 |
+
memory_compare_results_df = compare_results_df.drop_nulls(subset=["Peak GPU memory (MB)"])
|
162 |
+
memory_compare_results_df = memory_compare_results_df.unique(subset=["Model name"]).sort(
|
163 |
+
"Peak GPU memory (MB)", descending=False
|
164 |
+
)
|
165 |
+
memory_compare_results_df = memory_compare_results_df.with_columns(
|
166 |
+
pl.col("Accuracy").cum_max().alias("Pareto frontier (mem)")
|
167 |
+
)
|
168 |
+
memory_compare_results_df = memory_compare_results_df.drop("Samples / sec", "device", "ms / sample")
|
169 |
+
chart = plot_acc_memory(memory_compare_results_df)
|
170 |
+
x_max = memory_compare_results_df["Peak GPU memory (MB)"].quantile(0.9)
|
171 |
+
x_min = memory_compare_results_df["Peak GPU memory (MB)"].quantile(0.1)
|
172 |
+
chart.layer[0].encoding.x.scale = alt.Scale(domain=[x_min, x_max], type=x_scale_type)
|
173 |
+
output_df = memory_compare_results_df
|
174 |
+
|
175 |
# Rate
|
176 |
else:
|
177 |
(device, amp_enabled, compiled) = BENCHMARKS[benchmark]
|
178 |
+
df = compare_results_df.drop_nulls(subset=["ms / sample"])
|
179 |
+
df = df.filter(device=device, amp=amp_enabled, compile=compiled)
|
180 |
device_compare_results_df = df.unique(subset=["Model name"]).sort("ms / sample", descending=False)
|
181 |
+
device_compare_results_df = device_compare_results_df.drop("Peak GPU memory (MB)")
|
182 |
device_compare_results_df = device_compare_results_df.with_columns(
|
183 |
pl.col("Accuracy").cum_max().alias("Pareto frontier (ms)")
|
184 |
)
|
185 |
chart = plot_acc_rate(device_compare_results_df)
|
186 |
|
187 |
+
x_max = device_compare_results_df["ms / sample"].quantile(0.95)
|
188 |
+
x_min = device_compare_results_df["ms / sample"].min()
|
189 |
+
if x_max is not None and x_min is not None:
|
190 |
+
x_max = x_max * 1.04
|
191 |
+
x_min = x_min * 0.96
|
192 |
+
|
193 |
chart.layer[0].encoding.x.scale = alt.Scale(domain=[x_min, x_max], type=x_scale_type)
|
194 |
output_df = device_compare_results_df
|
195 |
|
results_il-common.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|