1
- -- !!! Query is not converted to CH syntax yet. Delete this line when it gets converted
2
- WITH performance_results AS (
3
- SELECT
4
- name,
5
- IF(speedup = ' infra_error' , NULL , speedup) AS speedup, -- Handle the recent burst of infra error
6
- REPLACE(
7
- filename,
8
- CONCAT(
9
- ' _' , : dtypes, ' _' , : mode, ' _' , : device,
10
- ' _performance'
11
- )
12
- ) AS filename,
13
- compilation_latency,
14
- compression_ratio,
15
- abs_latency,
16
- mfu,
17
- memory_bandwidth,
18
- dynamo_peak_mem,
19
- eager_peak_mem,
20
- workflow_id,
21
- CAST(job_id AS INT ) AS job_id,
22
- FORMAT_ISO8601(
23
- DATE_TRUNC(: granularity, _event_time)
24
- ) AS granularity_bucket,
25
- head_sha,
26
- head_branch,
27
- FROM
28
- inductor .torchao_perf_stats
29
- WHERE
30
- filename LIKE ' %_performance'
31
- AND filename LIKE CONCAT(
32
- ' %_' , : dtypes, ' _' , : mode, ' _' , : device,
33
- ' _%'
34
- )
35
- AND _event_time >= PARSE_DATETIME_ISO8601(:startTime)
36
- AND _event_time < PARSE_DATETIME_ISO8601(:stopTime)
37
- AND (workflow_id = :workflowId OR :workflowId = 0 )
38
- ),
39
- accuracy_results AS (
40
- SELECT
41
- name,
42
- accuracy,
43
- REPLACE(
44
- filename,
45
- CONCAT(
46
- ' _' , : dtypes, ' _' , : mode, ' _' , : device,
47
- ' _accuracy'
48
- )
49
- ) AS filename,
50
- workflow_id,
51
- CAST(job_id AS INT ) AS job_id,
52
- FROM
53
- inductor .torchao_perf_stats
54
- WHERE
55
- filename LIKE ' %_accuracy'
56
- AND filename LIKE CONCAT(
57
- ' %_' , : dtypes, ' _' , : mode, ' _' , : device,
58
- ' _%'
59
- )
60
- AND _event_time >= PARSE_DATETIME_ISO8601(:startTime)
61
- AND _event_time < PARSE_DATETIME_ISO8601(:stopTime)
62
- AND (workflow_id = :workflowId OR :workflowId = 0 )
63
- AND accuracy != ' model_fail_to_load'
64
- AND accuracy != ' eager_fail_to_run'
65
- ),
66
- results AS (
67
- SELECT
68
- performance_results .granularity_bucket AS granularity_bucket,
69
- performance_results .workflow_id AS workflow_id,
70
- performance_results .job_id AS job_id,
71
- performance_results .head_branch AS head_branch,
72
- performance_results .head_sha AS head_sha,
73
- CASE
74
- WHEN performance_results .filename LIKE ' %_torchbench' THEN ' torchbench'
75
- WHEN performance_results .filename LIKE ' %_timm_models' THEN ' timm_models'
76
- WHEN performance_results .filename LIKE ' %_huggingface' THEN ' huggingface'
77
- ELSE NULL
78
- END AS suite,
79
- CASE
80
- WHEN performance_results .filename LIKE ' %_torchbench' THEN REPLACE(
81
- performance_results .filename , ' _torchbench'
82
- )
83
- WHEN performance_results .filename LIKE ' %_timm_models' THEN REPLACE(
84
- performance_results .filename , ' _timm_models'
85
- )
86
- WHEN performance_results .filename LIKE ' %_huggingface' THEN REPLACE(
87
- performance_results .filename , ' _huggingface'
88
- )
89
- ELSE NULL
90
- END AS compiler,
91
- performance_results .name ,
92
- IF(TRY_CAST(speedup AS FLOAT) IS NOT NULL ,
93
- CAST(speedup AS FLOAT),
94
- 0 .0
95
- ) AS speedup,
96
- accuracy_results .accuracy AS accuracy,
97
- IF(TRY_CAST(compilation_latency AS FLOAT) IS NOT NULL ,
98
- CAST(compilation_latency AS FLOAT),
99
- 0 .0
100
- ) AS compilation_latency,
101
- IF(TRY_CAST(compression_ratio AS FLOAT) IS NOT NULL ,
102
- CAST(compression_ratio AS FLOAT),
103
- 0 .0
104
- ) AS compression_ratio,
105
- IF(TRY_CAST(abs_latency AS FLOAT) IS NOT NULL ,
106
- CAST(abs_latency AS FLOAT),
107
- 0 .0
108
- ) AS abs_latency,
109
- IF(TRY_CAST(mfu AS FLOAT) IS NOT NULL ,
110
- CAST(mfu AS FLOAT),
111
- 0 .0
112
- ) AS mfu,
113
- IF(TRY_CAST(memory_bandwidth AS FLOAT) IS NOT NULL ,
114
- CAST(memory_bandwidth AS FLOAT),
115
- 0 .0
116
- ) AS memory_bandwidth,
117
- IF(TRY_CAST(dynamo_peak_mem AS FLOAT) IS NOT NULL ,
118
- CAST(dynamo_peak_mem AS FLOAT),
119
- 0 .0
120
- ) AS dynamo_peak_mem,
121
- IF(TRY_CAST(eager_peak_mem AS FLOAT) IS NOT NULL ,
122
- CAST(eager_peak_mem AS FLOAT),
123
- 0 .0
124
- ) AS eager_peak_mem,
125
- FROM
126
- performance_results
127
- LEFT JOIN accuracy_results ON performance_results .name = accuracy_results .name
128
- AND performance_results .filename = accuracy_results .filename
129
- AND performance_results .workflow_id = accuracy_results .workflow_id
1
+ -- This powers HUD TorchAO benchmarks dashboards
2
+ WITH benchmarks AS (
3
+ SELECT
4
+ o .model .origins [ 1 ] AS suite,
5
+ o .model .name AS model,
6
+ tupleElement(o .benchmark , ' extra_info' ) [ ' quantization' ] AS dtype,
7
+ o .metric .name AS metric,
8
+ floor(arrayAvg(o .metric .benchmark_values), 2 ) AS value,
9
+ tupleElement(o .metric , ' extra_info' ) AS extra_info,
10
+ replaceOne(o .head_branch , ' refs/heads/' , ' ' ) AS head_branch,
11
+ o .head_sha AS head_sha,
12
+ o .workflow_id AS workflow_id,
13
+ o .job_id AS job_id,
14
+ DATE_TRUNC(
15
+ {granularity: String },
16
+ fromUnixTimestamp(o .timestamp )
17
+ ) AS granularity_bucket
18
+ FROM
19
+ benchmark .oss_ci_benchmark_v3 o
20
+ WHERE
21
+ o .timestamp >= toUnixTimestamp({startTime: DateTime64(3 ) })
22
+ AND o .timestamp < toUnixTimestamp({stopTime: DateTime64(3 ) })
23
+ AND o .repo = {repo: String }
24
+ AND (
25
+ has({commits: Array(String) }, o .head_sha )
26
+ OR empty({commits: Array(String) })
27
+ )
28
+ AND (
29
+ has({suites: Array(String) }, suite)
30
+ OR empty({suites: Array(String) })
31
+ )
32
+ AND (
33
+ has({dtypes: Array(String) }, dtype)
34
+ OR empty({dtypes: Array(String) })
35
+ )
36
+ AND tupleElement(o .benchmark , ' mode' ) = {mode: String }
37
+ AND tupleElement(o .benchmark , ' extra_info' ) [ ' device' ] = {device: String }
38
+ AND (
39
+ workflow_id = {workflowId: Int64}
40
+ OR {workflowId: Int64} = 0
41
+ )
42
+ AND (
43
+ o .metric .name in [ ' accuracy' ,
44
+ ' speedup' ,
45
+ ' compilation_latency' ,
46
+ ' compression_ratio' ,
47
+ ' abs_latency' ,
48
+ ' mfu' ,
49
+ ' memory_bandwidth' ,
50
+ ' dynamo_peak_mem' ,
51
+ ' eager_peak_mem' ]
52
+ )
130
53
)
131
- SELECT DISTINCT
132
- results .workflow_id ,
133
- -- As the JSON response is pretty big, only return the field if it's needed
134
- IF(:getJobId, results .job_id , NULL ) AS job_id,
135
- results .suite ,
136
- results .compiler ,
137
- results .name ,
138
- results .speedup ,
139
- results .accuracy ,
140
- results .compilation_latency ,
141
- results .compression_ratio ,
142
- results .abs_latency ,
143
- results .mfu ,
144
- results .memory_bandwidth ,
145
- results .dynamo_peak_mem ,
146
- results .eager_peak_mem ,
147
- results .granularity_bucket ,
54
+ SELECT
55
+ suite,
56
+ model,
57
+ dtype,
58
+ metric,
59
+ value,
60
+ extra_info,
61
+ workflow_id,
62
+ job_id,
63
+ granularity_bucket
148
64
FROM
149
- results
65
+ benchmarks
150
66
WHERE
151
- ARRAY_CONTAINS(SPLIT(:suites, ' , ' ), LOWER ( results . suite ))
152
- AND (ARRAY_CONTAINS(SPLIT(:compilers, ' , ' ), LOWER ( results . compiler )) OR :compilers = ' ' )
153
- AND (ARRAY_CONTAINS(SPLIT(:branches, ' , ' ), results . head_branch ) OR : branches = ' ' )
154
- AND (ARRAY_CONTAINS(SPLIT(:commits, ' , ' ), results . head_sha ) OR :commits = ' ' )
67
+ (
68
+ has({branches: Array(String) }, head_branch )
69
+ OR empty({ branches: Array(String) } )
70
+ )
155
71
ORDER BY
156
- granularity_bucket DESC ,
157
- workflow_id DESC ,
158
- suite ASC ,
159
- compiler ASC ,
160
- name ASC
72
+ granularity_bucket DESC ,
73
+ workflow_id DESC ,
74
+ suite ASC ,
75
+ dtype ASC ,
76
+ model ASC
0 commit comments