Hilbert.Tensor
Tensors redefined from scratch: a lazy graph of mathematics, planned, fused and run on the GPU through the system's own driver.
In use by Neuron, Science and every service's maths
Hilbert.Tensor
Hilbert.Tensor is MLambda’s tensor engine, written from scratch in Aleph and Hilbert, with no BLAS, no CUDA library and no Python underneath. Every computation in the family that works on arrays of numbers runs on it: matrix products, per-atom sums, eigen-solves, force fields, spectra, networks, the mail guard’s scores, the planner’s costs.
What makes it different
A tensor is a term, not a buffer. An operation does not compute. It adds a node to a lazy graph whose nodes are
Hilbert terms from the tensor catalogue (Catalog.hb, Numerics.hb): products, elementwise maths, reductions,
softmax, norms, transposes, slices and concatenations, written as Einstein summations
(tensorEinsum "ij,jk->ik" [a, b]). Because each node is mathematics, the graph can be rewritten by laws before it
runs. Gradients come from the same calculus laws as Hilbert’s, not from a separate autograd.
The planner decides where each graph runs. The Planner weighs each graph by laws (rules/Graph.hs): its
nodes, its work in multiply-adds and the measured costs of this machine (the host’s evaluator, a device launch, a
plan’s price). Small operands are computed at once on the host; a large graph is cut into kernels, fused and sent to
the GPU, with buffers kept resident between steps; a graph that is run again pays for its plan once
(rent-or-buy). Many small problems are stacked into one tensor ([B, n, n]), so each step is one law over the batch.
Kernels are generated, then compiled by the driver. Each fused node is built as LLVM IR for the device and handed to the vendor’s own driver on each operating system (on Windows, through the AMD driver’s runtime compiler). On MLambda.OS it goes through the kernel.
f64 by default. Science needs the digits.
What it changed
When the planner replaced a size-only rule, the measured times on an AMD APU were:
| Computation | Before | After |
|---|---|---|
| GHZ-10 quantum chain | 120 s | 55 ms |
| Born bond | 4 216 s | 0.375 s |
| 40-qubit bond | 8 423 s | 45 s |
Testing a GPU engine
Unit tests bind Tensor.Mock, a device that accepts every graph and computes none, so they check wiring, shapes,
plans and calls without a GPU. What a kernel computes is checked on the GPU by the drivers’ own specs, which never
run in CI.
Used by
Neuron (every model), Science (quantum, CAD simulation, chemistry), Helios
(series), Mail (the guard’s scores), Iris (picture filters) and every service’s .hb maths.