TatuEngine — first experiments with wave field theory
TatuEngine·

TatuEngine — first experiments with wave field theory

Context

TatuEngine was born from a silly question: “Do RT Cores process neural networks?” It sounds like a joke, but the idea behind it had real foundation — a neural network is, in the end, a function that transforms an input vector into an output vector. If you encode the weights as 3D geometry (triangles with a refractive index), each input token becomes a ray that passes through this geometry, and the output emerges from the constructive interference of waves on the other side.

It’s beautiful in theory. In practice, WSL doesn’t have RT Cores.

But the right question wasn’t “how to use RT Cores in WSL.” The right question was: “if I treat inference as wave propagation in a phase field, what happens?”

That question started the experiments.

The original dream: weights as geometry

The initial metaphor was too elegant to abandon:

Ternary weight w ∈ {-1, 0, +1} → lens with η = w
Lens position → f(layer, row, col) in 3D space
Input token → ray with initial phase φ₀
Output → interference of all waves at the detector

Each network weight became a triangle in a BVH (Bounding Volume Hierarchy). An inference was literally a ray-trace: fire rays, compute phase deviation, sum coherently.

The problem appeared quickly: 1 billion parameters in float32 = 36 GB of lenses. Each weight became 3 vertices × 3 floats + 3 optical property floats — tens of bytes per weight. For 1B parameters, tens of GB — no chance of fitting in consumer GPU VRAM.

The first pivot: hybrid approach

Instead of converting EVERYTHING to geometry (impossible for 1B params), I split the pipeline:

Step Where it runs Why
Embedding lookup CPU Linear table access — no GPU gain
RMSNorm CPU Simple vector operation
in_proj / out_proj / lm_head GPU (bridge_matmul) Heavy matmul — 99% of FLOPs
Conv1d + SiLU CPU Small sequential state
SSM step CPU Inherently sequential — h(t) = f(h(t-1), x(t))
Residual add CPU Trivial vector sum

This division wasn’t obvious at first. The Mamba SSM is different from Transformer: the hidden state h(t) depends on h(t-1). You can’t parallelize over time like attention. But the matmuls (which are the expensive part) are independent per token.

The discovery that changed everything: Block Codec

The hybrid approach worked, but it was still expensive — 10ms per token on CPU for 1B params. Then came the insight: ternary weights follow local patterns. Consecutive blocks of weights share zero, sign, and similar magnitude.

Instead of 1 lens per weight in a 1:1 scheme, a compact block fit in a lean block:

Each block:
- compact payload (few bits per weight)
- minimal header
- minimal spatial metadata
Total: a fraction of a byte per weight (well under the 1:1 scheme)

128× compression. And the best part: the traversal kernel can process entire blocks in parallel with 32 threads in the same warp.

GPU Block-Traversal: the first real result

With Block Codec working, I wrote the CUDA traversal kernel — each thread processes one row of the block, warp shuffle for partial sum, shared memory for accumulator.

The result was surprising:

Pipeline CPU GPU Speedup
1 token inference 10.552 ms 41.9 µs 252×
Bake 100K cells ~70 ms 4.8 ms 15×
16-ray traversal 74.2 ms 0.52 ms 146×

252 microseconds per token on a GPU that also runs CUDA Cores. For comparison, a Transformer of similar size takes 3-5ms on the same hardware.

What I learned from these experiments

1. Post-training ternarization destroys coherence

The model I tested (BitMamba-1B) was already natively ternary — trained with weights in 1. I tried ternarizing a float32 model post-training and the logits turned into noise. Ternary models need to be trained that way from the start.

2. Softplus with float32 silently overflows

expf(89.0f) = +inf. This broke my SSM step tests for 2 days until I realized the softplus of A_log was generating inf in the last batches. The fix is the numerically stable formulation (log1pf(expf(-abs(x)))).

3. SSM doesn’t carry history in the hidden state

I expected the hidden state h(t) to carry context, like an RNN’s hidden state. But Δh ≈ 0.0001 between consecutive tokens. Mamba’s real memory is in the kv_cache (conv buffer + SSM state). The hidden is almost a pass-through.

4. The AutoTrainer converges too fast — and that’s good

With spacing 3.5 between lenses (default), the AutoTrainer reaches 99.5% quality in 14 steps. Not because the system is simple — but because each lens already resolves the local gradient without interference. With spacing 0.8 (overlapping lenses), entropy rises and the trainer actually needs to work. But 3.5 is the sweet spot for pure inference.

5. The Adjacent Method beats numerical gradient

Instead of computing gradient by finite differences (expensive, unstable), the Adjacent Method tests the 3 adjacent refraction index options (η-1, η, η+1) and picks the one that minimizes the phase function. 3× faster, no false gradients, deterministically convergent.

The cold numbers

Metric June (start) July (today)
Tests 0 400+ (30 suites)
GPU speedup 252×
Compression 27.26 GB 245 MB (114×)
Pipeline Conceptual Hybrid CPU/GPU
Agent 0 8 subsystems
Model Mamba 2.8B (planned) BitMamba-1B (functional)

What’s next

The hybrid pipeline is functional, but the original vision hasn’t been fully realized: the weights aren’t real geometry during inference — Block Codec is a compressed representation, not an actual optical traversal.

The next step is connecting the MotorGPU (parallel traversal kernel) with the agent pipeline we built afterward — Immunosystem, associative LTM, GoalStack, ToolUseBuffer. The agent should be able to call tools, remember past sessions, and self-correct the phase field based on feedback.

TL;DR: Started wanting to do ray tracing for neural networks, discovered hybrid SSM is the real path, compressed 36 GB to 245 MB with Block Codec (128×), and achieved 252× GPU speedup. TatuEngine is no longer a crazy idea — it’s a functional inference engine that treats network weights as a phase field. And yes, I still think one day RT Cores will process neural geometry for real.