Maps to: Stanford CS 217 Hardware Accelerators for Machine Learning (Winter 2026), Lecture 15 · Tue 03/03/2026 · Memory-Centric Computing (Part 2). Reading (from the schedule):
- N. Verma et al., In-memory computing: advances and prospects, IEEE Solid-State Circuits Magazine 11(3), 2019;
- the readings of Lecture 14 (Kautz 1969; Mutlu et al. 2025; Ma & Patterson 2026).
Basis: The slides are not public. This lecture follows the session title and Verma et al.’s framing: in-memory computing amortizes memory access over many rows, and pays for it in signal-to-noise ratio. The device and chip examples are published:
- IBM’s 64-core phase-change-memory chip, HERMES (Le Gallo et al., Nature Electronics 2023);
- PCM device statistics (Joshi et al., Nature Communications 2020);
- TSMC’s all-digital SRAM compute-in-memory macro (Chih et al., ISSCC 2021);
- the energy limits of ADCs (Murmann).
The experiments use a model written for these notes (
imc.py):
- a functional analog crossbar (bit-serial or pulse-width inputs, bit-sliced or analog weights, device noise, drift, ADC), exact when ideal;
- an energy model in which every per-event energy is assumed and varied;
- a small network trained and run on the crossbars.
Device and chip numbers are labelled as published. The experiments do not reflect what was said in class. Code:
code/lecture15/(4 scripts + 1 module; ~45 s in total) Reading time: 3 hours including running the code
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Explain how a crossbar of memory cells computes a matrix-vector product with Ohm’s and Kirchhoff’s laws, including signed weights.
- Map multi-bit weights and inputs onto devices (bit slicing, bit-serial and pulse-width inputs), and compute the number of conversions and the ADC resolution an exact result needs.
- Explain where the energy saving comes from (no weight movement; one bit-line evaluation for many rows) and where it goes (ADCs, many conversions, device energy, the chip around the arrays).
- Measure the accuracy of an analog MVM as SNR / effective bits, and attribute losses to ADC bits, ADC range, programming error, read noise and drift.
- Compare analog, digital in-memory and conventional digital computing at equal accuracy, and place published chips in that comparison.
- Apply the practices that make analog computing usable: calibrated ADC ranges, global drift compensation, hardware-aware training, hybrid digital/analog layers.
- Judge where in-memory computing fits: weight-stationary edge inference, not today’s LLMs, because of capacity.
0.2 Prerequisites and scope
| Assumed | Introduced here | Developed later |
|---|---|---|
| Lecture 1: energy per operation; data movement dominates | crossbars; SRAM and resistive (NVM) cells; current vs charge domain | AWS Trainium’s memory system (L16) |
| Lecture 4: integer quantization, SQNR, effective bits | bit slicing, bit-serial and PWM inputs; ADC resolution and range | NVIDIA’s numerics roadmap (L17) |
| Lecture 7: SRAM bit lines, banks | ADC energy regimes; kT/C; drift; digital in-memory computing | |
| Lecture 14: processing near memory; capacity vs bandwidth | hardware-aware training; global drift compensation; capacity of IMC |
0.3 Map
§1 computing with Ohm and Kirchhoff ← code 01 (Part 1)
§2 multi-bit numbers, the ADC, and why many rows at once ← code 01 (Parts 2-5)
§3 accuracy: ADC range, rows, devices, drift ← code 02
§4 energy: where the saving comes from and where it goes ← code 03
§5 a network on crossbars ← code 04
§6 where in-memory computing fits
§7 summary §8 pitfalls §9 exercises §10 further reading §11 next lecture
0.4 Notation
| Symbol | Meaning |
|---|---|
| IMC / CIM | in-memory computing / compute-in-memory |
| n | rows summed by one column before one ADC conversion |
| G, G_max | a device’s conductance; its largest programmed value (normalized to 1 in the code) |
| L = 2^c − 1 | the largest digit a c-bit cell (pair) stores |
| P | input levels per pulse: 1 for bit-serial, 2^b − 1 for a b-bit PWM pulse |
| unit current | one device at G_max driven by a full input pulse |
| SNR, ENOB | signal-to-noise ratio; effective bits = (SNR − 1.76 dB) / 6.02 |
| ν | drift exponent: G(t) = G(t₀)(t/t₀)^−ν |
| GDC | global drift compensation |
| HWA training | hardware-aware training (noise injected into weights during training) |
1. Computing with Ohm and Kirchhoff
1.1 One step further than Lecture 14
Lecture 14 put small processors next to DRAM banks. They see the banks’ internal bandwidth, but the bits still leave the array, cross a sense amplifier and travel to an adder.
In-memory computing removes even that. The array that stores the weights also multiplies and adds. Store each weight as a conductance and apply the inputs as voltages on the rows:
- Ohm’s law gives each cell a current : a multiplication;
- Kirchhoff’s current law adds the currents that meet on a column wire: an accumulation.
The column currents are the matrix-vector product, all columns at once:
Two savings follow, and the rest of the lecture weighs them against their costs.
- No weight movement. A GEMV reads every weight once per input vector. With weights in SRAM, the read costs ~10× the INT8 MAC itself in our model (§4.3); with weights in HBM, ~280×. In a crossbar, the weights never move.
- Access amortization (Verma et al.’s central argument). A normal memory reads one row per access: n rows need n bit-line swings. In-memory computing activates n rows at once, and one bit-line evaluation serves n MACs (§2.4).
The price is that the result is an analog quantity. It must be converted by an ADC, and it carries the noise of every device that produced it.
1.2 A crossbar by hand
Script 01, Part 1. Three outputs, four inputs, weights in {−2..3}, the published PCM maximum conductance G_max = 25 µS (Joshi et al.), inputs as voltages up to 0.2 V:
| column | weights | G+ (µS) | G− (µS) | I+ (µA) | I− (µA) | (I+ − I−) rescaled | W x |
|---|---|---|---|---|---|---|---|
| 0 | +2 −1 0 +3 | 16.7, 0, 0, 25.0 | 0, 8.3, 0, 0 | 4.58 | 0.83 | +2.250 | +2.250 |
| 1 | +1 +1 −2 0 | 8.3, 8.3, 0, 0 | 0, 0, 16.7, 0 | 2.50 | 0.00 | +1.500 | +1.500 |
| 2 | 0 +3 +1 −1 | 0, 25.0, 8.3, 0 | 0, 0, 0, 8.3 | 2.50 | 0.42 | +1.250 | +1.250 |
A conductance cannot be negative. Each weight therefore uses two devices, G+ and G−, and the column circuit subtracts their currents (differential sensing). The code does this subtraction in analog, before one conversion per column.
1.3 Which memory?
| SRAM cells | Resistive (non-volatile) devices: RRAM, PCM, flash | |
|---|---|---|
| what is stored | exact bits (one per 6T/8T cell) | an analog conductance; a few bits’ worth of levels |
| how the MAC happens | current domain (a transistor’s current) or charge domain (a capacitor per cell, charge shared on the column) | current domain (I = G V) |
| precision of a cell | exact digital value; mismatch of the transistor current (several %) or of the capacitor (much smaller) | programming error, read noise, drift over time |
| writing a weight | fast, unlimited | slow program-and-verify pulses; limited endurance |
| density | a 6T cell per bit; weights need several cells | one or a few devices per weight, stackable in the back-end |
| keeping weights | volatile (needs power) | non-volatile |
Published PCM numbers used in the code (Joshi et al. 2020):
- G_max = 25 µS;
- programming error below 1.2 µS, with a median of 0.94 µS (3.8% of G_max);
- drift with ν ≈ 0.06 on average.
Without compensation, their ResNet-32 fell to 10% accuracy within about 1,000 s.
Why the two families exist.
- SRAM gives exact bits in a standard logic process, so the analog part is only the summation, and charge-domain designs (Verma’s group) make that summation precise.
- Resistive devices give density and non-volatility, with an analog weight in one device pair, but every weight is a little wrong and slowly changes.
The two presets in the code, SRAM_LIKE and PCM_LIKE, follow these two philosophies.
2. Multi-bit numbers, the ADC, and why many rows at once
2.1 Pulses and slices
A cell stores at most a few bits, and a row line carries one voltage. An 8-bit × 8-bit product is decomposed:
- Bit-sliced weights. The magnitude of each weight is split into c-bit digits, each stored in its own column pair. The digital results are recombined with shifts (× 2^{c·s} for slice s).
- Bit-serial inputs. Input bit b is applied as a 0/1 pulse, the column is converted, and the result is weighted by 2^b.
- Pulse-width (PWM) inputs. The whole input magnitude is one pulse whose length is proportional to the value, so the column integrates the current. HERMES uses 8-bit PWM inputs.
- Signed inputs are applied in two passes (positive part, negative part). After a ReLU, inputs are unsigned.
Script 01, Part 2 (256-row tile, 8-bit weights, unsigned 8-bit inputs):
| mapping | slices | pulses | conversions per column | ADC bits for an exact sum | SNR, 8-bit ADC, full range | 8-bit, calibrated range |
|---|---|---|---|---|---|---|
| binary cells, bit-serial (SRAM-like) | 7 | 8 | 56 | 10 | 12.2 dB | exact |
| 2-bit cells, bit-serial | 4 | 8 | 32 | 11 | 6.2 dB | exact |
| analog 7-bit cells, bit-serial | 1 | 8 | 8 | 16 | 9.2 dB | 33.2 dB |
| analog 7-bit cells, PWM (PCM-like) | 1 | 1 | 1 | 24 | 4.4 dB | 40.5 dB |
With enough ADC bits every mapping reproduces the integer product exactly: the model’s error is 0, and the self-test checks it.
2.2 How many ADC bits does an exact sum need?
A column adds n products of an input level in {0..P} and a weight digit in {−L..L}. Its sum takes 2nLP + 1 integer values:
- 256 rows, binary cells, bit-serial: 513 values, so 10 bits.
- Analog 7-bit cells (L = 127) with 8-bit PWM (P = 255): 16.6 million values, so 24 bits. No practical ADC has that.
The design space is a trade between the number of conversions and their resolution. Fewer, richer analog steps (analog weights, PWM inputs) need exponentially finer ADCs. Bit-serial, bit-sliced designs make each conversion easy but do many of them.
2.3 The range a column CAN produce vs the range data USES
The exact-bits formula assumes the worst case: every row on, every weight at full scale and the same sign. Real data is nothing like that. Signed products mostly cancel, so a sum of n terms grows like √n, not n.
Script 01, Part 3 (binary cells, bit-serial, Gaussian weights, ReLU inputs):
| rows n | largest possible |signal| | 99.9th percentile | rms | possible / used | ADC bits saved |
|---|---|---|---|---|---|
| 16 | 16 | 5.0 | 1.24 | 3.2× | 1.7 |
| 64 | 64 | 9.0 | 2.30 | 7.1× | 2.8 |
| 256 | 256 | 17.0 | 4.46 | 15.1× | 3.9 |
| 1024 | 1024 | 32.0 | 8.48 | 32.0× | 5.0 |
An ADC whose full scale covers only what occurs, clipping the rare rest, saves about log₂√n bits. In the code, CrossbarArray.calibrate sets the range to the 99.9th percentile of the ideal column signals on calibration data. The ADC’s step is always a power of two of the unit current, so the digital shift-and-add stays a shift.
This is why the calibrated column in §2.1 is so much better than the full-range one: 4.4 → 40.5 dB for PWM, and 12.2 dB → exact for the bit-sliced mapping. For bit-sliced 1-bit sums, the calibrated 8-bit ADC never clips on this data.
2.4 Why activate many rows at once
Verma et al.’s argument.
- A conventional memory reads one row per access: each bit costs a bit-line swing, a sense amplifier and the trip to the logic, and n bits take n cycles.
- An in-memory array evaluates the bit line once for n rows. The energy per MAC stops growing with n, and throughput is n times higher.
- The price is that the column now carries an n-level analog value, which must be resolved and is exposed to noise.
Script 01, Part 4. One 1-bit dot product of n rows.
ASSUMED:
- 0.4 fF of bit line per cell;
- 0.8 V swing in memory, 0.1 V for a normal read;
- 2 fJ to sense a bit and 10 fJ to move it to separate logic;
- per-cell mismatch of 5% (current domain) and 0.5% (charge domain);
- the ADC of §4.1, at lossless resolution.
| rows n | row by row: bit line + add | + sense + move | in memory | of which ADC | saving (without / with move) | 1 LSB | noise in LSB (current / charge) |
|---|---|---|---|---|---|---|---|
| 16 | 2.0 fJ | 14.0 fJ | 8.3 fJ | 8.0 fJ | 0.2× / 1.7× | 50 mV | 0.14 / 0.014 |
| 64 | 3.5 | 15.5 | 8.3 | 8.0 | 0.4× / 1.9× | 12.5 mV | 0.28 / 0.028 |
| 256 | 9.7 | 21.7 | 8.3 | 8.0 | 1.2× / 2.6× | 3.1 mV | 0.57 / 0.057 |
| 1024 | 34.3 | 46.3 | 12.5 | 12.3 | 2.7× / 3.7× | 0.78 mV | 1.13 / 0.113 |
| 4096 | 132.6 | 144.6 | 49.3 | 49.1 | 2.7× / 2.9× | 0.20 mV | 2.26 / 0.226 |
(fJ per 1-bit MAC; row by row takes n cycles, in memory 1.)
Read the table in three ways:
- The bit line is amortized. Its share in memory is 0.26 fJ per MAC at every n, while reading row by row costs more as the bit line grows.
- The ADC eats most of the saving. The ADC must resolve 2n + 1 levels. While its energy doubles per bit (§4.1), its share per MAC stays constant at ~8 fJ. Beyond ~11 bits it quadruples per bit and grows with n. Counting only the bit line, activating 256 rows saves just 1.2×; the clear gains are throughput (256×) and not moving bits to separate logic (2.6× with our assumptions).
- The LSB shrinks to V/n. At 256 rows one LSB is 3.1 mV, and a 5% mismatch of transistor currents is already 0.57 LSB of noise. Capacitors match ~10× better, which is why precise SRAM designs moved to the charge domain.
2.5 What physics allows
Script 01, Part 5.
| bits | ADC model (ASSUMED figures of merit) | bound 8kT·SNR | model / bound | smallest unit capacitor, 256 rows |
|---|---|---|---|---|
| 4 | 32 fJ | 0.013 fJ | 2,517× | 0.026 aF |
| 8 | 512 fJ | 3.3 fJ | 157× | 6.6 aF |
| 10 | 2,048 fJ | 52 fJ | 39× | 106 aF |
| 12 | 12,559 fJ | 832 fJ | 15× | 1,697 aF |
Thermal noise in the array is not the limit.
- Charge sharing averages the n cell voltages, so kT/C noise falls as the total capacitance grows.
- Even 12-bit precision on 256 rows needs only 1.7 fF of unit capacitance.
The limits are device mismatch and the ADC. The fundamental bound E ≥ 8kT·SNR (Murmann) sits far below real converters at low resolution, where switching, not noise, sets the energy. Above ~11 bits, the energy follows the bound’s slope: 4× per bit.
3. Accuracy: ADC range, rows, devices, drift
3.1 Measuring accuracy
The experiments of Script 02 use one layer:
- 256 outputs × 256 inputs (Part 2: 1,024 inputs);
- Gaussian weights and ReLU(Gaussian) inputs;
- 256 input vectors.
Accuracy is the SNR of the analog output against the floating-point product:
The digital references use the same quantization grids, with exact accumulation:
- INT8: 41.5 dB = 6.6 effective bits;
- INT4: 16.5 dB = 2.4 bits.
These are the output’s bits, after quantizing the inputs and the weights, not the format’s 8 or 4.
3.2 ADC bits and ADC range
Script 02, Part 1 (ideal devices):
| ADC bits | SRAM-like: full range | SRAM-like: calibrated | PCM-like: full range | PCM-like: calibrated |
|---|---|---|---|---|
| 4 | −0.3 b | 1.0 b | −0.3 b | 2.3 b |
| 5 | −0.1 b | 1.7 b | −0.3 b | 3.3 b |
| 6 | 0.4 b | 6.6 b | −0.3 b | 4.3 b |
| 8 | 1.7 b | 6.6 b | 0.3 b | 5.9 b |
| 10 | 6.6 b | 6.6 b | 2.3 b | 6.4 b |
| 12 | 6.6 b | 6.6 b | 4.3 b | 6.5 b |
(Negative effective bits mean the error is larger than the signal.)
- The range matters as much as the bits. A calibrated 6-bit ADC on the bit-serial, bit-sliced array is as accurate as INT8. A full-range one is useless.
- PCM-like conversions need more bits. The PCM-like array puts the whole 8 × 8-bit product into one conversion: even calibrated, 8 ADC bits give 5.9 effective bits, and ~10 are needed to approach INT8.
3.3 Rows per conversion
Script 02, Part 2 (1,024 inputs, 8-bit ADC):
| rows per conversion | tiles | PCM-like conversions/MAC | PCM: full range | PCM: calibrated | SRAM: calibrated |
|---|---|---|---|---|---|
| 32 | 32 | 0.031 | 10.5 dB | 5.5 b | 6.4 b |
| 128 | 8 | 0.0078 | 4.5 dB | 5.9 b | 6.4 b |
| 256 | 4 | 0.0039 | 2.1 dB | 5.6 b | 6.4 b |
| 1024 | 1 | 0.0010 | 0.1 dB | 5.6 b | 6.4 b |
The plan expected accuracy to fall as rows grew. With a calibrated range it barely changes.
- A conversion’s error grows like √n, as its signal does.
- The K/n partial sums then add the errors back to the same total.
With a full range, accuracy collapses with n. In this model, rows per conversion are almost free with calibration, while conversions per MAC fall 32×.
What stops real arrays at a few hundred rows lies outside the model:
- IR drop: the voltage lost along long, resistive wires makes a cell’s contribution depend on its position;
- the analog front-end must stay linear for the sums that do occur;
- small layers would leave large arrays mostly empty.
3.4 Device non-idealities
Script 02, Part 3 (PCM-like: analog weights, PWM inputs, calibrated 8-bit ADC; mean of 3 programmed arrays):
| programming error (of G_max) | read noise 0 | read noise 1% | read noise 3% |
|---|---|---|---|
| 0 | 5.9 b | 4.2 b | 2.6 b |
| 1% | 4.4 b | 3.8 b | 2.6 b |
| 2% | 3.4 b | 3.2 b | 2.4 b |
| 3.8% (published PCM) | 2.6 b | 2.5 b | 2.1 b |
| 8% | 1.5 b | 1.5 b | 1.4 b |
For comparison, b-bit weights with 8-bit inputs on the same data give 1.5 (3 bits), 2.7 (4 bits) and 3.8 (5 bits) effective bits.
The published programming error therefore makes the analog MVM about as accurate as 3–4-bit weights. This is consistent with HERMES’s statement that its weights are equivalent to 3–4 bits.
Devices, not the ADC, set the ceiling of analog weights.
3.5 Drift and global drift compensation
PCM conductance decays as a power law after programming, G(t) = G(t₀)(t/t₀)^−ν, with t₀ = 25 s here. Two parts matter:
- The mean exponent. It shrinks every output by the same factor: 0.74 after an hour and 0.43 after a year for ν = 0.06.
- The spread of ν across devices. It makes each weight decay differently. The error grows like σ_ν · ln(t/t₀).
Global drift compensation (Joshi et al.) reads the array once with a known input. It measures the factor α = ΣG(t)/ΣG(t₀) and divides the outputs by it, and it can be folded into the following batch normalization.
Script 02, Part 4 (SNR without / with GDC, other noise off):
| time | mean G(t)/G(25 s) | spread 0 | spread 0.02 | spread 0.04 |
|---|---|---|---|---|
| 1 hour | 0.742 | 11.8 / 35.8 dB | 11.6 / 19.7 dB | 10.9 / 14.5 dB |
| 1 day | 0.613 | 8.2 / 34.5 | 8.2 / 15.5 | 7.8 / 10.3 |
| 1 year | 0.430 | 4.9 / 32.0 | 5.0 / 10.6 | 4.9 / 5.7 |
| 10 years | 0.375 | 4.1 / 30.9 | 4.2 / 9.2 | 4.2 / 4.4 |
One measured factor removes the mean exactly. What remains is the spread (ASSUMED 0.02 in the preset), and it grows with log t.
A pitfall we hit. The first version of this experiment drew the test weights and the drift exponents from generators with the same seed. The “random” exponents were then the weights’ own Gaussian draws, perfectly correlated with W. Compensation made things worse, which no physical device would do.
Programming now uses independent seeds, and CrossbarArray documents the trap. Any simulation of “random” hardware errors must make them independent of the data they perturb.
3.6 Digitizing restores levels
Script 02, Part 5 (all non-idealities on):
| configuration | SNR vs float | SNR vs exact INT8 |
|---|---|---|
| PCM-like, 1 day after programming, GDC | 12.9 dB = 1.8 b | 12.9 dB |
| PCM-like, ideal devices | 37.3 dB = 5.9 b | 39.4 dB |
| SRAM-like, 0.5% capacitor mismatch, 8-bit ADC | 40.9 dB = 6.5 b | 50.2 dB |
| same mismatch, ideal ADC | 38.4 dB = 6.1 b | 41.5 dB |
| digital INT8 | 41.5 dB = 6.6 b | exact |
The bit-serial, bit-sliced array converts small integers. The calibrated ADC’s step is a fraction of a unit current, so rounding returns most mismatch errors to the correct integer. The coarse ADC result is closer to INT8 (50 dB) than the ideal ADC result (42 dB).
This is the old reason digital logic is robust: quantization regenerates levels as long as the noise stays below half a step.
The opposite case appears in Script 03, Part 2. A full-range 10-bit ADC has its own noise, ASSUMED to be 0.1% of a 256-unit full scale = 0.26 units. That noise corrupts the high-order conversions and leaves 2.9 effective bits.
4. Energy: where the saving comes from and where it goes
4.1 The ADC
Script 03, Part 1. ADC energy per conversion has two regimes in published surveys:
- Switching-limited (low resolution): energy ≈ FOM_W × 2^b. It doubles per bit. We ASSUME a Walden figure of merit of 2 fJ per conversion step.
- Thermal-noise-limited (high resolution): halving the noise voltage takes 4× the capacitance, so energy ∝ SNR. It quadruples per bit. We ASSUME a Schreier figure of merit of 180 dB.
| bits | 4 | 6 | 8 | 10 | 11 | 12 | 14 |
|---|---|---|---|---|---|---|---|
| model (fJ) | 32 | 128 | 512 | 2,048 | 4,096 | 12,559 | 200,895 |
The two regimes cross near 11 bits. Every bit an analog design saves at the ADC halves or quarters its largest energy term.
4.2 Energy per MAC, by component
Script 03, Part 2 (256 × 256 layer, array only, 22/28-nm-class assumptions; effective bits measured as in §3):
| configuration | cells | ADC | total fJ/MAC | TOPS/W | ADC share | eff. bits ideal / with devices |
|---|---|---|---|---|---|---|
| SRAM-like 8b × 8b, 10-bit ADC, full range | 17.9 | 448 | 478 | 4 | 94% | 6.6 / 2.9 |
| SRAM-like 8b × 8b, 8-bit ADC | 17.9 | 112 | 142 | 14 | 79% | 6.6 / 6.5 |
| SRAM-like 8b × 8b, 6-bit ADC | 17.9 | 28 | 58 | 35 | 48% | 6.6 / 6.6 |
| SRAM-like 4b × 4b, 5-bit ADC | 3.8 | 3.0 | 9.7 | 207 | 31% | 2.5 / 2.5 |
| PCM-like 8b × 8b PWM, 8-bit ADC | 19.0 | 2.0 | 21.3 | 94 | 9% | 5.9 / 1.9 |
| PCM-like 4b × 4b PWM, 6-bit ADC | 1.2 | 0.5 | 2.0 | 1,000 | 25% | 2.4 / 1.6 |
Rows, columns and shift-and-add make up the rest. “With devices” means the presets’ non-idealities: for PCM, 1 day after programming with GDC; for SRAM, 0.5% capacitor mismatch.
The ADC is where the saving goes, and can be kept.
- Bit-sliced SRAM-like arrays do 56 conversions per column, and their ADCs take 79% of the energy at 8 bits. Two fewer bits, still as accurate as INT8 with a calibrated range, cut the total 2.5×.
- PCM-like arrays convert once, and spend their energy in the devices. Then the devices’ noise limits the accuracy.
4.3 Compared with digital datapaths and published chips
Script 03, Part 3:
| way of computing | fJ per MAC | TOPS/W | source |
|---|---|---|---|
| digital INT8, weight-stationary (weights reused) | 111 | 18.0 | model |
| digital INT8 GEMV, weights from a 32 KB SRAM bank | 1,111 | 1.8 | model |
| digital INT8 GEMV, weights from HBM (L14: 31 pJ/B) | 31,311 | 0.1 | model |
| digital in-memory INT8 (AND + adder tree) | 201 | 10.0 | model |
| digital INT4, weight-stationary | 40 | 49.6 | model |
| digital in-memory INT4 | 42 | 47.1 | model |
| analog SRAM-like 8b × 8b, 6-bit ADC | 58 | 35 | model, array only |
| analog PCM-like 8b × 8b PWM, 8-bit ADC | 21 | 94 | model, array only |
| IBM HERMES, MVM at full utilization | 205 | 9.8 | published, whole chip |
| TSMC all-digital SRAM CIM | 22 | 89 | published, macro |
| H100, FP8 dense peak / TDP | 707 | 2.8 | datasheet, whole chip |
Three lessons follow.
- Analog wins big only against moving weights. Compared with a datapath that reads every weight from SRAM (1,111 fJ) or HBM (31,311 fJ), the analog array is ~20–540× cheaper. Against a weight-stationary digital array (111 fJ) the margin is ~2×.
- Whole chips give much of it back. HERMES’s ADC returns two 12-bit counts. With that readout, the model puts the array at 117 fJ per MAC. HERMES’s published 9.76 TOPS/W is 205 fJ per MAC, which leaves ~87 fJ per MAC (22 pJ per output) for everything else on the chip: the digital units, local memory and the on-chip network.
- Digital in-memory computing is a different trade. TSMC’s macro ANDs input bits with stored weight bits and sums them with an adder tree, so it is exact and scales with logic processes. In our model it costs about as much as a digital datapath whose weights are already local (42 fJ at INT4). Its gain is in avoiding weight reads, not in cheaper arithmetic. TSMC’s published 89 TOPS/W (22 fJ per MAC) is within 2× of the model’s INT4 number.
4.4 Energy at equal accuracy
Comparing TOPS/W without accuracy compares different things. A 21-fJ PCM MAC that delivers 1.9 effective bits is not a 111-fJ INT8 MAC.
Script 03, Part 4 gives, for each way of computing, the cheapest configuration that reaches a required accuracy (fJ per MAC, array only):
| accuracy needed | SRAM-like analog | PCM-like, ideal devices | PCM-like, devices (1 day) | digital weight-stationary | digital in-memory |
|---|---|---|---|---|---|
| ≥ 1.5 bits | 10 (4b×4b) | 2 | 2 (4b×4b) | 40 (INT4) | 42 |
| ≥ 2.0 bits | 10 | 2 | not reached | 40 | 42 |
| ≥ 4.0 bits | 24 (6b×6b) | 7 | not reached | 72 (INT6) | 107 |
| ≥ 6.3 bits | 58 (8b×8b, 6-bit ADC) | 27 (10-bit ADC) | not reached | 111 (INT8) | 201 |

- At ~2 bits analog is 4–20× cheaper than digital.
- At INT8-class accuracy the bit-sliced SRAM-like margin shrinks to ~2×.
- PCM-like devices do not reach 2 effective bits one day after programming. Their use depends on a network that tolerates that (§5).
4.5 Rows per conversion and the ADC’s share
Script 03, Part 5 (8b × 8b, calibrated 8-bit ADC, K = 1,024):
| rows n | SRAM-like fJ/MAC | ADC share | PCM-like fJ/MAC | ADC share |
|---|---|---|---|---|
| 32 | 1,002 | 89% | 36.7 | 44% |
| 256 | 142 | 79% | 21.3 | 9% |
| 1024 | 49.6 | 56% | 19.7 | 3% |
The ADC energy per MAC falls as 1/n. What remains is the cells’ energy, which no amortization removes. Together with §3.3, this is the reason designs want as many rows per conversion as IR drop and linearity allow.
4.6 Capacity
Script 03, Part 6:
| technology | weights per mm² | ResNet-50 (25.6 M) | Llama 3 8B | Llama 3 70B |
|---|---|---|---|---|
| IBM HERMES, whole chip (published 4.19 M weights, 144 mm²) | 29,127 | 879 mm² | 275,697 mm² | 2.4 M mm² |
| HERMES MVM arrays only (published 0.635 mm² per 65,536) | 103,206 | 248 mm² | 77,808 mm² | 683,618 mm² |
| SRAM CIM, 8-bit weights (ASSUMED 0.1 µm² cell, 50% efficiency) | 625,000 | 41 mm² | 12,848 mm² | 112,886 mm² |
| HBM3 (16 GB per stack, ASSUMED 110 mm² footprint) | 145 M | 0.18 mm² | 55 mm² | 485 mm² |
A HERMES-class chip holds 4.2 million weights. ResNet-50 needs 6 chips, and Llama 3 8B ~1,915.
Analog non-volatile arrays are weight-stationary by necessity. Reprogramming takes many program-and-verify pulses (HERMES allows up to 30 iterations per device) and wears the devices. So the whole model must fit on chip. That is natural for edge CNNs and far from LLM sizes, where a DRAM stack holds thousands of times more weights per mm² of package.
5. A network on crossbars
5.1 Setup
Script 04 trains a 256-256-128-10 ReLU MLP on noisy 16 × 16 “glyphs”: 10 classes of random strokes, jittered, shifted and noisy. It uses 30,000 training images and 5,000 test images (one standard error ≈ 0.3 points).
Each layer’s matrix product runs on its own crossbar. Biases, ReLUs and the argmax are digital.
- Input ranges are static, calibrated on training data.
- Each ADC range is calibrated on 500 training images.
- Analog results are the mean of 3 programmed “chips”.
Two models are trained:
- standard training;
- hardware-aware (HWA) training: every forward pass uses weights perturbed by Gaussian noise of 6% of each row’s maximum. That is slightly more than the √2 × 3.8% = 5.4% error of a PCM weight pair.
5.2 Results
Part 1 (25 s after programming):
| model | float | INT8 | INT4 | PCM-like, ideal devices | PCM-like | SRAM-like |
|---|---|---|---|---|---|---|
| standard | 92.6% | 92.5% | 91.6% | 92.5% | 92.1% | 92.5% |
| hardware-aware | 93.2% | 93.2% | 92.1% | 93.1% | 92.7% | 93.2% |
Classification tolerates far more error than the SNR of one MVM suggests. The PCM-like array delivers ~2.5 effective bits per MVM (§3.4) and loses half a point. This is a property of the task and the network, and it must be measured, not assumed.
Part 2: ADC bits (PCM-like, ideal devices): 3 bits 76.4%, 4 bits 88.1%, 5 bits 91.7%, 6 bits 92.1%, 8 bits 92.5%. With the preset’s devices, 8 bits gives 92.1%. Beyond 6 bits the gain is about the spread between chips: the devices, not the ADC, limit the result.
Part 3: programming error (read noise 1%):
| programming error | 0 | 3.8% (published) | 6% | 10% | 15% |
|---|---|---|---|---|---|
| standard | 92.5% | 92.2% | 91.6% | 88.9% | 82.5% |
| hardware-aware | 93.0% | 92.7% | 92.3% | 90.2% | 84.6% |
HWA training finds weights whose function survives perturbation, and the advantage grows with the error (+2.1 points at 15%). Part of its 0.5-point lead at 0% is regularization: it is also better in float.
Part 4: ten years of drift (PCM-like preset, ν = 0.06 ± 0.02):
| time | standard: none | standard: GDC | HWA: none | HWA: GDC |
|---|---|---|---|---|
| 25 s | 92.1% | 92.1% | 92.8% | 92.8% |
| 1 day | 90.5% | 91.5% | 91.0% | 92.2% |
| 1 month | 87.4% | 90.7% | 87.3% | 91.7% |
| 1 year | 82.9% | 90.0% | 81.2% | 90.7% |
| 10 years | 76.4% | 88.8% | 70.9% | 89.9% |

- GDC is the cheapest fix in the lecture. One measured scale factor per layer turns a 16-point loss into a 3-point loss over ten years.
- HWA training is not uniformly better. It helps with compensation, but without compensation it degraded faster than standard training (70.9% vs 76.4% after ten years). We did not investigate why. The lesson is to evaluate the practices together, not one at a time.
Part 5: which layer? (10% programming error; the other layers digital INT8):
| analog layers | accuracy | weights analog |
|---|---|---|
| layer 1 only | 91.5% | 66% |
| layer 2 only | 91.9% | 33% |
| layer 3 only | 91.4% | 1% |
| layers 1–2 (last layer digital) | 90.7% | 99% |
| all three | 88.9% | 100% |
The plan expected the last layer to dominate. In this network no single layer does: each alone costs about a point, and the losses add up. Keeping the small last layer digital recovers 1.8 points while 99% of the weights stay analog.
Hybrid designs keep such layers, and everything that is not a matrix product (normalization, activations, attention’s softmax), in digital units next to the arrays. HERMES has digital processing units in every core and a central one for that reason.
5.3 What makes analog computing usable
| problem | practice | where in the code |
|---|---|---|
| sums use a small part of the possible range | calibrate each ADC’s range on data; clip the rare rest | CrossbarArray.calibrate |
| conductance drift | global drift compensation: one measured factor per layer | mvm(compensate=True) |
| programming error, read noise | hardware-aware training with injected weight noise | train_mlp(weight_noise=…) |
| sensitive or small layers; non-GEMM ops | hybrid: digital units next to the arrays | analog_mlp_forward(digital_layers=…) |
| accuracy depends on the chip | evaluate over several programmed chips; report the spread | Bench.analog |
6. Where in-memory computing fits
On the energy roofline (Lecture 1). A digital accelerator’s energy per operation is roughly E_op + E_byte / I, where I is the arithmetic intensity with respect to the memory that holds the weights.
For a GEMV (I ≈ 1 FLOP per weight byte at batch 1), the second term dominates everywhere, and Lectures 13–14 attacked it by moving compute closer to the bytes. In-memory computing removes that term for weights. Its energy per MAC is set instead by the conversions, and those grow with the required precision. So the comparison that matters is:
- low arithmetic intensity on weights (GEMV, batch-1 inference, weights that must be read anyway) and modest precision → in-memory computing has a large advantage (§4.3: 20× vs SRAM reads);
- high intensity (large batches reuse each weight many times, so a weight-stationary digital array already amortizes the weight read) or high precision → the advantage shrinks to ~2× or disappears (§4.4).
Capacity decides the application.
- Analog non-volatile arrays hold millions of weights per chip, and every weight must stay put (§4.6). That fits always-on edge inference: keyword spotting, small CNNs, sensors. There the model fits, the batch is 1, and energy per inference matters most.
- For LLMs, with billions of weights, many users and long contexts, the weights live in DRAM or flash, and the right lever is bandwidth near memory (Lecture 14), not computing in it.
Digital in-memory computing (SRAM with AND gates and adder trees) gives up the analog gains to keep exactness and process scaling. It is the variant that commercial accelerators can adopt most easily.
7. Summary
- A crossbar computes y = W x in one step: Ohm’s law multiplies, Kirchhoff’s law adds; signed weights use device pairs.
- Multi-bit numbers trade conversions for resolution.
- Bit-sliced, bit-serial mappings need many easy conversions: 56 per column at 10 bits for 8 × 8.
- Analog weights with PWM inputs need one conversion that would need 24 bits to be exact.
- Real sums use √n of the possible range. Calibrating each ADC’s range saves ~log₂√n bits; at 256 rows a calibrated 6-bit ADC equals INT8 on bit-sliced arrays.
- The saving comes from not moving weights and from evaluating n rows at once.
- It goes to the ADCs: 2× per bit, 4× above ~11 bits, and 79% of a bit-sliced array’s energy at 8 bits.
- It also goes to the cells and the chip around the arrays (HERMES: ~87 of 205 fJ per MAC outside the array, by our model).
- Accuracy is set by the devices for analog weights. The published 3.8% PCM programming error is worth 3–4-bit weights. Drift shrinks outputs by 0.6× in a day. GDC removes the mean; the spread of ν remains.
- At equal accuracy, analog is 4–20× cheaper than digital at ~2 bits and ~2× at INT8-class accuracy (SRAM-like). Against weight reads from SRAM or HBM it is ~20–540× cheaper.
- Networks tolerate more than MVM SNR suggests.
- The MLP lost 0.5 points on PCM-like arrays.
- With GDC and HWA training it kept 89.9% (from 92.8%) after ten years of drift.
- Capacity limits the application: 29,127 weights per mm² (HERMES) means ~1,915 chips for Llama 3 8B. In-memory analog computing is for weight-stationary edge inference today.
8. Common pitfalls
- “TOPS/W says it all.” A 1,000-TOPS/W configuration that delivers 1.6 effective bits is not comparable to an INT8 datapath. Compare at equal accuracy (§4.4).
- “The ADC needs log₂(rows) + bits of resolution.” That covers the possible range. Real data uses ~√n of it, and a calibrated ADC needs far fewer bits (§2.3, §3.2).
- “More ADC bits is always better.” A coarse ADC aligned to unit steps regenerates levels, and a full-range high-resolution ADC can lose to its own noise (§3.6).
- “Array energy = chip energy.” The arrays are a minority of a whole chip’s energy in our HERMES check (§4.3).
- “Analog in-memory computing is for LLMs.” The weights do not fit, and non-volatile arrays cannot be rewritten per request (§4.6, §6).
- “Drift ruins analog computing.” The mean drift is removed by one factor per layer (GDC). The spread is what remains (§3.5, §5.2).
- “Random hardware errors in a simulation are random.” Not if their generator shares a seed with the data. Our first drift experiment showed compensation hurting for exactly that reason (§3.5).
- “Hardware-aware training always helps.” It helped with programming error and with compensated drift, and it hurt without compensation (§5.2).
9. Exercises
Exercise 1 (exact ADC bits). A 128-row array stores 2-bit weight digits and receives bit-serial inputs. How many ADC bits does an exact signed column sum need? And with 4-bit PWM inputs (P = 15)?
Answer
Bit-serial: 2 × 128 × 3 + 1 = 769 values, so 10 bits.
With 4-bit PWM inputs: 2 × 128 × 3 × 15 + 1 = 11,521 values, so 14 bits.
Exercise 2 (conversions). 6-bit signed weights are stored in 2-bit cells, and the inputs are unsigned 6-bit, bit-serial. How many conversions per column per input vector does a 1,000-input layer need on 256-row tiles?
Answer
- Weight slices: ⌈5/2⌉ = 3 (5 magnitude bits).
- Pulses: 6.
- Tiles: ⌈1000/256⌉ = 4.
Total: 3 × 6 × 4 = 72 conversions per column.
Exercise 3 (ADC energy per MAC). Check the 112 fJ per MAC of the SRAM-like array’s ADCs (§4.2) from first principles.
Answer
There are 7 slices × 8 pulses = 56 conversions per column, each summing 256 rows. An 8-bit conversion costs 2 fJ × 2⁸ = 512 fJ.
56 × 512 fJ / 256 MACs = 112 fJ per MAC.
Exercise 4 (HERMES’s peak). HERMES has 64 cores of 256 × 256 and a published MVM latency of 133 ns. Reproduce its published 63.1 TOPS. What does its published 9.76 TOPS/W imply for its power at that throughput?
Answer
2 × 64 × 256² ops / 133 ns = 8.39 × 10⁶ / 1.33 × 10⁻⁷ = 63.1 TOPS.
Power: 63.1 / 9.76 = 6.5 W.
Exercise 5 (drift). With ν = 0.06 ± 0.02 and t₀ = 25 s, estimate the mean conductance factor and the residual relative weight error after GDC at one year. What SNR does that suggest? Compare with §3.5.
Answer
ln(t/t₀) = ln(3.15 × 10⁷ / 25) = 14.05.
- Mean factor: e^(−0.06 × 14.05) = 0.43.
- Residual relative error: ≈ σ_ν × ln = 0.02 × 14.05 = 0.28.
- SNR ≈ −20 log₁₀ 0.28 = 11 dB.
The model measured 10.6 dB.
Exercise 6 (range). At 256 rows, the 99.9th percentile of bit-serial column sums was 17 unit currents. Using the √n law, predict it at 1,024 rows, and the number of ADC bits a calibrated range then saves compared with the full range.
Answer
17 × √4 = 34 (measured: 32).
Bits saved: log₂(1024 / 34) ≈ 4.9 (measured: 5.0).
Exercise 7 (when does reading weights stop mattering?). A digital INT8 datapath reads each weight from SRAM (1,000 fJ per byte in the model, on top of a 111-fJ MAC) but reuses it for a batch of B input vectors. For which B is its energy per MAC within 2× of the SRAM-like analog array (58 fJ)? Within 10%?
Answer
Energy per MAC = 111 + 1,000 / B.
- Within 2× (116 fJ): 1,000 / B ≤ 5, so B ≥ 200.
- Within 10%: never. The weight-stationary limit (111 fJ) is already 1.9× the analog array.
Reuse removes the weight-read argument for analog computing, but not the ~2× MAC advantage of §4.3.
Exercise 8 (kT/C). What unit capacitance keeps kT/C noise below half an LSB for a 10-bit conversion of a 1,024-row charge-sharing column with a 0.8 V swing? Is it a constraint?
Answer
- LSB = 0.8 / 2¹⁰ = 0.78 mV; half an LSB = 0.39 mV.
- C ≥ kT / (n (LSB/2)²) = 4.14 × 10⁻²¹ / (1024 × 1.53 × 10⁻⁷) ≈ 26 aF.
Real cell capacitors are ~1 fF, 40× larger. It is not a constraint; mismatch is.
Exercise 9 (digitization as regeneration). On the SRAM-like array, an 8-bit calibrated ADC gave 50 dB from exact INT8, while an ideal ADC with the same mismatch gave 42 dB. Explain. When would the ADC instead make things worse?
Answer
Why the coarse ADC helps. Each bit-serial, bit-sliced column sum is an integer number of unit currents. The calibrated ADC’s step is a fraction of a unit, and the mismatch error per conversion (0.5% × √(active devices) ≈ 0.06 units) is far below half a step of one unit. Rounding therefore usually lands on the correct integer, and the error disappears. An ideal ADC passes the error through, and the error is then multiplied by up to 2⁶ × 2⁷ in the shift-and-add.
When it hurts. When the noise approaches half a step: large mismatch, many active rows, or the ADC’s own noise at full range (§3.6: 2.9 bits). Then rounding errors of a whole unit in high-order slices dominate.
Exercise 10 (hardware-aware training). Why train with 6% weight noise when the expected error of a PCM weight pair is √2 × 3.8% = 5.4% of the maximum? What happens if the training noise is far too large?
Answer
Why slightly more noise. The hardware also has read noise, ADC noise and drift spread, which add to programming error. A margin covers them, and noise injection also regularizes (+0.6 points in float here).
Why not far more. Too much noise forces the network into weights whose function barely depends on any single weight. That costs clean accuracy, the regularizer turns into underfitting, and the gain against moderate hardware noise disappears.
Exercise 11 (capacity). How many HERMES chips (published: 4.19 M weights, 63.1 TOPS) would hold Llama 3 8B (8.03 B weights)? Ignoring everything else, what would their total peak be, and how does a batch-1 decode step (2 FLOPs per weight) compare with an H100?
Answer
8.03 × 10⁹ / 4.19 × 10⁶ ≈ 1,915 chips. Their total peak is 1,915 × 63.1 TOPS = 121 POPS.
The decode step. It needs 16 GOPs: ~0.13 µs at full utilization, plus 32 layers of inter-chip communication. An H100 reads 16 GB (bf16) at 3.35 TB/s, about 4.8 ms. In raw compute time the crossbars would be ~10⁴× faster per token, but they would occupy ~276,000 mm² of silicon (at 144 mm² per chip) for one copy of the model.
The point is not the speed. One model would take thousands of chips, and every new model or fine-tune would need reprogramming.
Exercise 12 (design). You need ~4 effective bits per MVM for an always-on keyword-spotting network of 200 k weights, at minimum energy. Using §4.4, pick a technology and configuration, and list the practices of §5.3 you would apply.
Answer
The configuration. The model fits on a fraction of one chip (200 k weights; HERMES holds 4.2 M). §4.4 gives the cheapest ≥ 4-bit configurations:
- PCM-like with ideal devices, 6b × 6b with an 8-bit ADC: 7 fJ;
- SRAM-like, 6b × 6b with a 5-bit ADC: 24 fJ;
- digital weight-stationary INT6: 72 fJ.
PCM-like devices with the published programming error do not reach 4 bits, so either relax the target and rely on the network’s tolerance (§5.2), or choose the SRAM-like charge-domain array: exact bits, 0.5% mismatch, ~3× cheaper than digital.
The practices. Calibrated ADC ranges, hardware-aware training, the last layer and non-GEMM operations in a small digital unit, and evaluation over several chips. With PCM, also GDC at power-up.
10. Further reading
- N. Verma et al., “In-memory computing: advances and prospects”, IEEE Solid-State Circuits Magazine 11(3), 2019.
- A. Sebastian, M. Le Gallo, R. Khaddam-Aljameh, E. Eleftheriou, “Memory devices and applications for in-memory computing”, Nature Nanotechnology 15, 2020.
- M. Le Gallo et al., “A 64-core mixed-signal in-memory compute chip based on phase-change memory for deep neural network inference”, Nature Electronics 2023 (arXiv:2212.02872).
- V. Joshi et al., “Accurate deep neural network inference using computational phase-change memory”, Nature Communications 11, 2020 (arXiv:1906.03138).
- S. Ambrogio et al., “An analog-AI chip for energy-efficient speech recognition and transcription”, Nature 2023.
- H. Valavi, P. Ramadge, E. Nestler, N. Verma, “A 64-tile 2.4-Mb in-memory-computing CNN accelerator employing charge-domain compute”, IEEE JSSC 54(6), 2019.
- Y.-D. Chih et al., “An 89TOPS/W and 16.3TOPS/mm² all-digital SRAM-based full-precision compute-in-memory macro in 22nm for machine-learning edge applications”, ISSCC 2021.
- A. Shafiee et al., “ISAAC: a convolutional neural network accelerator with in-situ analog arithmetic in crossbars”, ISCA 2016.
- B. Murmann, “ADC performance survey” (online data) and “Energy limits in A/D converters” (2012/2013).
- T. Andrulis, J. Emer, V. Sze, “Modeling analog-digital-converter energy and area for compute-in-memory accelerator design”, 2024 (arXiv:2404.06553).
11. Next lecture
Lecture 16 is a guest lecture on AWS Inferentia and Trainium, the accelerators a cloud provider builds for itself. We return from the memory array to a whole chip and a whole data center:
- why a cloud builds its own silicon;
- how a NeuronCore splits work across tensor, vector, scalar and general-purpose engines with software-managed on-chip SRAM;
- how chips are connected into servers and UltraServers.
The model will schedule a transformer layer across those engines, the way Lectures 9–10 mapped layers onto our own accelerator.