Backend conformance#
This page is the normative conformance matrix for BackendOps. Every
public method on spacecore.backend.BackendOps appears as a row. Columns
record which backends implement it within tolerance, which dtypes each
backend honors, optional-argument coverage, sparse support, JIT
compatibility, native vmap, and conversion behavior. Each row links to
the test(s) that pin it.
Tests live under tests/backend/. The shared harness
(tests/backend/_conformance.py) defines per-op tolerances, the
backend_ops fixture, and the assert_matches_reference helper. The
matrix is the contract; tests instantiate it.
Scope and policy#
In scope. NumPy is the reference. JAX, Torch, and CuPy are compared against NumPy through the harness. Sparse paths exist where the backend exposes a sparse array type.
Out of scope. Performance, device placement, JAX sharding, autograd, and downstream library compatibility.
Tolerance. Per-op + per-dtype, set in
tests/backend/_conformance.py:TOLERANCE_TABLE. The default isrtol=1e-6, atol=1e-8. Spectral and complex sqrt entries are looser.Skip vs deviation. A backend that genuinely lacks an op is skipped with a justification. A backend that returns a different result inside tolerance is a deviation and appears in Backend deviations.
Adding a backend. Implement
BackendOps, register the family, add a fixture branch intests/backend/conftest.py, and update theBackendscolumn of every row this implementation supports.
How to read a row#
Method —
BackendOpsmethod name.NumPy reference — the
numpyornumpy.linalgcallable used as ground truth.—means no direct NumPy spelling; the row is compared against another invariant (identity, round-trip, etc.).Backends —
N J T Ccolumns;y= covered,s= covered with a skip on absent platforms,d= deviation (see Backend deviations),—= not implemented for this backend.dtypes —
r32 r64 c64 c128;ycovered,—not covered by the backend natively.Tests — link(s) to the test file(s) that pin this row.
Matrix#
Metadata and predicates#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
identity |
y y y y |
n/a |
|
|
identity |
y y y y |
n/a |
|
|
constant |
y y y y |
n/a |
|
|
identity |
y y y y |
n/a |
|
|
identity |
y y y s |
n/a |
|
|
direct |
y y y y |
n/a |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
dtype kind |
y y y y |
y y y y |
|
Construction and dtype#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
SciPy sparse |
y s s s |
y y y y |
|
|
SciPy sparse dot |
y s s s |
y y y y |
|
Shape and layout#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
Elementwise and reductions#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
Linear algebra#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y s |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
|
direct |
y y y y |
y y y y |
|
Indexing and updates#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
|
y y y y |
y y y y |
|
|
functional indexing |
y y y y |
y y y y |
|
|
|
y y y y |
n/a |
|
Control flow#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
sequential Python |
y y y y |
n/a |
|
|
sequential stacked loop |
y y y y |
y y y y |
|
Conversion and inspection#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
round-trip equality |
y y y y |
y y y y |
|
|
identity |
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
Sparse paths#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
SciPy |
y — — s |
y y y y |
|
|
SciPy |
y — — s |
y y y y |
|
Constants#
Method |
NumPy reference |
Backends (N J T C) |
dtypes (r32 r64 c64 c128) |
Tests |
|---|---|---|---|---|
|
|
y y y y |
y y y y |
|
|
|
y y y y |
y y y y |
|
Reading the result columns#
s— skipped at runtime because the backend is not installed in the current environment, or because the underlying library does not expose the operation on this platform (e.g. CuPy sparse without a GPU).d— the backend returns a numerically valid result that differs from NumPy within the per-op tolerance; the deviation is documented in Backend deviations. Tests still pass.—— not implemented for this backend.BackendOpsraisesNotImplementedError(not a soft skip) and the test asserts that behavior intest_backend_optional_args.py.
Cross-references#
Backend deviations — user-facing list of accepted differences.
Batching test policy — what is and isn’t tested for batched paths.
Dtype and Scalar-Field Behavior and Conversion Policy — dtype/scalar-field contract underlying the conformance promises.
docs/dev/0.4.0-phase-a-inventory.mdsection A6 — the gap inventory that seeded this matrix.