-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy path[[...page]].tsx
418 lines (391 loc) · 13 KB
/
[[...page]].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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
import { Divider, Grid2, Skeleton, Stack, Typography } from "@mui/material";
import { BranchAndCommitPicker } from "components/benchmark/BranchAndCommitPicker";
import { CommitPanel } from "components/benchmark/CommitPanel";
import {
DASHBOARD_NAME_MAP,
DASHBOARD_QUERY_MAP,
DEFAULT_REPO_NAME,
LAST_N_DAYS,
MAIN_BRANCH,
} from "components/benchmark/common";
import { BenchmarkLogs } from "components/benchmark/compilers/BenchmarkLogs";
import {
COMPILER_NAMES_TO_DISPLAY_NAMES,
DEFAULT_DEVICE_NAME,
DISPLAY_NAMES_TO_DEVICE_NAMES,
DISPLAY_NAMES_TO_WORKFLOW_NAMES,
DTYPES,
} from "components/benchmark/compilers/common";
import { GraphPanel } from "components/benchmark/compilers/ModelGraphPanel";
import { ModelPanel } from "components/benchmark/compilers/ModelPanel";
import {
DEFAULT_MODE,
DTypePicker,
ModePicker,
MODES,
} from "components/benchmark/ModeAndDTypePicker";
import { QUANTIZATIONS } from "components/benchmark/torchao/common";
import CopyLink from "components/common/CopyLink";
import GranularityPicker from "components/common/GranularityPicker";
import { Granularity } from "components/metrics/panels/TimeSeriesPanel";
import dayjs from "dayjs";
import {
augmentData,
convertToCompilerPerformanceData,
} from "lib/benchmark/compilerUtils";
import { fetcher } from "lib/GeneralUtils";
import { BranchAndCommit, CompilerPerformanceData } from "lib/types";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import useSWR from "swr";
import { TimeRangePicker } from "../../../metrics";
function Report({
dashboard,
queryName,
queryParams,
startTime,
stopTime,
granularity,
suite,
mode,
dtype,
deviceName,
compiler,
model,
lBranchAndCommit,
rBranchAndCommit,
}: {
dashboard: string;
queryName: string;
queryParams: { [key: string]: any };
startTime: dayjs.Dayjs;
stopTime: dayjs.Dayjs;
granularity: Granularity;
suite: string;
mode: string;
dtype: string;
deviceName: string;
compiler: string;
model: string;
lBranchAndCommit: BranchAndCommit;
rBranchAndCommit: BranchAndCommit;
}) {
const queryParamsWithL: { [key: string]: any } = {
...queryParams,
branches: [lBranchAndCommit.branch],
commits: [lBranchAndCommit.commit],
getJobId: true,
};
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
});
// TODO (huydhn): Remove this once TorchInductor dashboard is migrated to the
// new database schema
lData =
dashboard === "torchao" ? convertToCompilerPerformanceData(lData) : lData;
lData = augmentData(lData);
lData = lData
? lData.filter((e: CompilerPerformanceData) => e.suite === suite)
: lData;
const queryParamsWithR: { [key: string]: any } = {
...queryParams,
branches: [rBranchAndCommit.branch],
commits: [rBranchAndCommit.commit],
getJobId: true,
};
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
});
// TODO (huydhn): Remove this once TorchInductor dashboard is migrated to the
// new database schema
rData =
dashboard === "torchao" ? convertToCompilerPerformanceData(rData) : rData;
rData = augmentData(rData);
rData = rData
? rData.filter((e: CompilerPerformanceData) => e.suite === suite)
: rData;
if (lData === undefined || lData.length === 0) {
return <Skeleton variant={"rectangular"} height={"100%"} />;
}
return (
<div>
<CommitPanel
repoName={
dashboard === "torchao" ? "pytorch/benchmark" : DEFAULT_REPO_NAME
}
lBranchAndCommit={{
...lBranchAndCommit,
date: lData[0].granularity_bucket,
}}
rBranchAndCommit={{
...rBranchAndCommit,
date:
rData !== undefined && rData.length !== 0
? rData[0].granularity_bucket
: undefined,
}}
workflowName={
dashboard === "torchao"
? "Torchao nightly workflow (A100)".toLowerCase()
: DISPLAY_NAMES_TO_WORKFLOW_NAMES[deviceName]
}
>
<BenchmarkLogs workflowId={lData[0].workflow_id} />
</CommitPanel>
<GraphPanel
queryName={queryName}
queryParams={queryParams}
granularity={granularity}
compiler={compiler}
model={model}
branch={lBranchAndCommit.branch}
lCommit={lBranchAndCommit.commit}
rCommit={rBranchAndCommit.commit}
/>
<ModelPanel
dashboard={dashboard}
startTime={startTime}
stopTime={stopTime}
granularity={granularity}
suite={suite}
mode={mode}
dtype={dtype}
deviceName={deviceName}
compiler={compiler}
model={model}
lPerfData={{
...lBranchAndCommit,
data: lData,
}}
rPerfData={{
...rBranchAndCommit,
data: rData,
}}
/>
</div>
);
}
export default function Page() {
const router = useRouter();
// The dimensions to query
const suite: string = (router.query.suite as string) ?? undefined;
const compiler: string = (router.query.compiler as string) ?? undefined;
const model: string = (router.query.model as string) ?? undefined;
const dashboard: string =
(router.query.dashboard as string) ?? "torchinductor";
const queryName: string =
DASHBOARD_QUERY_MAP[dashboard] ?? "compilers_benchmark_performance";
const branchQueryName = queryName + "_branches";
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 [mode, setMode] = useState<string>(DEFAULT_MODE);
const [dtype, setDType] = useState<string>(MODES[DEFAULT_MODE]);
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 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]);
if (suite === undefined || compiler === undefined) {
return <Skeleton variant={"rectangular"} height={"100%"} />;
}
// TODO (huydhn): Remove this once TorchInductor dashboard is migrated to the
// new database schema
const queryParams: { [key: string]: any } =
dashboard === "torchao"
? {
branches: [],
commits: [],
compilers: [compiler],
device: DISPLAY_NAMES_TO_DEVICE_NAMES[deviceName],
dtypes: [dtype],
granularity: granularity,
mode: mode,
repo: "pytorch/benchmark",
startTime: dayjs(startTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
stopTime: dayjs(stopTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
suites: [],
workflowId: 0,
}
: {
commits: [],
compilers: [compiler],
device: DISPLAY_NAMES_TO_DEVICE_NAMES[deviceName],
dtypes: dtype,
getJobId: false,
granularity: granularity,
mode: mode,
startTime: dayjs(startTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
stopTime: dayjs(stopTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
suites: [],
workflowId: 0,
};
return (
<div>
<Stack direction="row" spacing={2} sx={{ mb: 2 }}>
<Typography fontSize={"2rem"} fontWeight={"bold"}>
{DASHBOARD_NAME_MAP[dashboard]} Performance DashBoard (
{COMPILER_NAMES_TO_DISPLAY_NAMES[compiler] || compiler})
</Typography>
<CopyLink
textToCopy={
`${baseUrl}?dashboard=${dashboard}&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}` +
(model === undefined ? "" : `&model=${model}`)
}
/>
</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}
/>
{dashboard === "torchao" && (
<DTypePicker
dtype={mode}
setDType={setMode}
dtypes={Object.keys(MODES)}
label={"Mode"}
/>
)}
{dashboard === "torchinductor" && (
<ModePicker mode={mode} setMode={setMode} setDType={setDType} />
)}
<DTypePicker
dtype={dtype}
setDType={setDType}
dtypes={dashboard === "torchao" ? QUANTIZATIONS : DTYPES}
label={dashboard === "torchao" ? "Quantization" : "Precision"}
/>
<DTypePicker
dtype={deviceName}
setDType={setDeviceName}
dtypes={Object.keys(DISPLAY_NAMES_TO_DEVICE_NAMES)}
label={"Device"}
/>
<BranchAndCommitPicker
queryName={branchQueryName}
branch={rBranch}
setBranch={setRBranch}
commit={rCommit}
setCommit={setRCommit}
queryParams={queryParams}
titlePrefix={"Base"}
fallbackIndex={-1} // Default to the next to latest in the window
timeRange={timeRange}
/>
<Divider orientation="vertical" flexItem>
—Diff→
</Divider>
<BranchAndCommitPicker
queryName={branchQueryName}
branch={lBranch}
setBranch={setLBranch}
commit={lCommit}
setCommit={setLCommit}
queryParams={queryParams}
titlePrefix={"New"}
fallbackIndex={0} // Default to the latest commit
timeRange={timeRange}
/>
</Stack>
<Grid2 size={{ xs: 12 }}>
<Report
dashboard={dashboard}
queryName={queryName}
queryParams={queryParams}
startTime={startTime}
stopTime={stopTime}
granularity={granularity}
suite={suite}
mode={mode}
dtype={dtype}
deviceName={deviceName}
compiler={compiler}
model={model}
lBranchAndCommit={{ branch: lBranch, commit: lCommit }}
rBranchAndCommit={{ branch: rBranch, commit: rCommit }}
/>
</Grid2>
</div>
);
}