Our own AI, all the way down: engine, memory, agent — and the night it learns

Published 2026-09-20
Our own AI, all the way down: engine, memory, agent — and the night it learns

Most “AI companies” are a prompt, a key to someone else's API and a nice deck. We are built differently. In five and a half months we built a complete stack of our own: an inference engine that competes head-to-head with llama.cpp and often beats it; an agent runtime with persistent memory, a planner and task preemption; a measurement harness that decides every night whether the agent got better; and a training loop in which the agent changes its own weights only after statistical proof. All of it in Rust, all of it in production 24/7 on ordinary consumer GPUs. What follows are not promises but numbers from our benchmarks, with pointers to where they live.

What this article is about
We are not users of someone else's AI. We build every layer ourselves — from the kernel that writes to the GPU to the agent that retrains its own weights at night and proves in the morning that it got better.
Zero Day Labs
≈430K

Lines of Rust: agi-core, llamars, agi-web-ui, uide, codex-substrate — with ~1,700 tests.

+78%

Faster than llama.cpp: GPU prefill on Qwen3.5-35B, RX 6900 XT (Vulkan), at every context depth.

×9

KV-cache compression (MLA): 30 KiB per token instead of ~270. Huge context on modest hardware.

12 s

Instead of 106 s — the reply to a message that interrupts a running task: checkpoint and KV-prefix reuse.

Layer 1 · Inference

Our own engine,not a wrapper around llama.cpp.

llamars — pure Rust, ~150K lines, Vulkan and Metal without a single line of C.

The path was honest: first bindings to llama.cpp, then a runtime on top of them — and a ceiling. You cannot teach someone else's engine to snapshot a conversation to disk, share a GPU between two generation lanes, or tell the orchestrator its true context capacity. So llamars was born — our own inference engine for GGUF models.

Inside are things that usually only framework authors get to build. On Metal the whole model graph lives on the GPU: one command buffer per token, fused norm+matvec, packed QKV, flash-decoding with KV append, f16 activations end-to-end (ggml still keeps f32). On Vulkan — chained GEMM for prefill, int8 decode, cooperative-matrix kernels in f16/fp8, flash-decode with GQA sharing, q4_0 KV arenas. And an MLA cache for the DeepSeek family: 30 KiB per token instead of 270.

Tokens/s (pp — prefill, tg — generation) and wall time, same session, same hardware. Source: llamars/BENCH_RESULTS.md, Jul–Aug 2026.
Model · hardwarellamarsllama.cppΔ
Qwen3-8B Q4_K_M · M1 Max, Metal · pp512 / tg128524 / 47.8473 / 45.0+10.8% / +6.3%
TinyLlama 1.1B · M1 Max, Metal · pp512 / tg1283626 / 2393217 / 232+12.7% / +3.2%
Qwen3.5-35B-A3B · RX 6900 XT, Vulkan · GPU pp51231351762+78%
Qwen2.5-Omni-3B · RX 6900 XT · audio encode, 2.5 s150 ms364 ms×2.4
Qwen3-Embedding-0.6B · embed, 11 tokens200 ms540–768 ms×2.7

The engine is multimodal: a 32-layer Whisper or ViT encoder runs in a single command buffer, CosyVoice3 TTS (language model, flow matching and vocoder) is rewritten in Rust end to end, SDXL/Flux/Wan diffusion produces bit-identical images across restarts. And — rare for an inference engine — native LoRA training directly on quantized weights: a 27B model, 4096 context, 52 seconds per step, on one consumer card.

Q4_0 … Q8_0Q2_K … Q6_KIQ4_XS / IQ4_NLf16 / bf16VulkanMetalCPUGGUFLoRA trainMLA KV

We don't hide where we started. The first version of the engine earned an internal document titled *Brutal Reality Check*: a beautiful backend architecture, zero tokens per second, 44 of 201 tensors loading. It was rewritten bottom-up — from one working matrix multiply to a full GPU graph — and since then every kernel ships only together with a benchmark against llama.cpp on the same hardware.

Layer 2 · Memory

Memorythat survives a restart.

UIDE — our own store: RocksDB, a home-grown HNSW, a signed operation log.

An agent without memory is a chatbot. We split memory into its own engine, UIDE: persistent KV on RocksDB, embeddings, a compact dependency-free HNSW index (recall@10 ≥ 0.9 against brute force), index snapshots with delta reconciliation instead of rebuilds, and an Ed25519-signed operation log — groundwork for federating memory between instances. Inference is injected into UIDE through a trait: the store knows nothing about where vectors come from.

01

Goal Graph

A persistent DAG of tasks on top of memory: node digests, per-step token budgets, and a lesson from a failure available on the very next step of the same run.

02

Three tiers for KV

VRAM → RAM → NVMe with a measured restore cost, no constants in code. An 83,000-token conversation with an image: a turn in 10.5 s instead of ≈56 s of full re-prefill.

03

Recall under control

Memory benchmark: recall@5 = 0.963, MRR = 0.935, median 966 ms. Class balancing so rare memories don't drown.

Layer 3 · Agent

A runtimewhere everything is a step.

AGI Core: ~170K lines, ~1,200 tests, 1,227 commits in 5.5 months.

AGI Core is the irreducible kernel of an autonomous agent: a flow engine, a tool registry, memory, an event bus, an inference router and transport. Everything else is plugins and JSON process definitions that can change at runtime. The router holds four backends at once — local GGUF via llamars, OpenAI-compatible APIs, Anthropic and a remote agi-core — and picks per task.

Stack architecture: clients, AGI Core, UIDE memory, llamars inference, agi-bench gate
One stack from the WASM client down to the shader. Everything in green is ours.

A few decisions you won't find in popular agent frameworks:

We measure savings too. One agent-loop benchmark: before optimisation — 5 tasks of 6 and 217,904 tokens; after — 6 of 6 and 88,548 tokens, −59%. That is not “the model got smarter”; the context compiler stopped carrying junk into the prompt.

Layer 4 · Proof

An agent thatlearns at night — and has to prove it.

agi-bench: 37 tasks, 7 categories, Wilson confidence intervals, every night.

Self-improvement without measurement is self-deception. So the benchmark lives apart from the agent, in a directory the agent's process cannot read; tasks are parameterised by seed so they cannot be memorised; part of the set is held out. Every night on a timer: a run, a comparison with the baseline, a bootstrap of the difference.

The nightly cycle: a clock, a data stream into a GPU slab where a LoRA adapter crystal forms, and an A/B comparison
Night: corpus → stop the kernel → train → benchmark B → benchmark A → verdict.
1

00:30 UTC — build a corpus from the agent's “flight recorder” for the day: ~6.6M tokens per two days of work.

2

Stop the kernel, free the GPU.

3

Train a LoRA on our own quantisation: a 27B model, ~120 steps, 24 seconds per step.

4

Run the benchmark with the new adapter (B), then with the old one (A) — 30 tasks × 3 trials.

5

Compare: Wilson interval, bootstrap of the difference. Verdict: promote / hold / reject.

6

Bring the kernel up with the winner. Change nothing if there is no proof.

The first full night ended in reject — and it turned out the benchmark had measured memory, not quality: merging the adapter at load time pinned 14 GiB. We fixed the deployment format; the next night gave hold: B 89/90 vs A 88/90 — a difference within noise. No proof — no change of weights. We consider that the most important property of the system, not a weakness.

Horizon

Codethat can be checked formally.

codex-substrate: a content-addressed graph of programs with a proof kernel.

The next layer is already a prototype: codex-substrate — a code graph where every function is normalised, hashed with BLAKE3 and signed with Ed25519, with Hindley–Milner type inference, a dependently-typed proof kernel, Lean 4 import and compilation to WebAssembly. And inside AGI Core lives a verified decompiler: a tower of modules grown from a single nand atom recovered the whole of libm — 38 of 38 functions to 10⁻¹² on 20,000 probes each, with a binary 31% smaller than the original. This is what will let an agent change its own code by proving correctness rather than hoping for it.

Consulting

What of thisyour business needs.

We don't advise from slides: every recommendation has been tested on our own hardware in the last six months.

Everything above we built for ourselves — which is exactly why we know where AI projects lose money. Usually in three places: overpaying for third-party APIs where a 35B model on one card would do; agents without memory and without measurement that “sort of work”; and data leaving for someone else's cloud because “there is no other way”. There is.

🔍

Audit and architecture

We take apart your AI loop: models, cost per token, latency, memory, tool security. You get a plan with numbers — what to keep on APIs, what to bring in-house, what to rewrite.

⚙️

Inference on your side

We deploy models on-premise on consumer GPUs or in your cloud: quantisation, a KV cache sized for your context, batching. Measured against your current API — in tokens per second and in money.

🤖

Agents and training

We design agents with memory, a planner and a quality gate; we set up a nightly training loop on your data. Or we hand you ready roles — lawyer, accountant, recruiter, assistant, calls, chats.

Formats range from a one-day audit to a turnkey deployment with our runtime inside your perimeter. Write to [email protected] or use the contact form: describe the task and what you already run — we come back with a plan and an estimate. On why agents need a sandbox — see the separate article.

Why us
A consultant is worth the rakes he has already stepped on that you haven't bought yet. Behind us are our own engine, our own runtime and our own benchmark — and a folder of post-mortems for each.
Zero Day Labs

AI consulting

Stack audit, inference on your side, agents with memory and nightly training — from the people who wrote all of it themselves.

aiagentsrustinferenceconsulting
Try it