The rule
a @ b (or sf.matmul(a, b)) computes each output as dot of a row of a and a column of b: a sequential chain of fma from k = 0, saturating at each step, in the width of the data. Every output equals the 1-D sf.dot of that row and column bit for bit, which is tested.
Shapes
NumPy’s rules: 1-D operands are promoted and the extra dimension dropped, leading dimensions broadcast as a batch. A mismatch raisesSFShapeError on the host before anything runs:
Matmul plus bias
sf.addmm(a, b, d) is a @ b followed by one saturating add of d. It is a separate function because “the chain, then one add” is what the hardware’s mat_fma instruction is believed to do, and it is what the PyTorch linear layer uses for the bias.
On the device
With device arrays,@ is a heavy operation: it goes through the pre-flight gate, runs on the target, and returns a status.
exact=True comes from the range bound: the host computed that no partial sum of any output could exceed the maximum, so the launch was marked safe and no scan was needed. The device path →
Can it saturate?
A partial sum can pass the edge even if the final value would not, and once it saturates it stays there. The host’s bound is conservative: it uses the L1 norms of the rows and columns, which is tighter than the spec’sK × max|A| × max|B| and never looser. When the bound cannot prove safety, the probe samples real outputs; when it can prove every output saturates, the operation is refused before launch by default.
sf.config(suspect="raise") refuses on a suspicion; suspect="verify" replays the operation on the host and refuses only on proof.