6.5.8 · D4Advanced & Emerging Architectures

Exercises — Neural processing units (NPUs)

2,036 words9 min readBack to topic

Before we start, one shared reference card so no symbol appears unexplained:


Level 1 — Recognition

L1.1

Which single operation makes up roughly 90% of neural-network inference runtime, and what atomic hardware operation is it built from?

Recall Solution

What: Neural-net inference is dominated by matrix multiplication. Why: fully-connected and convolution layers both reduce to , and each output element is a dot product . The atom: each dot product is a chain of multiply-accumulate (MAC) operations — multiply a pair, add to the running sum. So the whole workload is "billions of MACs."

L1.2

Match each term to its one-line meaning: (a) PE, (b) systolic array, (c) weight-stationary, (d) on-chip SRAM.

Recall Solution
  • (a) PE — Processing Element: one MAC unit computing .
  • (b) Systolic array — a 2-D grid of PEs where data flows rhythmically between neighbouring PEs (no global memory read per step).
  • (c) Weight-stationary — weights are loaded once and held inside each PE while activations stream past.
  • (d) On-chip SRAM — fast scratchpad memory near the compute holding weights/activations so we avoid the expensive trip to DRAM.

Level 2 — Application

L2.1

A matmul multiplies a matrix by a matrix. How many MACs does it take?

Recall Solution

Formula: where here , , . Why this formula: each of the outputs is a dot product of length , i.e. multiplies each.

L2.2

An array is PEs running at GHz. Give its peak TOPS.

Recall Solution

Formula: . The counts the multiply and the add in each MAC. What it looks like: see the figure below — the win is the area of the grid ( MACs every single tick), not the clock speed.

Figure — Neural processing units (NPUs)

L2.3

The same array runs a matmul with perfectly (ignore fill/drain). How many clock cycles, and how long in microseconds at GHz?

Recall Solution

Total MACs: . MACs per cycle: the full grid does per cycle. Time: cycles . Why it's exactly : with a weight-stationary grid holding the whole weight matrix, you stream all activation rows through — one row per cycle after fill — so result rows in cycles.


Level 3 — Analysis

L3.1

A layer maps onto a array but only uses of the columns and of the rows. Ignoring fill/drain, what is the utilisation and the effective TOPS if peak (at GHz) is TOPS?

Recall Solution

Peak check: TOPS. ✓ Busy PEs: out of . Effective TOPS: TOPS. Why: the idle columns are silicon doing nothing — the peak number assumes every PE fires every cycle, which a mismatched layer shape breaks.

L3.2

The naïve dataflow loads both operands from DRAM for every MAC. A DRAM read pJ and a MAC pJ. For MACs (from L2.1), compute total energy (a) naïve — 2 reads per MAC — vs (b) an ideal reuse case where each of the two operands is read once and reused for its whole traversal. Assume the reuse case does DRAM reads per PE-load but we count only the arithmetic dominated by MACs. Give the ratio (naïve DRAM energy) : (MAC arithmetic energy).

Recall Solution

Naïve memory energy: reads/MAC pJ pJ. Arithmetic energy: pJ . Ratio: . What it means: naïvely, memory movement burns 6400× the arithmetic energy — this is the number that justifies the whole systolic reuse machine. The factor is just "two DRAM reads costing pJ each vs one pJ MAC."


Level 4 — Synthesis

L4.1

You are given a silicon budget and told: an fp32 multiplier occupies area . Multiplier area scales roughly as (bit-width)². (a) How much smaller is an int8 multiplier? (b) If you swap all fp32 MACs for int8, how many times more MACs fit in the same area? (c) What is the peak TOPS gain (same clock)?

Recall Solution

(a) Area ratio: , so An int8 multiplier is 16× smaller. (b) Same area ⇒ 16× more MAC units. (c) Peak TOPS ; with more PEs (larger effective ) and unchanged , peak scales 16× too. Why NN accept it: networks are robust to quantisation noise (Quantization and int8 inference) — trained with noise and using tolerant nonlinearities — so inference at int8 typically loses <1% accuracy while giving this 16× density.

L4.2

Design choice: you must run a stream of small matmuls back-to-back. Would you choose a array or a array for utilisation, and why? (Ignore fill/drain differences for the estimate; a layer maps onto a region.)

Recall Solution

The mapping: a weight matrix occupies only a block of PEs. On the array: busy PEs out of On the array: busy PEs out of 100% utilisation. Conclusion: the small array is far better utilised for small layers. The giant array's peak TOPS is wasted marketing here — most PEs sit idle. This is exactly why real designs tile/batch small layers or pick array size to match typical layer shapes (Domain-specific architectures, Dataflow and data reuse).


Level 5 — Mastery

L5.1

A weight-stationary array at GHz runs a matmul with , , . The pipeline fill latency is cycles before the first full column emerges, then one result column per cycle for columns. (a) Total cycles including fill. (b) Ideal cycles ignoring fill. (c) Utilisation as (ideal / actual). (d) Effective TOPS.

Recall Solution

The weight matrix is exactly , so it tiles the whole grid — every PE holds one weight, all busy during steady state. (a) Fill: cycles. Steady state: stream activation rows ⇒ cycles. Total: (b) Ideal (no fill): the useful work is result columns at one per cycle cycles. (Equivalently .) ✓ (c) Utilisation: (d) Effective TOPS: peak TOPS. What it looks like: the fill/drain is the ramp on the figure below — the array "warms up" for 511 cycles doing partial work before hitting full rhythm. With a large this overhead shrinks; with tiny it dominates.

Figure — Neural processing units (NPUs)

L5.2

Same array and clock. You now have a choice: run the layer above (large ) or a layer with (same ). Compute utilisation for the case (with the -cycle fill) and explain, in one sentence tying to the Roofline model, why batching helps.

Recall Solution

Actual cycles: . Ideal useful cycles: . Why batching helps: with tiny the fixed -cycle fill overwhelms the cycles of real work, so the array is 97% idle — increasing (batching) amortises the fill and pushes you toward the compute-bound ridge of the roofline, where you actually exploit the TOPS.


Recall One-look summary of every numeric answer

L2.1 MACs · L2.2 TOPS · L2.3 cycles · L3.1 , TOPS · L3.2 ratio · L4.1 · L4.2 vs · L5.1 cycles, , TOPS · L5.2 .