attention_scaled
std.nn.attention_scaled · Level L1Scaled dot-product attention with the standard 1/√d scale computed inside the graph (Size, then Sqrt). Calls attention.
softmax(Q·Kᵀ / √d)·V
Signature
attention_scaled(Q: f64[m, d], K: f64[t, d], V: f64[t, e]) → f64[m, e]
Structure
The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks a call to another library function; select it to open that function.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Agrees with the reference
softmax((Q @ K.T) / np.sqrt(d), axis=-1) @ Vto 80 digits (100-digit arithmetic), on all 40 test cases. - All 649 float64 results inside the running error bound; the closest uses 8% of it.
- Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
- correctly rounded (the float64 nearest the exact value)
- 68%
- bit-equal to the NumPy formula in float64
- 95%
- largest error, in units in the last place
- 140
Large ulp counts appear only where cancellation drives a result toward zero; the absolute error is still inside the bound.
Identity
sha256:bcd09cb93e1757202ae0aa382c14438762cc5535b794e9f483757090d1c50a0eThe semantic hash of the graph. It changes when the program changes, and never when only its documentation does.