q42 substrate binding (plan §5 / Phase 6) — serialize a ComputeGraphto and from
48-byte NQuin records, so a compute DAG persists in the same Merkle-DAG quin store as
the rest of QualiaDB (zero-copy, page-aligned), with provenance.
A directed acyclic compute graph. Acyclic by construction: ComputeGraph::push
only accepts inputs that reference already-added nodes (or EXTERNAL), so insertion
order is a valid topological order. nodes[i].out.producer == NodeId(i).
Fixed-rank (≤4) tensor shape — no Vec, so a TensorRef stays Copy. A dim of 0
means “runtime-parameterized” (resolved from a params buffer at dispatch — e.g. GEMM’s
M/N/K), which is how the dimension-independent WGSL kernels are represented.
An op-CLASS and its compile-time payload — the node label of the compute DAG (plan §2;
Slice/Rope added for the real decode layer). Seed arms (Elementwise/MatMul/Gemv/
Fft) have a real lowering today; the rest are declared so the vocabulary is fixed, and lower
to an explicit Err until their phase builds them.
A backend code generator. lower_graph calls exactly one method per node, in
topological order. Op-classes a backend has not implemented yet use the default
methods, which return an explicit Err (never a silent no-op).
Walk the graph in topological (insertion) order and dispatch each node to its
Lowerer method. The single, backend-agnostic lowering driver — every backend is a
Lowerer impl, so there are no per-kernel.id branches.