Tech, ExplainedSemiconductors and devices
Part

In-memory computing

Doing the maths where the data lives.

INSIDE: AI ACCELERATORHOW IT WORKS · ONE 512 × 512 LAYER COMPUTED INSIDE THE MEMORYThe layer's2,62,144 weightsare written intoa 512 × 512 gridof cells, once512 inputsarrive andare applied tothe 512 rowsas voltagesEach cell passesa current set byits input andits weight: onemultiplicationThe currentsin each columnadd up on onewire: one sumper column512 convertersturn thecolumn currentsinto 512digital numbersNo weight leftthe memory, sono energy wasspent moving itALSO TALKS TOHigh-bandwidth memory (HBM)INSIDE: AI ACCELERATORHOW IT WORKS · ONE 512 × 512 LAYER COMPUTED INSIDETHE MEMORYThe layer's 2,62,144weights are written intoa 512 × 512 grid ofcells, once512 inputs arrive and areapplied to the 512 rowsas voltagesEach cell passes acurrent set by itsinput and its weight:one multiplicationThe currents in eachcolumn add up on onewire: one sum per column512 converters turn thecolumn currents into 512digital numbersNo weight left thememory, so no energy wasspent moving itALSO TALKS TOHigh-bandwidth memory (HBM)INSIDE: AI ACCELERATOR · ONE 512 × 512 LAYERCOMPUTED INSIDE THE MEMORYThe layer's 2,62,144 weights are writteninto a 512 × 512 grid of cells, once↓512 inputs arrive and are applied to the512 rows as voltages↓Each cell passes a current set by itsinput and its weight: one multiplication↓The currents in each column add up on onewire: one sum per column↓512 converters turn the column currentsinto 512 digital numbers↓No weight left the memory, so no energywas spent moving itALSO TALKS TOHigh-bandwidth memory (HBM)
A 512 × 512 grid of memory cells holds a layer's weights, inputs arrive as voltages on the rows, each column's currents add up, and converters turn 512 column currents into 512 numbers.
opens a page inside this one a page in the same scene a page in another scene a concept page a label only, with no page

In-memory computing means doing the arithmetic inside the memory that stores the data, instead of first moving the data to a separate processor. It is also called compute-in-memory. Its aim is to save energy, because in an ordinary chip, moving data costs far more energy than the arithmetic itself.

In an ordinary computer, the memory and the processor are separate. To multiply two numbers, the processor must read them from memory, carry them along wires to its cores, multiply them and write the result back. Measurements on chips show how unequal these steps are. Reading one 32-bit number from external memory chips (DRAM) takes roughly 640 picojoules of energy. Multiplying two 32-bit numbers takes about 4 picojoules. A picojoule is a millionth of a millionth of a joule. So the trip costs about 150 times as much as the sum. AI makes this worse. A model's numbers, called weights, run into billions, and all of them must be read again for every word of an answer. This is the memory wall.

How does in-memory computing avoid the trip? The main operation in AI is multiply-and-add: multiply each input by a weight, and add up all the results. Memory is laid out as a grid of cells, in rows and columns. In-memory computing stores each weight in one cell of the grid. The inputs are applied to all the rows at once, as voltages. Each cell then lets through an electric current that depends on both its input and its stored weight. That is the multiplication. The currents from all the cells in a column meet on one wire and add up. That is the addition. So each column produces one multiply-and-add result, and all the columns work at the same time. This kind of calculation is analog: the result is a current, not a number. A converter at the foot of each column turns the current back into a digital number.

Take, for example, one layer of a language model with 512 inputs and a 512 × 512 table of weights, which means 2,62,144 multiplications. The weights are written into a 512 × 512 grid of memory cells once, when the model is loaded. Each time new inputs arrive, all 2,62,144 multiplications and 512 additions happen in one pass through the grid. No weight leaves the memory, so no energy is spent carrying it to a processor.

There are trade-offs. Analog currents are slightly imprecise and pick up electrical noise, so results are less exact than digital arithmetic. That is acceptable for running trained models, which work well with lower precision, but less suited to training. Models must also be adjusted to fit the grid. Some designs therefore use digital circuits placed inside the memory, which are exact but save less energy. Start-ups building AI accelerators, some with engineers in Bengaluru, use both approaches.

Compare high-bandwidth memory (HBM). HBM shortens the trip between memory and processor by stacking memory right beside the processor. In-memory computing removes most of the trip. The page on training vs inference explains why this matters most for answering requests.

Tech, Explained is a part of ingrid.fyi. Every page explains one piece of technology in plain words.