1
Create a value
An sf16 value is a 16-bit fixed-point number between -1 and 1. Creating one rounds your input to the nearest representable value.0.1 is not exactly representable, so you get the nearest code.
sf never hides this: comparisons are exact, so b == 0.1 is False.2
Do arithmetic
The operators do what the chip does: exact integer arithmetic, truncated toward zero.
3
See what happens at the edge
Results that do not fit are not silent. The default policy raises on overflow and divide by zero and warns on underflow.To get the hardware value without the exception, change the policy for a block:The message always tells you the device value, because that is what the chip would have produced.
4
Move to arrays
Arrays follow NumPy’s rules and apply the scalar rules element by element.An event in any element is reported with a count:
5
Multiply matrices on the device
Place arrays on a target with
device= and the heavy operations run there. The result carries a status.exact=True here means the host proved before the launch that no partial sum could saturate, so the status is a fact, not a scan.What just happened
- Every value you saw is an integer code divided by 32768. The float you print is a convenience; the code is the truth.
- Casts round to nearest; arithmetic truncates toward zero; adds and subtracts saturate. These are the hardware’s rules, and
sffollows them exactly. The format → - Nothing reaches the device that the host could decide on its own. The matmul above was proven safe before launch. Host and device →
Next steps
Scalars
Creating values, arithmetic, comparisons, casting, inspecting bits.
Arrays
Creating, broadcasting, reductions, matmul, the device path, status.
Error policy
Raise, warn or ignore, per event, per block of code.
API reference
Every function with its signature, events and an example.