Maps to: Stanford CS 217 Hardware Accelerators for Machine Learning (Winter 2026), Lecture 3 · Tue 01/13/2026 · Data Parallelism and Efficiency Metrics. Lab 0 is due; Lab 1 is out: design of a SIMD processing element. Reading (from the schedule):
- R. Venkatesan et al., MAGNet: a modular accelerator generator for neural networks, ICCAD 2019;
- Y.-H. Chen, T. Krishna, J. Emer, V. Sze, Eyeriss: an energy-efficient reconfigurable accelerator for deep convolutional neural networks, IEEE JSSC 2017.
Basis: The slides are not public. This lecture follows the session title, the two readings, Eyeriss’s companion dataflow paper (Chen, Emer, Sze, ISCA 2016) and Sze et al., Efficient Processing of Deep Neural Networks (chapters on dataflows and on benchmarking metrics). Numbers quoted from papers are labelled. The processing element, the energy accounting and the metric experiments are models written for these notes (
pe.py,metrics.py); their numbers come from running them and do not reflect what was said in class. Code:code/lecture03/(4 scripts + 2 modules; each runs in under a second) Reading time: 4 hours including running the code
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Write a convolution or a transformer layer as a loop nest, tell independent loops from reduction loops, and count how much of each a layer offers.
- Explain why accelerators are built from SIMD units: one instruction (or one configuration) drives many multipliers, amortizing the control energy that dominates a CPU (Lecture 1).
- Map a layer onto a SIMD unit in different ways (dot products, outer products, pixels × groups) and compute the utilization lost to padding.
- Split a layer across many PEs along M, N or K, and name what each split costs: load imbalance, broadcast traffic, partial-sum reduction traffic.
- Describe a MAGNet-style processing element (lanes, vector width, weight/input/accumulation buffers) and its three classic dataflows — weight-, output- and input-stationary — as loop orders.
- Predict where a PE loses cycles: padding, the accumulator read-modify-write hazard, weight-load time, weight-buffer bandwidth, and why double buffering matters.
- Do Eyeriss-style energy accounting: count accesses per storage level, multiply by the cost per access, and explain why reuse at the innermost level matters most.
- Explain row-stationary and count its accesses on a 2D convolution.
- Define peak vs effective throughput, utilization, TOPS/W, pJ/op, TOPS/mm², latency vs throughput, and take apart a headline number: precision, sparsity, power boundary, workload, process node.
- Report accelerator results honestly, in the spirit of MLPerf.
0.2 Prerequisites and scope
| Assumed | Introduced here | Developed later |
|---|---|---|
| Lecture 1: energy per operation and access, roofline, compulsory traffic | loop nests, SIMD mapping, spatial splits | the systolic array as another mapping (L5) |
| Lecture 2: pipelines, II, recurrences, latency-insensitive channels | the SIMD processing element of Lab 1 and its dataflows | vector units (L6), global buffers (L7), NoC broadcast/reduction (L8) |
| matrix multiplication, convolution | Eyeriss energy accounting, row-stationary | systematic mapping and dataflow search (L9) |
0.3 Map
§1 where the parallelism is: loop nests, SIMD mappings, spatial splits, pipelining ← code 01
§2 the processing element: MAGNet's PE, dataflows, utilization, shape, small batches ← code 02
§3 energy accounting: Eyeriss's hierarchy, reuse, row-stationary, the whole stack ← code 03
§4 efficiency metrics and how they mislead; benchmarking practice ← code 04
§5 Lab 1: designing the SIMD PE
§6 summary §7 pitfalls §8 exercises §9 further reading §10 next lecture
Suggested order: §1 → run 01 → §2 → run 02 → §3 → run 03 → §4 → run 04 → §5.
0.4 Notation
| Symbol | Meaning |
|---|---|
| the GEMM view of a layer: output rows (pixels × batch, or tokens), output columns (output channels), reduction (input channels × filter size) | |
| groups | independent small GEMMs (depthwise convolution: one per channel; attention: one per head) |
| lanes, vec | the PE’s vector MAC units and their width: lanes × vec multipliers |
| WS / OS / IS | weight- / output- / input-stationary dataflow |
| RF, array, buffer, DRAM | Eyeriss’s storage levels: per-PE register file, PE-to-PE network, global buffer, off-chip memory |
| MAC unit | energy of one MAC (Eyeriss’s normalization) |
| TOPS, TOPS/W | ops/s; ops per picojoule (1 MAC = 2 ops) |
1. Where the parallelism is
1.1 Intuition: grading a stack of exams
A teacher grading 500 exams with 20 questions each has two kinds of parallelism available. The exams are independent: 50 assistants can each take 10 exams and never talk. The questions of one exam form a reduction: 20 assistants could each grade one question of the same exam, but somebody must then add up the 20 scores. Both work. The first needs no coordination but enough exams per assistant. The second needs an adder at the end.
ML layers have exactly this structure, at a much larger scale.
1.2 The loop nest
A convolution is seven nested loops (batch , output channel , output pixel , input channel , filter position ):
for n in range(Nb): # independent (batch)
for k in range(K): # independent (output channels)
for p in range(P): # independent (output rows)
for q in range(Q): # independent (output columns)
for c in range(C): # REDUCTION (input channels)
for r in range(R): # REDUCTION (filter rows)
for s in range(S): # REDUCTION (filter columns)
out[n][k][p][q] += w[k][c][r][s] * x[n][c][p*stride + r][q*stride + s]
Grouping the independent loops into rows and columns and the reduction loops into a dot product gives the GEMM view: , , — the im2col transformation. A transformer’s projections and MLPs are GEMMs directly, with = tokens. Script 01, Part 1 tabulates eight real layers:
| layer | M | N | groups | K (reduction) | independent outputs | MACs |
|---|---|---|---|---|---|---|
| ResNet-50 conv1 7×7/2 | 12,544 | 64 | 1 | 147 | 803 k | 118 M |
| ResNet-50 3×3 (stage 2) | 3,136 | 64 | 1 | 576 | 201 k | 116 M |
| ResNet-50 1×1 (stage 2) | 3,136 | 64 | 1 | 256 | 201 k | 51 M |
| MobileNetV2 depthwise 3×3 | 3,136 | 1 | 144 | 9 | 452 k | 4.1 M |
| FC 2048→1000, batch 1 | 1 | 1,000 | 1 | 2,048 | 1 k | 2.0 M |
| Llama-8B q_proj, 512 tokens | 512 | 4,096 | 1 | 4,096 | 2.1 M | 8.6 G |
| Llama-8B attention QKᵀ, 512 tokens | 512 | 512 | 32 | 128 | 8.4 M | 1.1 G |
| Llama-8B MLP up, decode | 1 | 14,336 | 1 | 4,096 | 14 k | 59 M |
Even the smallest layer offers thousands of independent outputs. Parallelism is not scarce in ML. The design problem is which loops to spread over the hardware, and every choice favors some layers over others. Two shapes stand out as awkward. Depthwise convolution has a 9-long reduction and one output channel per group. Batch-1 layers have : a matrix-vector product with no reuse of the weights.
1.3 Forms of parallelism, and why SIMD
Hardware can exploit the loop nest in several ways:
| Form | What runs in parallel | Hardware | Cost |
|---|---|---|---|
| SIMD / vector (data parallelism) | the same operation on many elements | vector MAC units, lanes | operands must arrive together |
| spatial | different tiles of the loop nest on different PEs | arrays of PEs, a network | data distribution and collection |
| pipeline (operator) | different layers on different hardware at once | dataflow chips, layer pipelines | balancing the stages |
| batch | different inputs | any of the above | latency, memory |
Why SIMD first? Lecture 1 showed that a scalar core spends ~70 pJ on fetching, decoding and controlling one instruction whose arithmetic costs 0.1 pJ. A SIMD unit issues one instruction — or, in an accelerator, holds one configuration for thousands of cycles — for 64 multipliers. The control cost per MAC falls by 64× or more. MAGNet’s PE, Simba’s PE, a GPU’s tensor core and a TPU’s matrix unit are all variations on “one control decision, many MACs”.
1.4 Mapping a layer onto a SIMD unit
A SIMD unit of vec × lanes multipliers needs two loop dimensions to spread across its two axes. Script 01, Part 2 tries four mappings on an 8 × 8 unit and counts only the utilization lost to padding. A dimension of size on slots runs in steps, the last one partly empty, so the efficiency is :
| layer | vec=K, lanes=N (dot products) | vec=M, lanes=N (outer products) | vec=K, lanes=M | vec=M, lanes=G |
|---|---|---|---|---|
| ResNet conv1 7×7/2 | 0.97 | 1.00 | 0.97 | 0.12 |
| ResNet 3×3, 1×1 | 1.00 | 1.00 | 1.00 | 0.12 |
| MobileNetV2 depthwise | 0.07 | 0.12 | 0.56 | 1.00 |
| FC, batch 1 | 1.00 | 0.12 | 0.12 | 0.02 |
| Llama decode | 1.00 | 0.12 | 0.12 | 0.02 |
- Dot products (each lane = one output channel; its vec multipliers feed an adder tree over input channels) are MAGNet’s choice and serve the common layers perfectly. They lose a little on the first layer (147 = 3 channels × 49 is not a multiple of 8) and collapse on depthwise: a reduction of 9 fills 9 of 16 multipliers, and one output channel per group fills 1 of 8 lanes.
- Outer products (every multiplier owns one output) need many rows: they fail at batch 1.
- Pixels × groups is the only mapping that serves depthwise layers.
No mapping is best everywhere. That is the root of the “fixed vs flexible” debate that runs through the course: fixed PEs (MAGNet, NVDLA, TPU) win the common case, while flexible fabrics (Eyeriss’s reconfigurable mapping, MAERI in Lecture 5, reconfigurable dataflow in Lecture 12) pay hardware to cover the rest.

Figure (script 01): padding-only utilization of an 8 × 8 SIMD unit fed four ways. The depthwise and batch-1 layers each need a different mapping than the common case.
1.5 Spatial parallelism: splitting a layer over PEs
With 16 PEs, the GEMM can be split along M (pixels or tokens), N (output channels) or K (the reduction). Script 01, Part 3 measures each split. Utilization uses the PE model of §2; traffic is the bytes that must leave the global buffer:
| layer | split | utilization | inputs: broadcast / unicast | weights: broadcast / unicast | partial sums |
|---|---|---|---|---|---|
| ResNet 3×3 | M | 1.00 | 201 kB / 201 kB | 37 kB / 590 kB | — |
| N | 0.50 | 201 kB / 3.2 MB | 37 kB / 37 kB | — | |
| K | 0.90 | 201 kB / 201 kB | 37 kB / 37 kB | 12 MB | |
| Llama q_proj, 512 tok | M | 1.00 | 2.1 MB / 2.1 MB | 16.8 MB / 268 MB | — |
| K | 1.00 | 2.1 MB / 2.1 MB | 16.8 MB / 16.8 MB | 126 MB | |
| Llama decode | M | 0.02 | 4.1 kB | 58.7 MB | — |
| N | 0.33 | 4.1 kB / 65.5 kB | 58.7 MB | — |
Each split has its own price:
- Split M: every PE needs all the weights. Free if the network can broadcast one weight to all PEs, 16× the traffic if not. Useless when (decode): one PE works, fifteen idle.
- Split N: every PE needs all the inputs (broadcast again). With only 64 output channels, each PE gets 4 — half of its 8 lanes. Load balance is a utilization problem, not just a scheduling one.
- Split K: no duplication, but each PE produces partial sums that must be added across PEs: 126 MB of int32 partial sums for the 512-token projection, 7.5× its weights. This needs a reduction network or a lot of buffer traffic.
These are the two collective patterns an accelerator’s on-chip network must support efficiently — multicast and reduction. MAERI (Lecture 5), Eyeriss’s multicast buses and SIGMA (Lecture 8) are built around them.
1.6 Pipelining layers across PEs
Instead of all PEs working on one layer at a time, each group of PEs can own one layer and pass activations along like an assembly line. Script 01, Part 4 runs four CNN layers on 16 PEs: layer-sequential achieves 0.83 utilization, layer-pipelined (4 PEs per layer) only 0.59. The pipeline’s throughput is set by its slowest stage, conv1, which takes 477 k cycles while the depthwise stage needs only 227 k, so the other stages wait. Pipelining across layers pays off only when the stages are balanced: each layer gets hardware in proportion to its work. That is a mapping problem, solved by the compilers of reconfigurable dataflow machines (Lectures 9, 12–13). Its advantage, when balanced, is that intermediate activations never leave the chip.
2. The processing element
2.1 MAGNet’s PE
MAGNet (NVIDIA Research, ICCAD 2019) is a generator: a parameterized C++/SystemC template, written with MatchLib and synthesized with HLS (Lecture 2), that produces DNN accelerators for a chosen set of parameters. The generated accelerator is a tiled array of processing elements connected by a network-on-chip, plus a global buffer and a controller. Each PE contains:
- vector MAC units —
lanesunits, each computing avec-wide dot product per cycle (vec multipliers + an adder tree); - a weight buffer and an input buffer feeding them;
- an accumulation buffer holding partial sums;
- address generators that walk the loop nest of the mapped layer;
- a post-processing unit (bias, activation, pooling, re-quantization);
- network interfaces to receive inputs and weights and send outputs.
The parameters — vector width, number of lanes, buffer sizes, the dataflow — are what MAGNet’s design-space exploration sweeps. The Simba multi-chip-module prototype (Shao et al., MICRO 2019) was built from this template, with PEs of eight 8-wide vector MAC units. Lab 1 asks students to design such a SIMD PE in HLS. pe.py is the same block as a Python model.
2.2 The model
input buffer (IB) ── one input vector (vec elements) per cycle, broadcast to all lanes
│
weight buffer (WB) ─▶ [lane 0: vec × multiply + adder tree] ─▶ accumulation buffer (AB) / accumulator register
─▶ [lane 1: ...] ─▶ ...
─▶ ... (lanes outputs per cycle)
The model computes with int8 operands and int32 accumulation. Its timing rules (Lecture 2’s vocabulary):
- one vector-MAC issue per cycle: all lanes in lockstep;
- the weight buffer delivers
wb_widthweights per cycle; - an accumulation-buffer read-modify-write takes
acc_latency= 3 cycles. The same accumulator can be updated again only 3 cycles later — a recurrence, exactly like the fp32 accumulator of Lecture 2; - is padded to a multiple of vec and to a multiple of lanes. The padded MACs are issued and wasted.
simulate() executes every issue with real integer arithmetic, and its result equals A @ B. estimate() gives the same cycles and access counts in closed form, so big layers cost nothing to evaluate. The self-test checks that the two agree on 300 combinations of shape, configuration and dataflow.
2.3 Dataflows are loop orders
The PE must read, for every MAC, one input, one weight and one partial sum. A dataflow decides which of the three stays inside the PE while the others stream past — in other words, which loop is innermost:
# Weight-stationary (WS): load a block of lanes x vec weights into lane registers, stream all M inputs past it
for n_tile in range(N // lanes):
for k_chunk in range(K // vec):
W_regs = WB[k_chunk, n_tile] # read once per block
for m in range(M): # inner loop: inputs stream
AB[m, n_tile] += A[m, k_chunk] @ W_regs # partial sums: read-modify-write in the accumulation buffer
# Output-stationary (OS): keep lanes accumulators in registers, stream inputs AND weights
for n_tile in range(N // lanes):
for m in range(M):
acc = 0 # accumulator registers
for k_chunk in range(K // vec): # inner loop: the reduction
acc += A[m, k_chunk] @ WB[k_chunk, n_tile] # weights read EVERY cycle
AB[m, n_tile] = acc # written once
# Input-stationary (IS): hold one input vector, stream all weight blocks past it
for m in range(M):
for k_chunk in range(K // vec):
x = A[m, k_chunk] # read once
for n_tile in range(N // lanes): # inner loop: output channels
AB[m, n_tile] += x @ WB[k_chunk, n_tile]
The three compute the same thing, but they read each storage a different number of times (§3) and they stall in different situations (§2.5).
2.4 Experiments: correctness and real layers
Script 02, Part 1 runs a 20 × 30 × 12 GEMM. All three dataflows produce exactly A @ B, and the closed form matches the simulated cycles. Padding alone caps utilization at (, ). WS reaches 0.68, OS 0.69 and IS 0.50. IS stalls because an input row’s accumulators come back every 2 cycles (2 n-tiles), sooner than the 3-cycle read-modify-write.
Part 2 runs the layer zoo:
| layer | WS | OS | IS |
|---|---|---|---|
| ResNet conv1 | 0.97 | 0.97 | 0.97 |
| ResNet 3×3, 1×1; Llama prefill, attention | 1.00 | 1.00 | 1.00 |
| MobileNetV2 depthwise | 0.07 | 0.07 | 0.04 |
| FC, batch 1 | 0.33 | 1.00 | 1.00 |
| Llama decode | 0.33 | 1.00 | 1.00 |
On channel-rich layers every dataflow is perfect. The losses come from two places:
- Shape mismatch: depthwise layers waste the lanes and most of the vector.
- No reuse: at batch 1, WS loads every weight block for one input row. The same accumulators come back after 1 cycle instead of 3, so two of every three cycles are stalls.
OS and IS hide the batch-1 problem only because this PE’s weight buffer delivers 64 weights per cycle. Part 4 shows what happens when it does not.
2.5 Small batches, double buffering, bandwidth
Script 02, Part 4 applies a 256 × 256 weight matrix to input rows:
| PE variant | M=1 | M=2 | M=3 | M=4 | M=8 | M=64 |
|---|---|---|---|---|---|---|
| WS, double-buffered, WB 64/cycle | 0.34 | 0.67 | 1.00 | 1.00 | 1.00 | 1.00 |
| WS, double-buffered, WB 16/cycle | 0.25 | 0.50 | 0.75 | 1.00 | 1.00 | 1.00 |
| WS, single-buffered, WB 16/cycle | 0.20 | 0.33 | 0.43 | 0.50 | 0.67 | 0.94 |
| OS, WB 64/cycle | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| OS, WB 16/cycle | 0.25 | 0.25 | 0.25 | 0.25 | 0.25 | 0.25 |
The rules behind the table:
- WS needs . Each weight block must be used by enough rows to hide its own loading and to space out updates of the same accumulator — the interleaved-accumulator rule of Lecture 2 in another guise.
- Double buffering — two sets of weight registers, one computing while the other loads — is what lets the load hide at all. Without it, utilization is and never reaches 1.
- OS and IS read lanes × vec weights every cycle. With a 16-wide weight buffer they are stuck at 0.25 for every : bandwidth, not reuse, is their bottleneck.
The general lesson is that every dataflow moves the bottleneck somewhere: WS to the batch size, OS/IS to the weight-buffer bandwidth.

Figure (script 02): utilization of the 8 × 8 PE vs the number of input rows sharing the weights.
2.6 The shape of the PE
With 64 multipliers fixed, should they be 8 lanes × 8 or 2 × 32 or 64 × 1? Script 02, Part 3 measures WS utilization on every layer and a time-weighted average over the six smaller layers (the two big transformer GEMMs are perfect on every shape). 2 × 32 and 4 × 16 tie at 0.69, 8 × 8 gives 0.66, and 64 × 1 gives 0.48. Wide vectors waste multipliers on short reductions: the 3-channel first layer runs at 0.77 on 1 × 64. Many lanes waste them on few output channels: depthwise, with one channel per group, runs at 0.02 on 64 × 1. Batch-1 layers lose two-thirds on every shape. A fixed shape is a compromise tuned to a workload mix — MAGNet’s reason for being a generator.
3. Energy accounting
3.1 Eyeriss in one paragraph
Eyeriss (MIT, ISSCC 2016 / JSSC 2017) is a 65 nm CNN accelerator with 168 PEs in a 12 × 14 array, a 108 KB global buffer and 16-bit fixed-point arithmetic. Its central contribution is an energy-centric view of dataflow. The chip’s energy is dominated by moving data, so a dataflow should be chosen to maximize reuse at the cheapest storage level. The companion paper (Chen, Emer, Sze, ISCA 2016) normalizes the energy of fetching one 16-bit operand from each level to the energy of a MAC:
| level | example | cost (MAC units) |
|---|---|---|
| ALU | one 16-bit MAC | 1 |
| RF | 0.5–1 kB register file inside each PE | 1 |
| array | PE-to-PE network | 2 |
| global buffer | 100–500 kB shared SRAM | 6 |
| DRAM | off-chip | 200 |
The chip implements the row-stationary dataflow (§3.4) and saves further energy by gating computation on zero activations and compressing zeros in DRAM traffic. The JSSC paper reports running AlexNet’s convolutional layers at 34.7 frames/s at 278 mW. The ISCA paper’s comparison under equal area found row-stationary 1.4–2.5× more energy-efficient than the other dataflows on AlexNet’s convolutional layers.
3.2 Accounting: accesses × cost
The method is simple and general:
Script 03, Part 1 applies it to the PE of §2. Access counts come from pe.estimate() (script 02, Part 5) and costs per access from Lecture 1’s 45 nm models. A storage’s cost grows roughly with the square root of its capacity, so a 128-byte register file is ~16× cheaper per byte than a 32 KiB buffer:
| storage / operation | capacity | pJ per element |
|---|---|---|
| int8 MAC | — | 0.300 |
| lane weight registers (int8) | 128 B | 0.156 |
| accumulator registers (int32, r + w) | 32 B | 0.625 |
| input buffer (int8) | 16 KiB | 1.768 |
| weight buffer (int8) | 32 KiB | 2.500 |
| accumulation buffer (int32) | 8 KiB | 5.000 |
On the ResNet 3×3 layer, the energy per useful MAC splits as follows (pJ):
| dataflow | MAC | weight regs | acc. regs | input buf. | weight buf. | acc. buf. | total |
|---|---|---|---|---|---|---|---|
| WS | 0.300 | 0.156 | 0 | 0.221 | 0.001 | 1.241 | 1.92 |
| OS | 0.300 | 0 | 0.078 | 0.221 | 2.500 | 0.009 | 3.11 |
| IS | 0.300 | 0 | 0 | 0.028 | 2.500 | 1.241 | 4.07 |
The arithmetic is 16% of WS’s energy and 10% of OS’s. The accesses per MAC (script 02, Part 5) explain every column:
- WS reads each weight from the buffer once per 3,136 rows (0.0003 accesses per MAC). But it read-modify-writes an int32 partial sum in the accumulation buffer every 8 MACs (0.25 accesses per MAC × 5 pJ).
- OS keeps partial sums in registers but reads the weight buffer for every MAC (1.0 × 2.5 pJ).
- IS pays both.
Which dataflow wins depends on the ratio of these costs and on the layer shape. That is why Eyeriss and MAGNet both study dataflows and do not assume one.
3.3 How much reuse does each level need?
Eyeriss’s costs make the job of the memory hierarchy explicit. A MAC needs 3 operand accesses (two inputs and a partial sum). Script 03, Part 2:
| all 3 operands of every MAC from | energy per MAC (MAC units) | arithmetic share | reuse needed for ≤ 1 MAC unit |
|---|---|---|---|
| RF | 4 | 25% | 3 |
| array | 7 | 14% | 6 |
| global buffer | 19 | 5% | 18 |
| DRAM | 601 | 0.2% | 600 |
A byte fetched from DRAM must feed ~600 MACs before DRAM stops dominating. Adding levels of reuse divides the cost of the level above. Each row below adds one level of the hierarchy:
| reuse profile | MAC | RF | array | buffer | DRAM | total |
|---|---|---|---|---|---|---|
| no reuse below DRAM | 1 | — | — | — | 600 | 601 |
| + global buffer (each DRAM operand used 100×) | 1 | — | — | 18 | 6 | 25 |
| + array (each buffer operand used 10×) | 1 | — | 6 | 1.8 | 6 | 14.8 |
| + register files (each array operand used 10×) | 1 | 3 | 0.6 | 0.18 | 0.6 | 5.4 |
The final profile is what a good accelerator aims for. Most accesses are served by the register file, at the cost of a MAC, and every outer level is touched a hundred or a thousand times less often. The innermost level matters most because it is touched most: three accesses per MAC.
3.4 Row-stationary, counted
Row-stationary (RS) maps a 2D convolution onto an R × E array of PEs (R filter rows, E output rows). PE computes the 1D convolution of filter row with input row :
- filter rows are read once from the buffer and multicast across a row of PEs, then stay in their register files (“row-stationary”);
- input rows are read once and multicast along a diagonal of PEs (all with need input row ); each PE keeps a sliding window of inputs in its register file, so each input is reused times;
- partial sums accumulate in each PE’s register. Each PE then passes its row of partial sums to the PE below, which adds its own; the last row writes the output.
All three kinds of reuse — filter (across output columns), input (across the sliding window and the diagonal) and partial sum (down the column) — happen in registers and the array, not in the buffer. Script 03, Part 3 executes a 32 × 32 convolution with a 3 × 3 filter both ways and records where every operand was read:
| dataflow | correct | MACs | RF accesses | array transfers | buffer accesses | MAC units per MAC |
|---|---|---|---|---|---|---|
| no local reuse | yes | 8,100 | 0 | 0 | 31,500 | 24.3 |
| row-stationary | yes | 8,100 | 28,980 | 4,950 | 1,933 | 7.2 |
RS reads every weight and every input from the buffer exactly once () and writes every output once (). The buffer traffic falls 16×, and the remaining energy sits in the register files, which is where Eyeriss wants it. Real layers add input channels: each PE also accumulates over several channels in its RF before passing partial sums on, multiplying the reuse further.
3.5 The whole stack
Script 03, Part 4 adds compulsory DRAM traffic (every input, weight and output byte moved once; 162.5 pJ/B, Lecture 1) to the PE energy:
| layer | MACs per DRAM byte | MAC | registers | PE buffers | DRAM | total pJ/MAC | DRAM share |
|---|---|---|---|---|---|---|---|
| Llama q_proj, 512 tokens | 410 | 0.30 | 0.16 | 1.48 | 0.40 | 2.33 | 17% |
| ResNet 3×3 | 264 | 0.30 | 0.16 | 1.46 | 0.62 | 2.54 | 24% |
| ResNet 1×1 | 50 | 0.30 | 0.16 | 1.45 | 3.23 | 5.13 | 63% |
| MobileNetV2 depthwise | 4.5 | 4.27 | 2.22 | 16.5 | 36.2 | 59.1 | 61% |
| Llama decode, batch 1 | 1.0 | 0.30 | 0.16 | 3.97 | 162.6 | 167.0 | 97% |
(The depthwise layer’s PE terms are large because its padded MACs, utilization 0.07, are charged to its few useful ones.)
The layers spread over two orders of magnitude of reuse. Large GEMMs and 3×3 convolutions reuse each DRAM byte hundreds of times, so on-chip data movement — mostly the PE buffers — dominates their energy. 1×1 and depthwise layers spend more on DRAM than on everything else. Batch-1 decode touches every weight byte once: DRAM costs 542× the arithmetic, and no PE design can change that. Only reuse (batching), smaller weights (Lecture 4) or moving the arithmetic to the memory (Lectures 14–15) can.

Figure (script 03): energy per MAC by component (log scale). Arithmetic is the bottom slice of every bar.
4. Efficiency metrics and how they mislead
4.1 Definitions
| Metric | Definition | Caveat |
|---|---|---|
| peak throughput | MACs × clock × 2 (ops/s) | only at 100% utilization, at one precision |
| effective throughput | useful ops / time on a workload | depends on the workload; padding and sparse zeros are not useful ops |
| utilization | effective / peak | can be high for a slow chip (low peak) |
| energy efficiency | ops/s per W = ops/J; TOPS/W = ops/pJ | what is in the “W”? core, chip, board, DRAM? |
| energy per op | pJ/op = 1 / (TOPS/W) | at which voltage and clock? |
| area efficiency | ops/s per mm² | which node; does the area include SRAM, I/O? |
| energy per inference | J per image / per token | the metric users actually pay for |
| latency vs throughput | time for one request vs requests per second | usually not achievable at the same time |
4.2 One chip, seven numbers
Script 04, Part 1 describes one hypothetical chip — 4,096 int8 MACs at 1 GHz, the 45 nm energy model — in seven true ways:
| throughput claim | value | efficiency claim | TOPS/W | |
|---|---|---|---|---|
| peak dense int8 | 8.19 TOPS | multiplier + adder only, int8 | 6.67 | |
| peak int4 (2 MACs per int8 MAC) | 16.4 TOPS | multiplier + adder only, int4, “with sparsity” | 39.7 | |
| peak int4 “with 2:4 sparsity” | 32.8 TOPS | PE incl. registers and buffers, ResNet 3×3 | 1.16 | |
| effective, ResNet 3×3 | 8.19 TOPS | PE + DRAM, ResNet 3×3 | 0.85 | |
| effective, batch-1 LLM decode | 0.20 TOPS | PE + DRAM, batch-1 decode | 0.012 |
The throughputs span 164× and the efficiencies 3,309× — for the same silicon. None of the numbers is false; each answers a different question. A metric is meaningful only with its precision, sparsity convention, workload, utilization and power boundary stated. “Sparsity” numbers deserve particular care. 2:4 structured sparsity lets hardware skip half the multiplications when the weights have been pruned to that pattern, and vendors count the skipped operations as performed. The doubled number applies only to models pruned that way.
4.3 Peak vs effective
Script 04, Part 2 compares chip X (4,096 MACs, 100 GB/s) with chip Y (2,048 MACs, 400 GB/s):
| layer | X | Y | faster |
|---|---|---|---|
| ResNet 3×3, 1×1; Llama prefill | compute-bound | compute-bound | X by 2.0× |
| MobileNetV2 depthwise | 452 µs | 452 µs | tie (both use one lane) |
| Llama decode, batch 1 | 587 µs (DRAM) | 147 µs (DRAM) | Y by 4.0× |
| Llama decode, batch 16 | 590 µs (DRAM) | 459 µs (compute) | Y by 1.3× |
Which chip is “faster” depends on the mix. The six layers run once each favor X (3.77 vs 5.33 ms), because the big prefill GEMM dominates. A serving workload of one prefill and 512 decode steps favors Y by 3.8× (79 vs 303 ms). Peak TOPS predicts the speed only of kernels above the ridge point (Lecture 1). For LLM serving, most of the time is spent below it.
4.4 Latency vs throughput
Script 04, Part 3 runs one decode-step matrix (4096 × 14336) on chip X at growing batch sizes:
| batch | time per step (latency per token) | throughput | utilization | bound |
|---|---|---|---|---|
| 1 | 587 µs | 1.7 k tok/s | 0.02 | DRAM |
| 16 | 590 µs | 27.1 k tok/s | 0.39 | DRAM |
| 64 | 918 µs | 69.8 k tok/s | 1.00 | compute |
| 256 | 3.67 ms | 69.8 k tok/s | 1.00 | compute |
Up to (where weight-reading time equals compute time, Exercise 9), batching is nearly free: the weights are read once per step whatever the batch. Beyond it, latency grows linearly while throughput stays flat. “Latency at batch 1” and “throughput at batch 256” are two different operating points. Quoting both as if simultaneous is the most common sleight of hand in LLM hardware marketing. MLPerf Inference reports scenarios separately for this reason: single-stream (latency), multi-stream, server (throughput under a latency bound) and offline (pure throughput).
4.5 Comparing across process nodes
Two hypothetical designs: A at 2.5 pJ/MAC in 45 nm, B at 0.5 pJ/MAC in 7 nm. Which is the better architecture? A common practice is to “normalize” B to 45 nm with a scaling rule, energy ∝ (feature size). Script 04, Part 4:
| exponent α | B scaled to 45 nm (pJ/MAC) | better design |
|---|---|---|
| 0.5 | 1.27 | B |
| 1.0 | 3.21 | A |
| 2.0 | 20.66 | A |
The conclusion flips between α = 0.5 and 1 (they tie at α ≈ 0.87, Exercise 10). Classical Dennard scaling would suggest α ≥ 2. Since supply voltages stopped falling (Lecture 1), real gains per node are much smaller, and node names below ~20 nm are labels rather than dimensions. Cross-node comparisons should show their sensitivity to the scaling rule, or better, compare designs in the same node.
4.6 Datasheets
Script 04, Part 5 divides datasheet peak ops by TDP for the machines of Lecture 1:
| chip | process | best dtype | TOPS/W (best) | TOPS/W (bf16/fp16) |
|---|---|---|---|---|
| V100 | 12 nm | fp16 | 0.42 | 0.42 |
| A100 | 7 nm | int8 | 1.56 | 0.78 |
| H100 | 4N | fp8 | 2.83 | 1.41 |
| B200 | 4NP | fp4 | 9.00 | 2.25 |
| TPU v1 | 28 nm | int8 | 1.23 | — |
The “best” column improves 21× from V100 to B200, but half of that comes from changing the precision (fp16 → fp8 → fp4). At bf16/fp16 the improvement is 5.4×. GPU TDPs cover the whole board (including HBM), while some accelerator figures cover only the chip. All of these are peaks, reached only at 100% utilization.
4.7 Reporting honestly
MLPerf (MLCommons) is the community’s answer to these pitfalls. It fixes the models and datasets, the quality targets (a submission must reach a given accuracy), the scenarios (above) and the rules — in the closed division, the model may not be changed. MLPerf Power adds measured wall power under the same rules. For your own results — the project of this course — a checklist:
- State the precision, and whether throughput is dense.
- Report effective throughput on named workloads, with utilization.
- State the power boundary (core, chip, chip + DRAM, board) and how power was obtained (measured, simulated, modeled).
- Report latency and throughput at the same operating point, with the batch size.
- Name the process node and do not normalize across nodes without showing the sensitivity.
- Compare against a baseline run under the same rules, and keep the accuracy fixed.
5. Lab 1: designing the SIMD processing element
Lab 1 designs, in C++/SystemC with HLS, the kind of PE modeled in pe.py. The questions it raises map one to one onto this lecture:
| Design question | In the model | What to measure |
|---|---|---|
| how many lanes, how wide? | lanes, vec | utilization on the target layers (§2.6), area |
| which dataflow? | dataflow | cycles and accesses per MAC (§2.3–§3.2) |
| how wide must the weight buffer read be? | wb_width | OS/IS stalls, WS load time (§2.5) |
| double-buffer the weight registers? | double_buffer | small-M utilization (§2.5) |
| accumulator latency vs batch | acc_latency | WS/IS hazard stalls |
| buffer sizes | wb_bytes, ib_bytes, ab_bytes | energy per access (§3.2); capacity (Lecture 7) |
In HLS terms (Lecture 2), the lanes are an unrolled loop and the vector is an unrolled reduction tree, and II = 1 is the target. The buffers are partitioned arrays whose port counts must match the per-cycle reads. The PE’s interfaces to the rest of the accelerator are latency-insensitive channels. Labs 2–4 then add the vector unit (Lecture 6), the global buffer (Lecture 7) and the interconnect (Lecture 8).
6. Summary
- ML layers are loop nests with abundant independent parallelism (outputs) and reduction parallelism (dot products); the design problem is which loops to spread over the hardware.
- SIMD amortizes control over many multipliers; every accelerator’s core is “one decision, many MACs”.
- A mapping that fills an 8 × 8 unit perfectly on ResNet runs at 0.07 on depthwise convolution; no fixed mapping or PE shape is best for every layer.
- Splitting a layer across PEs costs broadcast (split M or N) or reduction traffic (split K) and load balance; pipelining layers costs stage balance.
- A PE’s dataflow is a loop order. WS needs enough batch to amortize weight loads and accumulator latency; OS/IS need weight-buffer bandwidth; double buffering hides loads.
- Energy = Σ accesses × cost. In the PE, buffers cost more than the arithmetic (the MAC is 10–16% of the total). Eyeriss’s costs (1 / 2 / 6 / 200) demand ~600× reuse of DRAM data, and the innermost level matters most.
- Row-stationary reads every input and weight from the buffer once and keeps all three kinds of reuse in registers and the array (16× fewer buffer accesses on a 3×3 convolution).
- With DRAM included, DRAM is 17% of the energy for prefill GEMMs and 97% for batch-1 decode.
- Headline metrics of one chip span 164× (TOPS) and 3,309× (TOPS/W). State precision, sparsity, workload, utilization, power boundary, operating point and node. Benchmark the way MLPerf does.
7. Common pitfalls
- “More parallel hardware = faster.” Only if the layer’s shape fills it: depthwise layers and batch-1 decode leave most multipliers idle (§1.4, §2.4).
- “The dataflow doesn’t matter for energy, the MACs are the same.” Accesses per MAC differ by orders of magnitude between dataflows (§3.2).
- “WS is always best.” It needs enough rows to amortize every weight block; at batch 1 it stalls (§2.5).
- “A convolution’s input is the im2col matrix.” That matrix repeats every pixel R × S times. Memory traffic must use the real tensor (this mistake made a 3×3 layer look DRAM-bound in a first version of script 03; see the code README).
- “TOPS/W of the multiplier = TOPS/W of the chip.” Registers, buffers, DRAM, leakage and I/O come on top (6.67 vs 0.85 vs 0.012, §4.2).
- “Sparse TOPS are TOPS.” Only for models pruned to the supported pattern.
- “Chip X has twice the TOPS, so it is twice as fast.” Not below the ridge point (§4.3).
- “Normalized to 45 nm, B is better.” Depends on the exponent you chose (§4.5).
8. Exercises
Exercise 1 (padding). A 20 × 30 × 12 GEMM runs on PEs of 64 multipliers. What is the padding-only utilization bound for shapes 8 × 8 (lanes × vec) and 4 × 16?
Answer
8 × 8: K = 30 → 4 chunks of 8 (30/32), N = 12 → 2 tiles of 8 (12/16): 0.9375 × 0.75 = 0.70 (script 02, Part 1). 4 × 16: K = 30 → 2 chunks of 16 (30/32), N = 12 → 3 tiles of 4 (12/12): 0.94. The better shape is the one whose widths divide the layer’s dimensions.
Exercise 2 (WS and small M). A WS PE has an accumulator read-modify-write latency of 5 cycles and loads a weight block in 2 cycles (double-buffered). What is its utilization for M = 1, 2, 5, 10 (ignoring padding and drain)?
Answer
Each block of M issues takes max(M, 2, 5) cycles: utilization M / max(M, 5) = 0.2, 0.4, 1.0, 1.0. The accumulator latency, not the weight load, is the binding constraint here. Without double buffering it would be M / max(M + 2, 5): 0.2, 0.4, 0.71, 0.83.
Exercise 3 (bandwidth). An OS PE has 16 lanes × 8 multipliers and a weight buffer that delivers 32 weights per cycle. What is its utilization on a large GEMM? How wide must the weight buffer be for full utilization, and what does that mean for its energy?
Answer
Each issue needs 128 weights, i.e. 4 cycles: utilization 0.25. Full utilization needs 128 weights per cycle — a wide (or heavily banked) buffer read every cycle, so the weight-buffer energy per MAC is one access per MAC (2.5 pJ for a 32 KiB buffer in our model), more than 8× the MAC itself. That is the price of output stationarity.
Exercise 4 (accesses per MAC). Derive the WS dataflow’s storage accesses per MAC for a large GEMM on a lanes × vec PE: input buffer, weight buffer, accumulation buffer, weight registers. Check against script 02, Part 5 (lanes = vec = 8, M = 3136).
Answer
Per issue: vec input reads shared by lanes × vec MACs → 1/lanes (0.125). Weights: lanes × vec read once per block of M issues → 1/M (0.0003). Accumulation buffer: lanes reads + lanes writes per issue → 2/vec (0.25; the first k-chunk has no read, giving 0.248). Weight registers: one read per MAC → 1. The formulas show the knobs: more lanes reduce input traffic, more rows reduce weight traffic, wider vectors reduce partial-sum traffic.
Exercise 5 (reuse and energy). With Eyeriss’s costs, a design serves each MAC with 3 RF accesses, 0.2 array accesses, 0.05 buffer accesses and 0.002 DRAM accesses. Compute the energy per MAC in MAC units and the share of arithmetic. Which level would you attack first?
Answer
1 + 3·1 + 0.2·2 + 0.05·6 + 0.002·200 = 1 + 3 + 0.4 + 0.3 + 0.4 = 5.1 MAC units; arithmetic 20%. The RF is the largest term (3 of 5.1). It can only shrink by making register accesses cheaper (smaller RFs, operand forwarding without storing) or by sharing one RF read among several multipliers (SIMD broadcast, i.e. what a wide vector unit does). DRAM and the array are next at 0.4 each.
Exercise 6 (row-stationary by formula). For an H × W input and an R × S filter (single channel, no padding), derive RS’s buffer accesses and compare with no local reuse. Check with script 03, Part 3 (32 × 32, 3 × 3).
Answer
RS reads each weight once (RS), each input once (HW) and writes each output once (EF, with E = H − R + 1, F = W − S + 1): 9 + 1,024 + 900 = 1,933. No local reuse reads 2 operands and writes 1 partial sum per MAC, and reads the partial sum back for all but the first MAC of each output: 3·8,100 + (8,100 − 900) = 31,500. Ratio 16×. In general the ratio grows with R·S, the number of MACs per output.
Exercise 7 (spatial split). A batch-1 decode GEMV (K = 4096, N = 14336) runs on 16 WS PEs (8 × 8, acc_latency 3). Splitting N gives 0.33 utilization. Why? Propose two changes that raise it, and say which one helps end-to-end performance on a real chip.
Answer
With M = 1, every weight block serves one issue, and the same accumulators return after 1 cycle instead of 3: two stall cycles per issue. Fixes: (a) an OS dataflow with a weight buffer wide enough for 64 weights per cycle per PE (utilization 1.0 at the PE level); (b) batching several sequences (M ≥ 3). On a real chip the weights come from DRAM once per step (Lecture 1, script 03 Part 4). Fix (a) makes the PEs fast but leaves the step DRAM-bound. Only (b) — more reuse per weight byte — raises end-to-end throughput.
Exercise 8 (decoding a headline). A vendor advertises “400 TOPS, 10 TOPS/W” for an accelerator, in a footnote “INT4, with 2:4 structured sparsity”. What are its dense int8 peak and, assuming an int4 MAC costs about a third of an int8 MAC’s energy (as in our 45 nm model), roughly its dense int8 arithmetic TOPS/W?
Answer
Dense int4 = 400/2 = 200 TOPS; dense int8 (int4 mode = 2 MACs per int8 MAC) = 100 TOPS. Efficiency: remove the sparsity factor → 5 TOPS/W dense int4. An int8 op costs ~3× an int4 op, so roughly 1.7 TOPS/W dense int8 — before any memory, leakage or I/O power that the headline may or may not include. (Our model: int8 MAC 0.300 pJ, int4 MAC 0.101 pJ, ratio 3.0.)
Exercise 9 (the batch where decode becomes compute-bound). Chip X has 8.19 TOPS and 100 GB/s. One decode step multiplies a 4096 × 14336 int8 matrix by B vectors. Find the batch above which the step is compute-bound, and compare with script 04, Part 3.
Answer
Weight time: 58.7 MB / 100 GB/s = 587 µs. Compute time per vector: 2 · 58.7 M / 8.19 TOPS = 14.3 µs. . The table shows B = 16 still DRAM-bound (590 µs) and B = 64 compute-bound (918 µs ≈ 64 × 14.3). Below throughput grows linearly with B at constant latency; above it, latency grows and throughput stays flat.
Exercise 10 (the break-even exponent). At what node-scaling exponent α do designs A (2.5 pJ, 45 nm) and B (0.5 pJ, 7 nm) tie?
Answer
→ . The ranking hinges on an exponent nobody knows to better than a factor of two, which is the argument for same-node comparisons.
Exercise 11 (programming: zero gating). Eyeriss gates (skips) computation when an input activation is zero. Add a zero_fraction argument to pe.energy() that removes that fraction of the MAC and weight-register energy, and estimate the saving on the ResNet 3×3 layer if 50% of activations are zero (typical after ReLU). Why is the saving much smaller than 50%?
Answer
Removing 50% of the MAC (0.300 pJ) and weight-register (0.156 pJ) energy saves 0.228 of 1.919 pJ/MAC, about 12%. Gating does not remove the buffer and accumulation-buffer accesses that dominate (1.46 pJ/MAC). It saves only the arithmetic and the innermost operand reads. To save more, the hardware must avoid moving zeros, through compression in buffers and DRAM (as Eyeriss does with run-length coding off-chip) or sparse formats (Lecture 8’s SIGMA).
Exercise 12 (programming: a 2D split). Extend split_layer in script 01 to split M across 4 rows of PEs and N across 4 columns (a 4 × 4 grid). Compute the input and weight traffic with row/column multicast (inputs multicast along a row of PEs, weights along a column) for the ResNet 3×3 layer. Compare with the pure M and N splits.
Answer
With multicast along rows and columns, each input byte leaves the buffer once (201 kB) and each weight byte once (37 kB) — the same as a full broadcast — and each PE receives 1/4 of the inputs and 1/4 of the weights. Without multicast: inputs 4× (each of the 4 PEs in a row needs its row’s inputs: 804 kB) and weights 4× (148 kB), much less than the 16× of a 1D split. Utilization: N = 64 over 4 columns gives 16 channels per PE (8 lanes × 2 tiles, no waste), M = 3136 over 4 rows gives 784 rows per PE: about 1.0. A 2D split with row/column multicast is how systolic arrays and NoC-based accelerators get both reuse and balance (Lectures 5, 8).
9. Further reading
- R. Venkatesan et al., “MAGNet: a modular accelerator generator for neural networks”, ICCAD 2019.
- Y. S. Shao et al., “Simba: scaling deep-learning inference with multi-chip-module-based architecture”, MICRO 2019 — the chip built with the MAGNet methodology.
- Y.-H. Chen, J. Emer, V. Sze, “Eyeriss: a spatial architecture for energy-efficient dataflow for convolutional neural networks”, ISCA 2016 — the dataflow taxonomy and the energy comparison.
- Y.-H. Chen, T. Krishna, J. Emer, V. Sze, “Eyeriss: an energy-efficient reconfigurable accelerator for deep convolutional neural networks”, IEEE JSSC 2017.
- V. Sze, Y.-H. Chen, T.-J. Yang, J. Emer, Efficient Processing of Deep Neural Networks (2020) — chapter 3 (key metrics and design objectives) and chapter 5 (dataflows).
- V. Sze et al., “How to evaluate deep neural network processors: TOPS/W (alone) considered harmful”, IEEE Solid-State Circuits Magazine 2020.
- P. Mattson et al., “MLPerf: an industry standard benchmark suite for machine learning performance”, IEEE Micro 2020; V. Janapa Reddi et al., “MLPerf inference benchmark”, ISCA 2020.
- NVIDIA, NVDLA open-source hardware documentation — another fixed-function PE design.
10. Next lecture
Lecture 4, Quantization, attacks the cost of every term in this lecture’s energy tables at once. Fewer bits per operand means smaller multipliers (cost ~ bits²), cheaper register and buffer accesses (cost ~ bytes) and less DRAM traffic. That last point is the only fix for the 97% DRAM share of batch-1 decode short of batching. We will build bit-exact encoders for INT8, FP8, FP6, FP4, the OCP MX block formats and NVIDIA’s NVFP4, measure their errors on Gaussian and heavy-tailed data, see why LLM activations with outliers are hard to quantize, and price each format’s multiply-accumulate in hardware.