Softmax across a row of tiles
Softmax turns a row of scores into probabilities. If the scores live on different processing elements (PEs), which values need to cross a tile boundary for every PE to normalize its own scores?
Run the experiment
| Schedule | Row traversals | Scalar-hop count | Max absolute error |
|---|
What each tile sends
Separate max and sum. Reduce local maxima along the row and broadcast the global max back. Each tile uses it to compute a stable local exponential sum. Reduce those sums, broadcast the denominator, and normalize locally.
Merge max and sum together. Each tile starts with a pair (m, s), where m is its local max and s is the sum of its exponentials after subtracting that max. To merge pairs A and B, take m = max(mA, mB) and compute s = sA × exp(mA − m) + sB × exp(mB − m). That rescaling puts both sums on the same basis. Reduce the pair, broadcast the final pair, and normalize locally.
For four tiles, the separate schedule takes four traversals with one scalar each. The merged schedule takes two traversals carrying two scalars each. Both move 12 scalar-hops, where one scalar crossing one neighbor link counts as one hop. The merged schedule cuts the number of traversals and adds rescaling math. The model does not account for queues, instruction timing, or overlap.
Mapping it to the Wafer-Scale Engine
In the Cerebras Labs SDK, Tungsten would compute the local max, sum, and rescaling. Paint would place the head, middle, and tail PEs and route a reduction in one direction and a broadcast back. The Cerebras broadcast and reduce tutorial shows that routing pattern for sums. The normalization math comes from Milakov and Gimelshein’s online softmax.
This browser model uses JavaScript floating-point arithmetic. A native follow-up would use the Labs SDK simulator to check target precision and measure cycles while varying row width and the number of scores per tile.
