awzeal: Bonsai 2.5 27B Running in Ring 0 of Our Own ZealOS Fork
Our ZealOS fork runs LLM inference in ring 0 now. Ternary-Bonsai-2.5-27B answers inside the OS, and so does a small Qwen3 that is fast enough to chat with. We call the fork awzeal, and it ships as a container:
podman run -it --device /dev/kvm ghcr.io/aitherium/awzeal
That boots ZealOS under KVM and drops you at an awzeal> prompt on the serial console. Every token you see was computed by the guest CPU inside ZealOS. There is no Linux underneath doing the work, and no API call.
Measured today on a Ryzen 9 9950X3D:
| model | where | cores | decode |
|---|---|---|---|
| Qwen3-0.6B (Q8_0) | ZealOS, 4 GB guest | 1 | 19 tok/s |
| Qwen3-0.6B (Q8_0) | ZealOS, 4 GB guest | 4 | 23–42 tok/s |
| Ternary-Bonsai-2.5-27B (PQ2_0) | ZealOS, 12 GB guest | 1 | 1.04 tok/s |
Bonsai's first answer inside the OS:
[AIBONSAI] ready: engine 1121152 B, model 7 parts 6917 MiB, ctx 2048, vocab 248320
The capital of France is **Paris**.
The capital of Germany is **Berlin**. <- follow-up turn, same state
ZLOUT-END prefill=20 tok 13.30s decode=8 tok 7.71s (1.04 tok/s) ctx=57/2048
The source is public: github.com/Aitherium/awzeal.
How a HolyC operating system runs an AVX2 transformer
ZealOS is the modernised fork of TempleOS: 64-bit, ring 0 everywhere, everything JIT-compiled from HolyC at boot. Its compiler does not emit AVX, so we don't ask it to. The engine is a separate flat binary that HolyC calls through plain function pointers.
For Qwen3 that binary is llm.asm's forward pass, the hand-written x86-64 NASM engine (MIT). We link its shared modules with a small glue file that does three jobs.
It speaks the HolyC calling convention. HolyC pushes every argument on the stack, arg 1 lands at [RBP+16], and the callee pops. The glue saves every register and the MXCSR, switches to a private AVX-aligned stack, calls the SysV engine, and returns with ret n*8.
It turns AVX on. ZealOS never sets CR4.OSXSAVE or XCR0, so the first VEX instruction would fault. Every entry point fixes that on whatever core it lands on:
zl_enable_avx:
mov rax, cr4
or rax, (1 << 18) | (1 << 10) | (1 << 9) ; OSXSAVE | OSXMMEXCPT | OSFXSR
mov cr4, rax
xor ecx, ecx
xgetbv
or eax, 7 ; x87 | SSE | AVX
xsetbv
ret
It loads anywhere. We link the image twice, at base 0 and at base 0x10000000, and diff the two. Every field that moved by exactly the delta is an absolute relocation. The count is zero: the engine is fully RIP-relative, so the HolyC loader copies it into memory and calls it directly. A 64-byte header lists the entry points (ZlInit, ZlBegin, ZlNext, ZlEnd, ZlReset, ZlStat, ZlWorker, ZlThreads), and AILLM.ZC binds them:
ZlInit = zl.image + (zl.image(U32 *))[2];
ZlBegin = zl.image + (zl.image(U32 *))[3];
ZlNext = zl.image + (zl.image(U32 *))[4];
Every core, the ZealOS way
ZealOS owns its application processors, so we can't wake them the way llm.asm's bare-metal OS does. Instead the loader Spawn()s one task per CPU, each pinned to its core. Each task calls ZlWorker(tid), which spins on a generation counter. The calling core quantizes the activation vector once, bumps the generation with lock xadd, runs slice 0 of the matmul itself, and waits for every worker's cache-line-private done flag. A worker that sees no job for about 20 ms returns to HolyC and Yields, so the cores stay usable when nobody is asking anything. This is the same lock-free design llm.asm uses on bare metal, with ZealOS tasks standing in for raw APs.
Kernel agents that think locally
The fork's AI layer is FluxIDT (event rings), CapEngine (capability tokens, default-deny), AgentForge (identities, spawning, a scored task scheduler) and InferQueue (priority queue with a model registry). We now JIT-compile all four at boot on top of the stock kernel. The queue's local-CPU backend is a hook the engine fills in:
case INFER_BACKEND_LOCAL_CPU:
if (infer_local_cpu_fp && (*infer_local_cpu_fp)(req, InferResp(req)))
{
req->status = INFER_STATUS_COMPLETE;
break;
}
Spawn a worker agent and it gets a role-based capability token that includes infer.* EXECUTE. Give it a task, run one AgentTick, and the scheduler dispatches the task. The task calls InferSync and the answer comes back through the token check:
[AIAGENT] spawned worker#0
[AIAGENT] worker#0 (role 1) status 3: My job is to maintain and optimize the
ZealOS system to ensure it runs efficiently and reliably.
Bonsai 2.5 27B: a second engine
Bonsai is not a dense Qwen3. It uses the qwen35 hybrid layout: 64 layers, 48 of them Gated DeltaNet (conv1d plus a recurrent state per head) and every fourth a gated full-attention layer with partial multi-section RoPE. Its weights are PrismML's ternary PQ2_0, stored Hadamard-rotated along the input dimension with explicit sign vectors.
So it gets its own engine, written in freestanding C (no libc, -ffreestanding -mavx2 -mfma). It covers GGUF parsing, PQ2_0 matvec with the Hadamard transform folded in, both layer types, the 248k-entry byte-level BPE tokenizer and the chat template. It is packaged with exactly the same header and HolyC ABI as the Qwen3 engine, so AIAsk and AIChat don't know which one they're talking to.
We held it to our own llama.cpp build as the reference. The prompt token ids and the first eight greedy tokens match exactly, and the top-5 log-probs agree within 0.03.
ZealOS reads models from a FAT32 disk, and FAT32 caps a file at 4 GiB. So the GGUF is cut at tensor boundaries into seven parts of up to 1 GiB each. The loader gives each part its own allocation and hands the engine a part table, so no single file or allocation has to hold 6.9 GB.
Limits
Bonsai runs on one core today, about 1 tok/s, and streaming 6.9 GB through ZealOS's FAT32 takes around 20 minutes at boot. Next: the same per-core workers Qwen3 already uses, then an awzeal:bonsai image.
Run it
# chat on the console
podman run -it --device /dev/kvm ghcr.io/aitherium/awzeal
# one-shot, for scripts
podman run --rm --device /dev/kvm -e AWZEAL_PROMPT="Write one sentence about operating systems." ghcr.io/aitherium/awzeal
AWZEAL_SMP sets the guest cores and AWZEAL_RAM its memory. CI builds the image from source on every push, boots it under KVM, checks that an agent and the chat both answer, and only then publishes it.
Credits: ZealOS and TempleOS (public domain), llm.asm by alesha-pro (MIT), Qwen3 by the Qwen team (Apache-2.0), Ternary-Bonsai by PrismML.
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.