Emulator and hardware
Understand what the cpu-backend build does on your CPU, which results transfer to a physical card, and how to check which backend you ran on.
Every result in this guide comes from the toolkit’s CPU emulator, the cpu-backend build. This page explains what the emulator does, so you can judge which conclusions carry over to a physical card.
What the emulator is
The emulator is a small Rust file in the toolkit source, src/qant_driver_import/backend_cpu.rs. It replaces the Q.ANT driver with CPU code. Its header comment describes it as a lightweight simulation backend that is “intentionally minimal and not fully featured” but “sufficient for validating toolkit integrations”.
The rest of the toolkit is the same in both builds. The Python wrapper, the argument checks and the Rust core that builds layers from primitives all run unchanged. Only the lowest layer, the calls to the driver, is swapped out.
What the emulator does
| Driver function | What the emulator does |
|---|---|
| Element-wise multiply | Multiplies the two inputs in bfloat16. |
| Batched matrix-vector multiply | Multiplies each pair of elements in bfloat16 and adds the products in float32, then rounds the sum to bfloat16. |
| Scaled periodic nonlinearity | Computes an exact cosine, u.cos() * v in bfloat16. |
init_npu, release_npu | Does nothing and reports success. |
| Device ID | Ignores it. Every call runs the same CPU code, whatever device_id you pass. |
get_available_npus | Returns {0: 'cpu_backend'}. |
get_driver_info | Returns cpu-backend;commit:none;. |
get_sensor_info | Returns fixed constants, for example 35.0 for every temperature and 1.8 for voltage_1v8. |
get_version_info | Returns empty strings. |
get_perf_counter | Returns 0.0 for both counters. |
setup_logging | Fails with logging not available for cpu-backend. |
What a physical card does differently
A physical NPU computes the multiplications and the nonlinearity optically. The toolkit documentation describes the nonlinearity as tcos, a 2π-periodic function with values between -1 and 1 that is similar to a cosine but has “the cosine-related shape of the periodic optical nonlinearity”. The emulator uses an exact cosine in its place.
An analog optical computation also adds noise. The Fourier network example trains with Gaussian noise for this reason, so that its weights tolerate the noise of a physical device.
We have no access to a card. We can’t tell you how large the noise is, how far tcos departs from a cosine, or how fast a card runs.
What emulator results tell you
Emulator results are useful for some questions and not others.
| Question | Can the emulator answer it? |
|---|---|
| Does my code call the API correctly, with the right shapes and dtypes? | Yes. The argument checks are the same in both builds. |
| How much does bfloat16 rounding change my model’s output? | Partly. Inputs and outputs are bfloat16 in both builds, so that rounding transfers. How a card computes internally may differ. |
| Does my model’s algorithm work, for example a KAN layer learning a function? | Yes, for an ideal cosine and no noise. |
| How accurate is my model on a card? | No. The card’s tcos and noise are missing. |
| How fast is my model on a card? | No. The emulator computes with simple loops on the CPU. |
| Does my multi-device code scale? | No. The emulator always reports one device and ignores device_id. |
Check which backend you ran on
Call get_driver_info and look for the cpu-backend prefix:
import qant_native_computing_toolkit as q
info = q.info.get_driver_info()
print(info)
On the emulator this prints cpu-backend;commit:none;. You can also check get_available_npus(). The emulator returns the serial cpu_backend for device 0, while a card returns its real serial number.
To record which backend produced a result, save the output of get_driver_info next to your results.
Reproduce the emulator in your browser
This site includes a NumPy version of the emulator’s KAN layer arithmetic that runs in your browser. It matched the real emulator bit for bit on 40 of 40 random layers and on a full trained network. Use it to try KAN layers without installing anything:
- The live cosine example runs a KAN layer step by step.
- The playground lets you design and run a larger Fourier network.
Like the emulator, these pages compute an exact cosine. They show the same algorithm behaviour and bfloat16 effects, and the same limits apply.
What’s next
- See emulator results for every operation in the introduction example.
- Read the rules that both builds share in Key concepts.