A Uniform Latency Model for DNN Accelerators�with Diverse Architectures and Dataflows
Linyan Mei∗†, Huichu Liu∗, Tony Wu∗, H. Ekin Sumbul∗,
Marian Verhelst†, Edith Beigne∗
∗Meta Reality Labs, †MICAS-ESAT, KU Leuven
January 2022
Outline
2
Outline
3
Fast Latency Estimation - Necessity
4
HW Architect: Design high performance HW
Compiler Designer: Map each DNN layer to HW efficiently
Algorithm Developer: Develop HW-friendly DNNs
Can we estimate the latency of a given (NN layer, HW arch, mapping) quickly?
Yes, with analytical model!
Analytical Latency Modeling - Feasibility
5
HW: Structured
Algorithm: Regular
Mapping: Deterministic
Analytical Latency Modeling – Challenge NO. 1
6
One model that suits all different (NN layer, HW arch, mapping) combinations
NN layer
HW arch
Mapping
Analytical Latency Modeling – Challenge NO. 2
7
Spatially underutilized
Temporally underutilized
PE array
Spatial mapping
❌Mismatch
❌ Insufficient memory BW and port
❌ Suboptimal temporal mapping
Timeline
…
…
HW components work concurrently�(parallel / series, independent / interference)
Spatial
underutilization
Easy ~
Temporal stall
Hard !
Analytical Latency Modeling – Challenges and SotAs
8
State of the Arts | Guarantee Generality | Capture Concurrency |
[MAESTRO] | No, with a pre-defined HW template | |
[dMazeRunner] | No, with a pre-defined HW template | |
[Interstellar] | | No, only consider spatial underutilization |
[Timeloop] | | No, only consider spatial underutilization |
❌ Insufficient mem BW and port
❌ Suboptimal temporal mapping
One model that suits all different (NN layer, HW arch, mapping) combinations
Outline
9
A Uniform Dataflow Representation – Prior Art
10
An uneven mapping example
r loop 🡪 data size
ir loop 🡪 data reuse
pr loop 🡪 r/ir loops
L. Mei, P. Houshmand, V. Jain, S. Giraldo and M. Verhelst, "ZigZag: Enlarging Joint Architecture-Mapping Design Space Exploration for DNN Accelerators," in IEEE TC, 2021
W-Reg
I-Reg
O-Reg
Local Buffer (W/I/O)
Latency Model Overview
Input to the model (NN layer, HW arch, mapping):
11
Weight Input Output
for B in [0, 4) GB GB GB
for K’ in [0, 2) GB LB GB
for OY in [0, 2) LB LB LB
for C’ in [0, 2) LB LB LB
for OX in [0, 2) W-Reg LB LB
for K in [0, 3) W-Reg I-Reg O-Reg
for C in [0,2) W-Reg I-Reg O-Reg
O[B][3K’+K][OY][OX] += W[K][2C’+C] × I[B][2C’+C][OY][OX]
Output of the model:
for B in [0, 4)
for K in [0, 6)
for C in [0, 4)
for OX in [0, 2)
for OY in [0, 2)
O[B][K][OY][OX] +=
W[K][C] × I[B][C][OY][OX]
W-Reg
I-Reg
O-Reg
Local Buffer (W/I/O)
Global Buffer (W/I/O)
Modelling Methodology – The 3 Steps
12
Step 1: “Divide”
Step 2: “Combine”
Step 3: “Integrate”
🡪 Temporal stall
Step 1: Divide
Divide into Unit Mems & Identify DTLs & Compute key attributes 🡪 next slides
13
Weight Input Output
for B in [0, 4) GB GB GB
for K’ in [0, 2) GB LB GB
for OY in [0, 2) LB LB LB
for C’ in [0, 2) LB LB LB
for OX in [0, 2) W-Reg LB LB
for K in [0, 3) W-Reg I-Reg O-Reg
for C in [0,2) W-Reg I-Reg O-Reg
O[B][3K’+K][OY][OX] += W[K][2C’+C] × I[B][2C’+C][OY][OX]
W-Reg
I-Reg
O-Reg
Local Buffer (W/I/O)
Global Buffer (W/I/O)
Unit Mem: Memory that only holds a single operand (W/I/O).
DTL: Data transfer link between Unit Mem across memory levels (read/write).
Key attributes: MemDATA , MemCC , ReqBWu , MUWu , SSu.
Mem7
Mem8
Mem9
Mem1
Mem2
Mem3
Mem4
Mem5
Mem6
Step 1: Divide - Compute key attributes 1
Attributes of Unit Mem
The product of all the r loops' size (temporal & spatial) at current and lower memory levels.
The product of all the temporal loop sizes at current and lower memory levels.
14
Weight Input Output
for B in [0, 4) GB GB GB
for K’ in [0, 2) GB LB GB
for OY in [0, 2) LB LB LB
for C’ in [0, 2) LB LB LB
for OX in [0, 2) W-Reg LB LB
for K in [0, 3) W-Reg I-Reg O-Reg
for C in [0,2) W-Reg I-Reg O-Reg
O[B][3K’+K][OY][OX] += W[K][2C’+C] × I[B][2C’+C][OY][OX]
Mem7
Mem8
Mem9
Mem1
Mem2
Mem3
Mem4
Mem5
Mem6
| B | K | C | OY | OX |
W | ir | r | r | ir | ir |
I | r | ir | r | r | r |
O | r | r | ir | r | r |
r
ir
r
r
ir
r
ir
MemDATA = 6
MemCC = 12
MemDATA = 12
MemCC = 48
MemDATA = 24
MemCC 384
Step 1: Divide - Compute key attributes 2
15
Attributes of Data Transfer Link (DTL)
ReqBWu = MemDATA / MemCC
ReqBWu = (MemDATA / MemCC) × top-ir loop size
E.g.
Weight
If Mem 7 is double-buffered :
ReqBWu = 6 data / 12 cycle = 0.5 data / cycle
If Mem 7 is non-double-buffered :
ReqBWu = 6 data / 12 cycle × 2 = 1 data / cycle
(* spatial unrolling not considered)
Buffer A
Buffer B
Buffer A
r
r
ir
r
ir
Buffer A
Buffer B
Buffer A
W/I
O
ReqBWu
Step 1: Divide - Compute key attributes 3
16
Attributes of Data Transfer Link (DTL)
Non-double-buffered
memory level
Double-buffered
memory level
“M” : Memory data updating
“C” : data Consuming
“n” in Mn/Cn : identify data producer-consumer pair, e.g., M1 serves C1
Step 1: Divide - Compute key attributes 3
17
Attributes of Data Transfer Link (DTL)
Non-double-buffered
memory level
Double-buffered
memory level
Step 1: Divide - Compute key attributes 3
18
Attributes of Data Transfer Link (DTL)
Non-double-buffered
memory level
Z = 1
Z = 2
Z = 3
Z = 4
= XREQ × Z
Double-buffered
memory level
Step 1: Divide - Compute key attributes 3
19
Attributes of Data Transfer Link (DTL)
Double-buffered
memory level
Non-double-buffered
memory level
Z = 1
Z = 2
Z = 3
Z = 4
Each DTL:
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
= XREQ × Z
= (XREAL−XREQ) × Z
Step 2: Combine
Consider memory port sharing, and combine unit attributes
20
ReqBWu
MUWu
SSu
Unit Mems DTLs
Step 2: Combine - SSu @same port
Combine Unit Stall/Slack (SSu) @same port
21
Mem 1
Mem 2
Mem 4
Mem n
Mem 3
…
Mem
Mem
Mem
Mem
Mem
DTL(1)
DTL(2)
DTL(3)
DTL(4)
DTL(n)
W
I
O
W
I
Assume�one physical memory
Step 2: Combine - SSu @same port
Combine Unit Stall/Slack (SSu) @same port
22
n DTLs share 1 memory port
Assume
Mem ★ only has 1 port
Each DTL:
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
Mem ★
Mem 1
Mem 2
Mem 4
Mem n
Mem 3
…
Known: SSu(1), SSu(2) , … , SSu(n) ;
MUWu(1), MUWu(2) , … , MUWu(n)
Want to know:
SScomb(1,2,…,n)
Value & Position
Value
DTL(1)
DTL(2)
DTL(3)
DTL(4)
DTL(n)
SSu(1)<0
SSu(2)>0
SSu(3)<0
SSu(4)=0
SSu(n)>0
Step 2: Combine - SSu @same port
Combine Unit Stall/Slack (SSu) @same port
23
Actual working cycle within each MUW
Assume n DTLs share 1 memory port
Reorder DTLs based on SSu (+/-).
Assume:
Sum of positive stalls
Step 2: Combine - SSu @same port
Combine Unit Stall/Slack (SSu) @same port
24
Actual working cycle within each MUW
Sum of positive stalls
| |
| |
| |
| |
Step 2: Combine - SSu @same port E.g. 1
Combine Unit Stall/Slack (SSu) @same port
25
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 3 | 4 | 12 | 0 | 24 | 12 |
DTL(2) | 8 | 6 | 6 | 4 | 24 | 0 |
Timeline
(cycle)
0
32
Each DTL
8
2
5
Ideal data transfer waveform
Step 2: Combine - SSu @same port E.g. 2
Combine Unit Stall/Slack (SSu) @same port
26
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 3 | 4 | 12 | 0 | 24 | 12 |
DTL(2) | 4 | 3 | 3 | 8 | 24 | 0 |
Timeline
(cycle)
0
32
Each DTL
8
5
1
4
Ideal data transfer waveform
Step 2: Combine - SSu @same port E.g. 3
Combine Unit Stall/Slack (SSu) @same port
27
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 3 | 4 | 12 | 0 | 24 | 0 |
DTL(2) | 8 | 6 | 3 | 4 | 24 | -12 |
Timeline
(cycle)
0
32
Each DTL
8
5
2
Ideal data transfer waveform
Step 2: Combine - SSu @same port E.g. 4
Combine Unit Stall/Slack (SSu) @same port
28
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 5 | 4 | 12 | 8 | 24 | 8 |
DTL(2) | 8 | 6 | 3 | 4 | 24 | -12 |
Timeline
(cycle)
0
32
Each DTL
8
5
2
10
Ideal data transfer waveform
Step 2: Combine - SSu @same port E.g. 5
Combine Unit Stall/Slack (SSu) @same port
29
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 5 | 4 | 12 | 8 | 24 | 20 |
DTL(2) | 8 | 6 | 6 | 4 | 24 | 0 |
Timeline
(cycle)
0
32
Each DTL
8
5
2
10
Ideal data transfer waveform
Step 2: Combine - SSu @same port E.g. 6
Combine Unit Stall/Slack (SSu) @same port
30
| |
| |
| |
| |
Mem ★
Mem 1
Mem 2
DTL(1)
DTL(2)
1 port
DTL(1)
DTL(2)
For every MemCC ,
can be busy for XREQ ,
actually is busy for XREAL .
In total goes through Z MemCC .
MUWu = XREQ × Z
SSu = (XREAL−XREQ) × Z
| | | XREAL | Z | MUWu | SSu | MUWcomb | SScomb |
Legend | | | | | | | | |
DTL(1) | 8 | 3 | 5 | 4 | 12 | 8 | 24 | 36 |
DTL(2) | 8 | 6 | 10 | 4 | 24 | 16 |
Timeline
(cycle)
0
32
Each DTL
8
5
2
10
12
Ideal data transfer waveform
Step 3: Integrate
31
Consider actual design constrains, integrate combined attributes
memory operations �that can be overlapped �(stalls hided under the longest one)
memory operations
that cannot be overlapped
Parallel 🡪 Max
Series 🡪 Sum
Outline
32
Model Validation
33
Against an in-house DNN accelerator
Outline
34
Case Study 1: Mapping v.s. Latency 1
35
Hardware
Workload
Layer dimensions:
B: 64, K: 160, C: 960
Precision:
W/I: 8 bits, O: 24 bits
Temporal Loops
W
I
O
B: Latency-optimized
Temporal Loops
W
I
O
Mapping A: Energy-optimized
Data reuse (ir loops)
Mapping A
Mapping B
I (Inputs)
O (Outputs & Partial Sums)
Less O-Reg/GB traffic
Less I-LB/GB traffic
Case Study 1: Mapping v.s. Latency 2
36
Workload
Layer dimensions:
B: 64, K: 160, C: 960
Precision:
W/I: 8 bits, O: 24 bits
Hardware
Temporal Loops
W
I
O
B: Latency-optimized
Temporal Loops
W
I
O
A: Energy-optimized
Data reuse (ir loops)
+5%
[pJ]
[pJ]
Total
Partial energy breakdown
Case Study 1: Mapping v.s. Latency 3
37
Workload
Layer dimensions:
B: 64, K: 160, C: 960
Precision:
W/I: 8 bits, O: 24 bits
Hardware
Temporal Loops
W
I
O
B: Latency-optimized
Temporal Loops
W
I
O
A: Energy-optimized
Data reuse (ir loops)
Temporal stall [cycle]
Ideal computation [cycle]
MAC Array Utilization [%]
-30%
Case Study 1: Mapping v.s. Latency 4
38
Workload
Layer dimensions:
B: 64, K: 160, C: 960
Precision:
W/I: 8 bits, O: 24 bits
Hardware
Temporal Loops
W
I
O
B: Latency-optimized
Temporal Loops
W
I
O
A: Energy-optimized
Data reuse (ir loops)
RealBW [bit/cc]
ReqBW (Mapping A) [bit/cc]
ReqBW (Mapping B) [bit/cc]
ReqBW largely exceeds RealBW + Frequent GB access
induce large stall.
Case Study 1: Mapping v.s. Latency 5
Conclusion:
39
A good latency model is critical to help DNN accelerator mapper to minimize system temporal stall:
Case Study 2: Workload v.s. Latency 1
40
Workload Pool
Layer dimensions:
B/K/C: {8,32,128,512}
Hardware
Mapping
Latency-optimized
Case Study 3: HW Architecture v.s. Latency
41
Hardware
Mapping
Latency-optimized
Workload
Layer dimensions:
B: 64, K: 160, C: 960
4,176 HW Arch
Outline
42
Conclusion and Future Work
43
Conclusion
Future Work