§10.2.1Processing in Memory: Fundamentals & NVM

Part III Sze et al. pp. 245–251 · ~12 min read

  • processing in memory
  • word line
  • bit line
  • DAC
  • ADC
  • memristor
  • current-based PIM

§10.1 moved compute near the memory. Processing in memory (PIM, also “in-memory computing”) goes further: it moves the compute into the memory that stores the weights. This page covers the general PIM architecture — the crossbar model that every later subsection builds on — and its first technology instantiation, non-volatile memories.

Conventional vs in-memory — what stops moving

DNN processing can be phrased as matrix–vector multiplication (the full book’s Chapter 4 shows FC layers as one big matrix–vector product, and CONV layers reduced to it via the Toeplitz expansion — glossed here where needed). In a conventional design, both operands travel: the input-activation vector and the weight matrix are read from their memories into a MAC array. The number of weights readable at once is capped by the memory interface (read-out logic, ports) — capping operations per cycle, and with it throughput.

PIM’s move (Figure 10.2): put the compute inside the weight memory — weights are never read out. Only the inputs flow in and only computed results (partial sums or output activations) flow out. Two wins:

  1. Weight movement disappears — the cost of reading the A×B weight matrix is gone.
  2. Weight bandwidth explodes — parallel access is no longer limited by the memory interface; in theory the whole matrix participates at once.
Figure 10.2 — conventional vs processing in memory (click blocks)
high bandwidthhigh bandwidth — interface-limited!low bandwidthInput ActivationMemoryclick for detailsWeight MemoryA × B weightsclick for detailsCompute (e.g., MAC array)click for detailsresultspsums / output activationsclick for details
Blocks with a dot open up — click one to look inside.

The crossbar: Figure 10.3, live

The typical PIM design is a weight-stationary dataflow : weights sit still, inputs stream past them. Word lines (WLs) deliver the input activations to the storage elements; bit lines (BLs) collect the computed partial sums. Each storage element performs a multiplication; the accumulation across all elements on a column happens on the wire. An array of B rows × A columns can, in theory, use all A×B weights simultaneously: A dot products of B elements — A×B MACs — in one cycle. Step it yourself (the numbers are the book’s own toy example from Figure 10.7):

Figure 10.3, live — weight-stationary PIM array on the book’s toy example (input [1,2,0,3])
cycle 1 / 1 — the whole A×B array in one cycle
Columns in Array (A = 4) — one dot product each1203inputsDAC (drives WL)WL1×1=12×1=23×1=32×1=20×2=01×2=22×2=40×2=03×0=00×0=01×0=01×0=02×3=63×3=91×3=31×3=3BLRows (B = 4)ADC (reads BL accumulation)····partial sums (accumulating)
Cycle 1: rows 0, 1, 2, 3 drive their inputs on the word lines; columns 0, 1, 2, 3 accumulate products on their bit lines. Click any cell to inspect its MAC.

B = CHW = 4 rows, A = M = 4 columns: one cycle computes all 16 MACs, yielding the psum vector [7, 13, 10, 5]. Later (10.2.4) the same lab reruns with realistic limits — watch this 1 cycle become 12.

Three more properties of this array, from the book:

  • Input reuse for free: each input activation on a word line reaches all A columns — up to A-fold reuse without re-reading the input.
  • Tiny “MACs”: a storage element is 10–100× smaller in area (3–10× in edge length) than digital MAC logic, so the wires that deliver inputs are shorter — less routing capacitance, cheaper input delivery.
  • Converters at the edges: depending on input/output formats, DACs drive the word lines (cost scales with input precision) and ADCs resolve the bit lines (cost scales with psum precision, which grows with weight/input precision and with B, the number of values accumulated).

Aside — the ADC’s thermal-noise tax (book footnote 5)

An N-bit ADC must place 2N−1 decision boundaries. Thermal noise (∝ kT/C of its sampling capacitor) jiggles those boundaries dynamically and randomly — degrading the DNN’s accuracy, not just signal quality. Low-noise ADCs cost power and area, so ADC design is a genuine three-way trade (power / area / accuracy) that the book insists should be included when reporting PIM accuracy.

The same machine as a loop nest

The full book (its Chapter 5) writes dataflows as loop nestsparallel-for loops run spatially (all iterations at once, in hardware), plain for loops run temporally (one iteration per cycle). An FC layer with M output channels and inputs flattened to length CHW becomes Design 20 — note there is no temporal loop: everything happens in one cycle.

i = Array(CHW)          # input activations
f = Array(M, CHW)       # filter weights
o = Array(M)            # output partial sums

parallel-for m in [0, M):
    parallel-for chw in [0, CHW):
        o[m] += i[chw] * f[m, chw]

Mapping constraints: A ≥ M (a column per output channel) and B ≥ CHW (a row per input element). When they don’t hold with equality, part of the array idles — the under-utilization story of 10.2.4. A 1-D convolution (Design 21) adds one temporal loop over output positions q; each cycle uses all M×S×C weights, reuses each input activation C×S times, and accumulates M psums — with the same input value delivered again for different qs (the Toeplitz-expansion effect: convolution re-reads shifted input windows):

i = Array(C, W)         # input activations
f = Array(M, C, S)      # filter weights
o = Array(M, Q)         # output partial sums

parallel-for m in [0, M):
  parallel-for s in [0, S):
    parallel-for c in [0, C]:
      for q in [0, Q):            # temporal — Q cycles
        w = q + s
        o[m, q] += i[c, w] * f[m, c, s]

Constraints here: A ≥ M and B ≥ C × S.

10.2.1 Non-volatile memories: physics does the MAC

NVM brings the density argument: storage-plus-compute packed at roughly DRAM density, dense enough to hold entire models and replace off-chip memory. The storage elements are programmable resistive devices — memristors (as cross-point elements they can even sit at wire crossings without an access transistor).

The multiplication is Ohm’s law; the accumulation is Kirchhoff’s current law — the current-based approach :

A memristor MAC (Fig. 10.4a) — conductance × voltage = current; currents sum on the bit line
I  =  V1G1I1+V2G2I2I \;=\; \underbrace{V_1 G_1}_{I_1} + \underbrace{V_2 G_2}_{I_2}
termmeaningunitsdictated by
ViV_iword-line voltage — encodes input activation iVinput (via DAC)
GiG_idevice conductance (1/resistance) — programmed to the weightSstored weight
IiI_idevice current = the product Vi × GiAphysics (Ohm)
IIbit-line current = accumulated partial sumAphysics (Kirchhoff)
I₁ = V₁G₁24 µA
I₂ = V₂G₂24 µA
bit-line I (psum)48 µA

Worked example: V₁ = 0.6 V on a 40 µS device gives 24 µA; V₂ = 0.3 V on 80 µS gives 24 µA; the bit line carries their sum, 48 µA — a two-element dot product with zero transistors of arithmetic. Flash-based NVM does the same via the floating-gate transistor: the weight sets the threshold voltage V_T, and the device’s I–V characteristics produce I_DS(V_GS, V_T); currents again sum on the bit line.

VILRS / R_ON — steep slopelow resistance = high G = large weightHRS / R_OFF — shallow slopehigh resistance = low G = small weight(a) resistive NVM: slope of I–V = conductance = the stored weight (often just 2 states)V_GSI_DSdifferent V_T = different weights(b) floating-gate NVM: weight sets the threshold; I–V curves shift accordingly (Fig. 10.4 b/d)

Figure 10.4(b)/(d), recreated: the two ways a device’s I–V curve encodes a weight — as the slope (resistive LRS/HRS states) or as a threshold shift (floating gate).

NVM’s three unique challenges

  1. Writes are expensive. Programming memristors costs far more than SRAM/DRAM writes — so designs hold all weights resident rather than swapping per layer (the book likens it to FPGA designs like Brainwave and FINN that pin weights at synthesis). Chapter 3’s flexibility warning applies: model size becomes bounded by array capacity.
  2. Devices vary and bend. Device-to-device and cycle-to-cycle variations plus nonlinear conductance limit precision to 1–4 bits per device and shape the signaling: instead of encoding inputs as voltage amplitudes, many designs encode them in time pulse-width modulation at fixed voltage (unary coding), integrating current on a capacitor.
  3. No negative resistance. Signed weights need differential signaling — two storage elements (often two whole arrays) per weight — or must be avoided: binary weights as [0,1] with XNOR (or NAND) logic replacing multiplication (reduced-precision tricks from the full book’s Chapter 7).
The NVM device zoo — candidates and the properties that differentiate them
DeviceTraded properties
PCRAMphase-change RAMendurance · retention · write current · density · variation · speed
RRAM / ReRAMresistive RAMsame six axes
CBRAMconductive-bridge RAMsame six axes
STT-MRAMspin-transfer-torque magnetic RAMsame six axes
Dotted-underlined cells have explanations — click one.

The book points to in-depth treatments of how these device properties affect DNN processing — and notes work that flips the problem: design the device so it suits DNN processing (including in-place, parallel weight updates for training).

Simulation vs silicon — the reality gap

NVM-PIM results split sharply. Simulated designs demonstrate large models (VGG-class on ImageNet) and assume all 128–256 rows activate simultaneously. Fabricated test chips demonstrate MNIST-scale digit classification, activate at most ~32 rows (process variations, read-out/ADC limits), and use one bit per memristor. Read every PIM headline with §3.7’s test-setup checklist in hand.

Design takeaway

PIM trades the interface bottleneck for an analog computing problem: the multiply is a device property, the add is a wire law, and every non-ideality (variation, nonlinearity, noise) now lands directly on DNN accuracy. The next two pages instantiate this in SRAM and DRAM; 10.2.4 prices the whole bargain.

Check yourself

Check yourself — PIM Fundamentals & NVM

1.What data does a processing-in-memory architecture avoid moving, compared to a conventional design?

2.In the weight-stationary PIM array (Fig. 10.3), a MAC's multiply and accumulate map onto which physical elements?

3.How does a memristor perform a multiplication?

4.Why do NVM-based PIM designs typically require the memory to hold ALL of the DNN model's weights at once?

5.NVM devices cannot have negative resistance. Predict how signed weights are supported.

6.What gap does the book highlight between simulated and fabricated NVM-PIM results?

6 questions