Skip to main content

sf.devices()

The names of the registered targets, as a tuple:

sf.device(name="atreides-sim") and sf.get_device(name)

The target object by name. SFUnsupportedError for an unknown name.

sf.register_device(device)

Add a target, or replace one with the same name. This is how a simulator or the real chip is plugged in.

The Device interface

Subclass sf.Device and set:
str
The name used in device= and sf.devices().
tuple[int, ...]
Widths the target accepts; (16,) for Atreides.
bool
True if run returns per-element event flags. With flags, statuses are exact and over="raise" applies to heavy ops.
str, int
What the target does in reductions; the reference assumes sequential at data width.
int
Largest buffer the target takes; checked before launch.
and implement:
sf.MockAtreides in src/sf/_device.py is the reference implementation to copy from. Kernel-capable targets (Stage 3) add limits, check_launch, launch, alloc, upload, download and synchronize; see plugging in hardware.

Counters

Every device counts its launches in device.launches; kernel targets also count kernel_launches. The test suite uses these to prove that pre-flight refused a launch rather than running and discarding it.