The multiply happens all at once. The nonlinearity does not.
Count the operations in a layer and the activation function is one part in 577. Count the steps and it is the last one, and nothing in the next layer can begin until it is done. That asymmetry is invisible in an operation count and it is what sets how fast a model can run — and in compute-in-memory it costs more than it does in a digital part, for a reason that has nothing to do with the function itself.
Take the layer the convolution post counts: a 56×56 feature map with 64 channels, a 3×3 kernel, 64 output channels [1]. Every one of the 200,704 output values is a sum of 576 products, and then one nonlinearity is applied to it.
576 multiply-accumulates. One activation. The activation function is 0.17% of the layer's operations — one part in 577. On that accounting it barely exists, and that is roughly how it is treated: a footnote to the matrix multiply, a lookup table somewhere in the datapath.
Now count steps instead of operations. The 576 products are formed together, in one pass of the array. The one activation happens afterwards, on its own, and nothing in the next layer can begin until it has. The two numbers are measuring different things, and only one of them is about time.
The wide block is 576 multiply-accumulates happening together — the thing the array is for. Everything after it is serial and narrow, and in a bit-sliced design the first two stages repeat once per slice before a finished value exists at all. The activation is the cheapest box in the row. It is also the last one, which is the only property that matters to the schedule: the next layer's array cannot be driven until a value has crossed all of it. Drawn for this post; the boxes are stages, not durations, and no box is to scale.
The nonlinearities in a trained model are the residue of every optimisation that worked
A network needs the nonlinearity for a reason that also explains why it cannot be scheduled away. Stack two linear layers and you get B(Ax) = (BA)x: one matrix, one layer, and all the depth gone. The nonlinearity between them is the only reason the second layer is doing anything the first could not.
Which means the function is exactly the thing that cannot be folded into its neighbours — and the things that can be, are. Batch normalisation at inference is a fixed scale and shift per channel [2]. That is affine, so it folds into the preceding convolution's weights and disappears before the model is ever deployed. Scaling factors, bias terms, the requantisation between two linear stages: every one of them gets absorbed by a compiler that is working properly. What is left in the graph of a well-optimised model is the parts that provably cannot be moved, and the activation functions are most of them.
So a nonlinearity is not an inefficiency waiting to be removed. It is the boundary of what any optimisation is allowed to touch.
Depth is a count of barriers
A residual network named ResNet-50 is 49 convolutions and a fully connected layer [1], with a nonlinearity after almost all of them. That number is in the name. It is also, near enough, the number of times an inference has to stop being parallel.
This is where the accounting turns. Widen the array — more rows, more columns, more tiles working at once — and the time spent inside a layer falls. The number of barriers does not move at all. If one crossing costs t, a 50-barrier model pays 50 t before any array has done anything, however good the array is. Hardware sets the width. The model sets the depth, and the depth is a floor.
Neither of the two standard explanations for a slow workload covers this. It is not arithmetic-bound and it is not bandwidth-bound [6]; it is dependency-bound, and the dependency is the one thing in the graph that was never going to be optimised away.
Some nonlinearities are reductions, and those are the expensive ones
Not every nonlinearity is the same shape.
Pointwise functions — ReLU, GELU, SiLU — need element i and nothing else. A value can move on the instant it exists, so a long chain of them can be streamed, and the barrier is as short as the function.
Reductions cannot. Softmax needs a maximum and a sum over the whole row of scores before it can emit any element of its output [3], and a normalisation layer needs a mean and a variance over the whole vector. Nothing leaves until everything has arrived. That is a full stop in the schedule rather than a short one, and it is the reason the best-known optimisation in transformer inference is a reorganisation of the traffic around the softmax rather than a change to any arithmetic [4].
The distinction decides whether a layer can be streamed or has to be buffered, which is why our own model catalogue carries a field for it: for each model, whether a block attends across the whole feature map, so that a frame cannot be streamed straight through and the mapping has to hold a barrier there. It decides how a model is placed on the part. It is not a performance number and it is not reported as one.
Why the crossing costs more in compute-in-memory
In a digital accelerator the activation is a stage in the same datapath the sum is already in: the value is a number when the accumulator finishes, and the activation unit sits immediately downstream of the accumulators as its own pipeline stage [5]. The barrier is real there too. It is just short.
In an analog array the value is not a number when the sum finishes. It is a charge, a current or an interval. Crossing the barrier means leaving the analog domain and coming back:
- Convert the column's result, which is where the energy of the whole design goes — its own post.
- Combine the slices, because a single conversion holds a fragment of the value rather than the value [7]. Until they are combined there is no finished sum for a function to act on.
- Apply the function, which is a table lookup and the cheapest item on this list by a wide margin.
- Requantise and re-encode the result into something that can drive the next array's rows.
The function is step 3 of 4 and the least of them. The cost is the round trip, and the round trip exists because the arithmetic was analog, not because the activation was hard.
This also explains why the obvious fix does not work. If the converter applied the nonlinearity itself, step 3 would vanish into step 1 and the barrier would get shorter. It cannot, in an exact bit-sliced design, because at conversion time there is no finished sum to bend — that argument is set out, with what it is worth and who it is available to, in where the activation function goes. Note that the two posts are measuring different currencies and agree: the stage is cheap in energy and cheap in time, and the crossing is neither.
The shape of a layer decides how bad the ratio is
The 0.17% at the top of this post is not a constant. It is 576 divided into one, and 576 is a property of that particular layer.
One output value's worth of work, in each case: the multiply-accumulates that produce it, against the single nonlinearity applied to it. A depthwise 3×3 convolution produces each output from nine products, so the activation is a tenth of its operations rather than a six-hundredth — and depthwise convolutions are exactly what the models designed for small devices are made of. The architectures that were made efficient by removing multiplies are the ones whose remaining work is least like a matrix multiply.
Measured: Nothing. There is no measurement in this figure. Modelled: Every bar: products per output value divided into one, for the stated layer shape. It counts arithmetic only — no conversion, no accumulation, no data movement — which is the whole point of putting it next to the argument above rather than on its own.
Sources: [1]
The bottom bar is the one worth sitting with. A decade of making vision models cheaper has meant replacing dense convolutions with depthwise ones, which removes almost all of the multiplies and none of the activations. Measured in operations that looks like a tenfold saving. Measured in barriers it is the same model with the arithmetic stripped out of it, and the part that was never the problem is now a tenth of what remains.
What this means for a design, and what we are not saying
Two questions follow, and only the first of them is answerable in public.
How many crossings does an inference need, and what does each one have to touch? A crossing that is resolved on the die between two arrays is a different event from one that goes out to external memory and back. Every design in this field is, at some level, an answer to that question.
And how is the crossing itself built? That is our answer to give and we are not giving it here. The readout is pre-filing and these posts stop at the result; how a model's layers are arranged across the part is the part of the architecture we do not describe publicly at all.
What we do not know
We have no silicon, so we cannot price t. Everything above says that the barrier count is a floor and that the floor is set by the model; it does not say what one barrier costs in nanoseconds, and we will not until there is a process design kit under the design. Our simulator is cycle-level and bit-exact against the digital reference, which makes it the right tool for asking what a model does and the wrong one for asking how long it takes.
What we can say is that the quantity is countable today, from the model alone, before any hardware exists — and that it is the quantity a wider array does not improve.
References
- , “Deep residual learning for image recognition,” Proc. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016. doi:10.1109/CVPR.2016.90measured siliconCited for the layer shapes the worked example is drawn from, and for the fact that a residual network is named by its depth — the 50-layer version is 49 convolutions and a fully connected layer. Confirmed on Semantic Scholar; the Crossref cross-check was rate-limited.
- , “Batch normalization: accelerating deep network training by reducing internal covariate shift,” Proc. 32nd International Conference on Machine Learning, PMLR vol. 37, pp. 448–456, 2015. proceedings.mlr.press/v37/ioffe15.htmlmeasured siliconCited for what batch normalisation is. At inference it is a fixed per-channel scale and shift, which is affine, which is why it folds into the preceding convolution's weights and vanishes from the graph. The paper is the definition; the folding is standard engineering practice rather than a result in it.
- , “Attention is all you need,” arXiv:1706.03762; presented at the Conference on Neural Information Processing Systems, 2017, 2017. arxiv.org/abs/1706.03762reviewCited for the structure of a transformer block, and for softmax sitting inside attention where it must see a whole row of scores before it can emit any of them. Cited as the arXiv record, which is what we verified.
- , “FlashAttention: fast and memory-efficient exact attention with IO-awareness,” arXiv:2205.14135, 2022. arxiv.org/abs/2205.14135measured siliconCited because its contribution is a reorganisation of traffic around the softmax rather than a change to the arithmetic, which is the cleanest demonstration that the reduction, not the multiply, was the thing in the way.
- , “In-datacenter performance analysis of a tensor processing unit,” Proc. ACM/IEEE 44th Annual International Symposium on Computer Architecture (ISCA), 2017. doi:10.1145/3079856.3080246measured siliconCited for one structural fact about its architecture: the activation stage is a pipeline stage of its own, downstream of the accumulators and separate from the matrix multiply unit. The page range in the ACM proceedings could not be confirmed from a source we could reach, so it is left out.
- , “Roofline: an insightful visual performance model for multicore architectures,” Communications of the ACM, vol. 52, no. 4, pp. 65–76, 2009. doi:10.1145/1498765.1498785reviewThe two standard explanations for why a workload is slow: it is limited by arithmetic, or by moving operands. Cited for the distinction, and because the limit this post is about is neither of them.
- , “ISAAC: A Convolutional Neural Network Accelerator with In-Situ Analog Arithmetic in Crossbars,” ACM/IEEE International Symposium on Computer Architecture (ISCA), pp. 14-26, 2016. doi:10.1109/ISCA.2016.12simulationCited for bit-slicing: a multi-bit weight spread across several low-bit cells, with the partial products combined by shift-and-add outside the array. It is why a single conversion is a fragment rather than a finished value.