1 of 43

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

2 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
  • A Uniform Intra-Layer Analytical Latency Model
  • Model Validation
  • Three Case Studies
  • Conclusion and Future Work

2

3 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
    • Necessity + Feasibility + Challenge
  • A Uniform Intra-Layer Analytical Latency Model
  • Model Validation
  • Three Case Studies
  • Conclusion and Future Work

3

4 of 43

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

  • HUGE architecture design space�(E.g., PE array size, interconnection, memory hierarchy)
  • Traditional latency estimation methods: time-consuming, not flexible�(E.g., RTL simulation, cycle-accurate simulator)
  • HUGE mapping design space�(E.g., Loop tiling, loop ordering, loop unrolling)
  • Mapping impact
  • DNN layer type/shape/size impact

Can we estimate the latency of a given (NN layer, HW arch, mapping) quickly?

Yes, with analytical model!

5 of 43

Analytical Latency Modeling - Feasibility

5

HW: Structured

Algorithm: Regular

Mapping: Deterministic

6 of 43

Analytical Latency Modeling – Challenge NO. 1

  • Guarantee Generality – “One for All”

6

One model that suits all different (NN layer, HW arch, mapping) combinations

NN layer

HW arch

Mapping

7 of 43

Analytical Latency Modeling – Challenge NO. 2

  • Capture Concurrency – “All in One”

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 !

8 of 43

Analytical Latency Modeling – Challenges and SotAs

  • Guarantee Generality – “One for All”

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

  • Capture Concurrency – “All in One”

One model that suits all different (NN layer, HW arch, mapping) combinations

9 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
  • A Uniform Intra-Layer Analytical Latency Model
    • “One-for-All”: A Uniform Dataflow Representation
    • “All-in-One”: Divide-Combine-Integrate 3-Step Method
  • Model Validation
  • Three Case Studies
  • Conclusion and Future Work

9

10 of 43

A Uniform Dataflow Representation – Prior Art

  • Loop Relevancy Principle

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

  • Uneven Mapping Format

W-Reg

I-Reg

O-Reg

Local Buffer (W/I/O)

11 of 43

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:

  • Total latency + latency breakdown
  • Each HW component’s working state
  • System latency bottleneck

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)

12 of 43

Modelling Methodology – The 3 Steps

12

Step 1: “Divide”

Step 2: “Combine”

Step 3: “Integrate”

🡪 Temporal stall

13 of 43

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

14 of 43

Step 1: Divide - Compute key attributes 1

Attributes of Unit Mem

  • MemDATA : Data size held in the Unit Mem

The product of all the r loops' size (temporal & spatial) at current and lower memory levels.

  • MemCC : Updating period of Unit Mem

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

15 of 43

Step 1: Divide - Compute key attributes 2

15

Attributes of Data Transfer Link (DTL)

  • ReqBWu : Required BW to prevent computation stall
    • DTL double-buffered memory level

ReqBWu = MemDATA / MemCC

    • DTL non-double-buffered memory level

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

16 of 43

Step 1: Divide - Compute key attributes 3

16

Attributes of Data Transfer Link (DTL)

  • MUWu : Total allowed memory updating time window
  • SSu : Total Stall (+) or Slack (-)

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

17 of 43

Step 1: Divide - Compute key attributes 3

17

Attributes of Data Transfer Link (DTL)

  • MUWu : Total allowed memory updating time window
  • SSu : Total Stall (+) or Slack (-)

 

Non-double-buffered

memory level

Double-buffered

memory level

 

 

18 of 43

Step 1: Divide - Compute key attributes 3

18

Attributes of Data Transfer Link (DTL)

  • MUWu : Total allowed memory updating time window
  • SSu : Total Stall (+) or Slack (-)

 

 

 

 

Non-double-buffered

memory level

 

Z = 1

Z = 2

Z = 3

Z = 4

= XREQ × Z

Double-buffered

memory level

19 of 43

Step 1: Divide - Compute key attributes 3

19

Attributes of Data Transfer Link (DTL)

  • MUWu : Total allowed memory updating time window
  • SSu : Total Stall (+) or Slack (-)

 

 

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

20 of 43

Step 2: Combine

Consider memory port sharing, and combine unit attributes

20

  • Combine ReqBWu @same port: ReqBWcomb(1,6) = ReqBWu① + ReqBWu
  • Combine MUWu @same port: MUWcomb(1,6) = MUWu① ∪ MUWu
  • Combine SSu @same port: SScomb(1,6) = Combine(SSu①, SSu⑥) 🡪 next slides
  • Combine SSu @same served mem: SScomb((1,6),(2,7)) = max(SScomb(1,6) , SScomb(2,7))

ReqBWu

MUWu

SSu

Unit Mems DTLs

21 of 43

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

22 of 43

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 = (XREALXREQ) × 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

23 of 43

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

 

 

24 of 43

Step 2: Combine - SSu @same port

Combine Unit Stall/Slack (SSu) @same port

24

Actual working cycle within each MUW

 

Sum of positive stalls

 

 

 

 

25 of 43

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 = (XREALXREQ) × 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

26 of 43

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 = (XREALXREQ) × 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

27 of 43

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 = (XREALXREQ) × 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

28 of 43

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 = (XREALXREQ) × 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

29 of 43

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 = (XREALXREQ) × 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

30 of 43

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 = (XREALXREQ) × 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

31 of 43

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

32 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
  • A Uniform Intra-Layer Analytical Latency Model
  • Model Validation
  • Three Case Studies
  • Conclusion and Future Work

32

33 of 43

Model Validation

33

  • Limited Global Buffer BW
  • Evaluated NN layers across a large range
  • Average latency estimation accuracy: 94.3%

Against an in-house DNN accelerator

34 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
  • A Uniform Intra-Layer Analytical Latency Model
  • Model Validation
  • Three Case Studies
    • Mapping v.s. latency
    • Workload v.s. latency
    • HW architecture v.s. latency
  • Conclusion and Future Work

34

35 of 43

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

  • Mem Access
  • Energy
  • Latency
  • BW Analysis

36 of 43

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

  • Mem Access
  • Energy
  • Latency
  • BW Analysis

37 of 43

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%

  • Mem Access
  • Energy
  • Latency
  • BW Analysis

38 of 43

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)

  • Mem Access
  • Energy
  • Latency
  • BW Analysis

RealBW [bit/cc]

ReqBW (Mapping A) [bit/cc]

ReqBW (Mapping B) [bit/cc]

ReqBW largely exceeds RealBW + Frequent GB access

induce large stall.

39 of 43

Case Study 1: Mapping v.s. Latency 5

Conclusion:

39

  1. Matching required memory BW (mapping-dependent) with �real memory BW (HW-dependent);

  • Reducing the frequent memory access of the low-BW link.

A good latency model is critical to help DNN accelerator mapper to minimize system temporal stall:

40 of 43

Case Study 2: Workload v.s. Latency 1

40

Workload Pool

Layer dimensions:

B/K/C: {8,32,128,512}

Hardware

Mapping

Latency-optimized

  • Temporal stall can play important role in total latency.
  • Latency breakdown helps to analyse trend, identify the system bottleneck.
  • Latency estimation time is always short, doesn’t scale up with workload size (<1ms).

41 of 43

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

  • Area-latency trade-off sensitivity towards memory size is high @ low GB BW.

  • MAC array size preference changes for different memory BWs.

  • BW-awareness is important for HW parameter optimization on latency.

42 of 43

Outline

  • Fast Latency Estimation for DNN Accelerator
    • Necessity + Feasibility + Challenge
  • A Uniform Intra-Layer Analytical Latency Model
    • “One-for-All”: A Uniform Dataflow Representation
    • “All-in-One”: Divide-Combine-Integrate 3-Step Method
  • Model Validation
  • Three Case Studies
    • Mapping v.s. latency
    • Workload v.s. latency
    • HW architecture v.s. latency
  • Conclusion and Future Work

42

43 of 43

Conclusion and Future Work

  • A unified analytical intra-layer latency model for DNN accelerators is proposed. It can provide latency breakdown and identify performance bottlenecks.
  • Following a divide-combine-integrate 3-step approach, the model overcomes prior challenges by capturing the periodic operation of hardware components.

43

Conclusion

Future Work

  • Recent technology such as 3D IC with fine-pitch SRAM-on-logic stacking can offer high BW interconnects. The proposed BW-aware latency model can help explore the new design space.
  • This intra-layer latency model also builds a solid foundation for modeling latency in cross-layer and multi-core DNN mapping scenarios.