-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathtorchao.tsx
342 lines (316 loc) · 10.7 KB
/
torchao.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import { Divider, Skeleton, Stack, Typography } from "@mui/material";
import { BranchAndCommitPicker } from "components/benchmark/BranchAndCommitPicker";
import { CommitPanel } from "components/benchmark/CommitPanel";
import { LAST_N_DAYS, MAIN_BRANCH } from "components/benchmark/common";
import { BenchmarkLogs } from "components/benchmark/compilers/BenchmarkLogs";
import CompilerGraphGroup from "components/benchmark/compilers/CompilerGraphGroup";
import { SummaryPanel } from "components/benchmark/compilers/SummaryPanel";
import { DTypePicker, MODES } from "components/benchmark/ModeAndDTypePicker";
import {
DEFAULT_DEVICE_NAME,
DEFAULT_MODE,
DEFAULT_REPO_NAME,
DISPLAY_NAMES_TO_DEVICE_NAMES,
QUANTIZATIONS,
} from "components/benchmark/torchao/common";
import { SUITES } from "components/benchmark/torchao/SuitePicker";
import CopyLink from "components/common/CopyLink";
import GranularityPicker from "components/common/GranularityPicker";
import { Granularity } from "components/metrics/panels/TimeSeriesPanel";
import dayjs from "dayjs";
import { convertToCompilerPerformanceData } from "lib/benchmark/compilerUtils";
import { fetcher } from "lib/GeneralUtils";
import { BranchAndCommit } from "lib/types";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import useSWR from "swr";
import { COMPILER_SUITES_MAP } from "../../lib/benchmark/compliers/CompilerSuites";
import { TimeRangePicker } from "../metrics";
function Report({
queryParams,
startTime,
stopTime,
granularity,
mode,
dtype,
deviceName,
lBranchAndCommit,
rBranchAndCommit,
}: {
queryParams: { [key: string]: any };
startTime: dayjs.Dayjs;
stopTime: dayjs.Dayjs;
granularity: Granularity;
mode: string;
dtype: string;
deviceName: string;
lBranchAndCommit: BranchAndCommit;
rBranchAndCommit: BranchAndCommit;
}) {
const queryName = "torchao_query";
const queryParamsWithL: { [key: string]: any } = {
...queryParams,
branches: [lBranchAndCommit.branch],
commits: lBranchAndCommit.commit ? [lBranchAndCommit.commit] : [],
};
const lUrl = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
JSON.stringify(queryParamsWithL)
)}`;
let { data: lData, error: _lError } = useSWR(lUrl, fetcher, {
refreshInterval: 60 * 60 * 1000, // refresh every hour
});
const queryParamsWithR: { [key: string]: any } = {
...queryParams,
branches: [rBranchAndCommit.branch],
commits: rBranchAndCommit.commit ? [rBranchAndCommit.commit] : [],
};
const rUrl = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
JSON.stringify(queryParamsWithR)
)}`;
let { data: rData, error: _rError } = useSWR(rUrl, fetcher, {
refreshInterval: 60 * 60 * 1000, // refresh every hour
});
if (
lData === undefined ||
lData.length === 0 ||
rData === undefined ||
rData.length === 0
) {
return <Skeleton variant={"rectangular"} height={"100%"} />;
}
lData = convertToCompilerPerformanceData(lData);
rData = convertToCompilerPerformanceData(rData);
return (
<div>
<CommitPanel
repoName={DEFAULT_REPO_NAME}
lBranchAndCommit={{
...lBranchAndCommit,
date: lData[0].granularity_bucket,
}}
rBranchAndCommit={{
...rBranchAndCommit,
date:
rData !== undefined && rData.length !== 0
? rData[0].granularity_bucket
: undefined,
}}
workflowName={"Torchao nightly workflow (A100)".toLowerCase()}
>
<BenchmarkLogs workflowId={lData[0].workflow_id} />
</CommitPanel>
<SummaryPanel
dashboard={"torchao"}
startTime={startTime}
stopTime={stopTime}
granularity={granularity}
mode={mode}
dtype={dtype}
deviceName={deviceName}
lPerfData={{
...lBranchAndCommit,
data: lData,
}}
rPerfData={{
...rBranchAndCommit,
data: rData,
}}
all_suites={SUITES}
/>
{Array.from(Object.values(COMPILER_SUITES_MAP)).map((suiteConfig) => {
return (
suiteConfig.showGraph && (
<div key={suiteConfig.id}>
<CompilerGraphGroup
dashboard={"torchao"}
suiteConfig={suiteConfig}
queryParams={queryParams}
granularity={granularity}
lBranchAndCommit={lBranchAndCommit}
rBranchAndCommit={rBranchAndCommit}
/>
</div>
)
);
})}
</div>
);
}
export default function Page() {
const router = useRouter();
const defaultStartTime = dayjs().subtract(LAST_N_DAYS, "day");
const [startTime, setStartTime] = useState(defaultStartTime);
const defaultStopTime = dayjs();
const [stopTime, setStopTime] = useState(defaultStopTime);
const [timeRange, setTimeRange] = useState<number>(LAST_N_DAYS);
const [granularity, setGranularity] = useState<Granularity>("hour");
const [suite, setSuite] = useState<string>(Object.keys(SUITES)[0]);
const [mode, setMode] = useState<string>(DEFAULT_MODE);
const [dtype, setDType] = useState<string>(QUANTIZATIONS[0]);
const [lBranch, setLBranch] = useState<string>(MAIN_BRANCH);
const [lCommit, setLCommit] = useState<string>("");
const [rBranch, setRBranch] = useState<string>(MAIN_BRANCH);
const [rCommit, setRCommit] = useState<string>("");
const [baseUrl, setBaseUrl] = useState<string>("");
const [deviceName, setDeviceName] = useState<string>(DEFAULT_DEVICE_NAME);
// Set the dropdown value what is in the param
useEffect(() => {
const startTime: string = (router.query.startTime as string) ?? undefined;
if (startTime !== undefined) {
setStartTime(dayjs(startTime));
if (dayjs(startTime).valueOf() !== defaultStartTime.valueOf()) {
setTimeRange(-1);
}
}
const stopTime: string = (router.query.stopTime as string) ?? undefined;
if (stopTime !== undefined) {
setStopTime(dayjs(stopTime));
if (dayjs(stopTime).valueOf() !== defaultStopTime.valueOf()) {
setTimeRange(-1);
}
}
const granularity: Granularity =
(router.query.granularity as Granularity) ?? undefined;
if (granularity !== undefined) {
setGranularity(granularity);
}
const suite: string = (router.query.suite as string) ?? undefined;
if (suite !== undefined) {
setSuite(suite);
}
const mode: string = (router.query.mode as string) ?? undefined;
if (mode !== undefined) {
setMode(mode);
}
const dtype: string = (router.query.dtype as string) ?? undefined;
if (dtype !== undefined) {
setDType(dtype);
}
const deviceName: string = (router.query.deviceName as string) ?? undefined;
if (deviceName !== undefined) {
setDeviceName(deviceName);
}
const lBranch: string = (router.query.lBranch as string) ?? undefined;
if (lBranch !== undefined) {
setLBranch(lBranch);
}
const lCommit: string = (router.query.lCommit as string) ?? undefined;
if (lCommit !== undefined) {
setLCommit(lCommit);
}
const rBranch: string = (router.query.rBranch as string) ?? undefined;
if (rBranch !== undefined) {
setRBranch(rBranch);
}
const rCommit: string = (router.query.rCommit as string) ?? undefined;
if (rCommit !== undefined) {
setRCommit(rCommit);
}
setBaseUrl(
`${window.location.protocol}//${
window.location.host
}${router.asPath.replace(/\?.+/, "")}`
);
}, [router.query]);
const queryParams: { [key: string]: any } = {
branches: [],
commits: [],
compilers: [],
device: DISPLAY_NAMES_TO_DEVICE_NAMES[deviceName],
dtypes: [dtype],
granularity: granularity,
mode: mode,
repo: DEFAULT_REPO_NAME,
startTime: dayjs(startTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
stopTime: dayjs(stopTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
suites: Object.keys(SUITES),
workflowId: 0,
};
return (
<div>
<Stack direction="row" spacing={2} sx={{ mb: 2 }}>
<Typography fontSize={"2rem"} fontWeight={"bold"}>
TorchAO Performance DashBoard
</Typography>
<CopyLink
textToCopy={`${baseUrl}?dashboard=torchao&startTime=${encodeURIComponent(
startTime.toString()
)}&stopTime=${encodeURIComponent(
stopTime.toString()
)}&granularity=${granularity}&mode=${mode}&dtype=${dtype}&deviceName=${encodeURIComponent(
deviceName
)}&lBranch=${lBranch}&lCommit=${lCommit}&rBranch=${rBranch}&rCommit=${rCommit}`}
/>
</Stack>
<Stack direction="row" spacing={2} sx={{ mb: 2 }}>
<TimeRangePicker
startTime={startTime}
setStartTime={setStartTime}
stopTime={stopTime}
setStopTime={setStopTime}
timeRange={timeRange}
setTimeRange={setTimeRange}
setGranularity={setGranularity}
/>
<GranularityPicker
granularity={granularity}
setGranularity={setGranularity}
/>
<DTypePicker
dtype={mode}
setDType={setMode}
dtypes={Object.keys(MODES)}
label={"Mode"}
/>
<DTypePicker
dtype={dtype}
setDType={setDType}
dtypes={QUANTIZATIONS}
label={"Quantization"}
/>
<DTypePicker
dtype={deviceName}
setDType={setDeviceName}
dtypes={Object.keys(DISPLAY_NAMES_TO_DEVICE_NAMES)}
label={"Device"}
/>
<BranchAndCommitPicker
queryName={"torchao_query_branches"}
queryParams={queryParams}
branch={rBranch}
setBranch={setRBranch}
commit={rCommit}
setCommit={setRCommit}
titlePrefix={"Base"}
fallbackIndex={-1} // Default to the next to latest in the window
timeRange={timeRange}
/>
<Divider orientation="vertical" flexItem>
—Diff→
</Divider>
<BranchAndCommitPicker
queryName={"torchao_query_branches"}
queryParams={queryParams}
branch={lBranch}
setBranch={setLBranch}
commit={lCommit}
setCommit={setLCommit}
titlePrefix={"New"}
fallbackIndex={0} // Default to the latest commit
timeRange={timeRange}
/>
</Stack>
<Report
queryParams={queryParams}
startTime={startTime}
stopTime={stopTime}
granularity={granularity}
mode={mode}
dtype={dtype}
deviceName={deviceName}
lBranchAndCommit={{ branch: lBranch, commit: lCommit }}
rBranchAndCommit={{ branch: rBranch, commit: rCommit }}
/>
</div>
);
}