Federico completed the first real conversation with vetta-infer through the strata-ctl web GUI on Sogliola: 'Ciao, sono Federico' -> 'Ciao Federico! Piacere di conoscerti. Come posso aiutarti oggi?' 2650 prompt + 53 completion tokens, 4.2 tok/s decode, first token 618 s. The 618 s time-to-first-token is the sequential prefill of the ~2650-token agent prompt (~140 ms/token); decode is ~4.2 tok/s. Recorded honestly as the current performance frontier (not a hang). - README M1 milestone: inference landed (EXACT parity + strata-ctl link), with a dedicated measured first-GUI-conversation bullet; refreshed verification counts (5 Lean files incl. inkling_loop.lean). - ORIENTATION 'Current state (honest)': replaced the stale 'No token generated yet' with the real state (full forward, EXACT parity, agent link, first GUI chat, blocking-sync CPU fix A/B 101.2%->54.2%); marked road steps 1-5 landed, M2 performance (graph capture / batched prefill / expert WMMA) as the frontier.
8.5 KiB
Orientation: what you're looking at
If you come from vLLM, llama.cpp, SGLang, or TensorRT-LLM, this repo will feel
alien at first. That's expected — it's built on a different mental model. This
document explains what vetta-infer is, why it looks the way it does, and the
road ahead. Read this before diving into the code.
What it is, in one paragraph
vetta-infer is a MoE-first microkernel inference engine written in safe
Rust with a minimal set of AMD ROCm HIP kernels. It is not a general-purpose
engine: it targets one specific machine — an AMD Ryzen AI 9 HX 370 APU
(gfx1150, RDNA 3.5) with 96 GiB of unified memory and dual NVMe — and one
class of models: Mixture-of-Experts decoder LMs (first target:
Inkling-2-Mini). Small dense utility encoders (e.g. BGE-M3 embeddings) are in
scope as a secondary lane; dense decoder LMs are deliberately out of scope.
The engine is co-designed with its consumer, the vetta-agents framework
(evolved from strata-ctl), and ultimately serves a principal named Iris.
Why it looks different (the mental-model shift)
Five ideas explain almost everything that will surprise you:
-
Pure microkernel + services. There is no monolithic runtime. A tiny kernel (
kn) owns the bus, registry, and UMA/DMA broker and contains zero model logic. Everything else — loading, compilation, execution, sampling, speculative decoding, telemetry, the wire gateway — is a separate service crate. Control flow stays in safe, CPU-testable Rust;unsafeis confined to the HIP FFI (hip) and IO syscalls (io). -
Models are compiled, not loaded. A dual-step loader turns a HuggingFace
.safetensorsmodel into a canonical IR, then aBackendPackerlowers it into a portable.vbundle/(manifest + weights + plans). You don't point the engine at raw weights; you build a bundle once and boot from it. The manifest carries identity-by-provenance (sha256), ABI version, and target. -
The forward pass is a declared, validated plan. Instead of imperative kernel calls scattered through C++ files, the model's compute is expressed as
graph.vplan(an op sequence) +memory.vplan(buffer arenas). At boot these lower to a flatCompiledPlan. Before any GPU launch, the plan is checked by an arena validator (no buffer overlap, checked bounds, no use-before-write) whose correctness is proven in Lean 4. The graph is data, not code. -
Proof-first for complex logic. Non-trivial state machines — the DMA slab ring, bus lifecycle, serve session, arena plans — are modeled and verified in
proofs/*.lean(0sorryAx, standard axioms only) before the Rust is written. Simple logic just gets ordinary CPU tests. This is a hard rule, not a nicety: it eliminates whole classes of bugs by construction. -
Parity discipline, no unmeasured claims. Every kernel is checked against a CPU oracle (and the hardened
strataC++/HIP reference) before it is wired in. Every performance claim must carry real measurements and the exact hardware/model/flags. "It should be fast" is not a sentence we accept.
The crate map
| Crate | Responsibility |
|---|---|
vetta-infer-abi |
Shared contracts: .vbundle manifest/plans, vplan opcodes, arena validator, JSON, sha256, serve wire types. |
vetta-infer-kn |
The microkernel: bus, registry, UMA/DMA broker. No model logic. |
vetta-infer-ld |
Loader: safetensors reader, ModelImporter (config → IR → graph), BackendPacker, bundle I/O. |
vetta-infer-hip |
HIP FFI/DMA backend (gfx1150). unsafe isolated here. Feature-gated kernel build. |
vetta-infer-cc |
Compilation/control services. |
vetta-infer-rt |
Operational runtime: executes the CompiledPlan on the HIP backend. |
vetta-infer-lab |
Laboratory/probing runtime; shares the rt executor core. |
vetta-infer-sp |
Speculative decoding / MTP verification. |
vetta-infer-nt |
NVMe streaming / disk cache (io_uring, write-once O_RDONLY). |
vetta-infer-tm |
Telemetry. |
vetta-infer-gw |
Wire gateway: the stdin/stdout line protocol the agent speaks; CLI. |
Current state (honest)
- The engine runs real inference, end-to-end, and it is correct. The full
48-visit Inkling-2-Mini forward (prelude + looped core ×3 passes with bank
rollback + coda + final depth-mix/softcap) runs on the real
gfx1150weights. Greedy decoding is EXACT multi-token parity against the hardenedstratareference (16 and 40 tokens, F32 and FP16 KV). The two root causes of the old token-2+ gap were structural, not precision: per-pass KV pools and the unpadded logit vocab (200058). - Linked to the agent framework.
strata-ctl --servespawnsvetta-inferand serves its OpenAI-compatible API; the wire protocol (READY/INFO/T/PP/ RESUME/DONE/ERR) is field-for-field compatible. Verified live: capital queries, Italian multi-turn, EOS/stop handling. - First real interactive GUI conversation (2026-12-01, measured). Through the
strata-ctlweb GUI on Sogliola (http://sogliola:1234), enginevetta-infer:- prompt "Ciao, sono Federico" → "Ciao Federico! Piacere di conoscerti. Come posso aiutarti oggi?"
- 2650 prompt + 53 completion tokens · 4.2 tok/s decode · first token 618 s.
- The 618 s time-to-first-token is the sequential prefill of the GUI's ~2650-token agent prompt (~140 ms/token); decode itself is ~4.2 tok/s. This is the honest current performance frontier, not a hang.
- Host CPU during inference is no longer a busy-wait. ROCm's default spin
host-wait schedule pinned the process at ~100% CPU; setting
hipDeviceScheduleBlockingSyncbefore context creation (as the reference does) dropped it to ~54% (measured A/B 101.2% → 54.2%). The residual ~54% is genuine kernel-launch submission cost (~1300 launches/token), removed only by HIP graph capture. - What is NOT done yet (the frontier): HIP graph capture (collapse the per-token launches → near-zero host CPU), batched prefill / prefix cache (make large-prompt time-to-first-token seconds, not minutes), and the expert-GEMV math speedup (WMMA). These are the M2 performance work — correctness is already there; speed is the next axis.
The road to the goal
The destination: a working, measured inference engine that the agent framework
can talk to over the wire, replacing the old strata engine for a real
conversation. Steps 1–5 are landed — the first real GUI conversation happened
on 2026-12-01 (see Current state). The path, in order:
- Inkling graph parity — ✅ landed (attention-residual block-mix, loop
controllers, ShortConv4, relative-position bias, sliding-window attention,
per-pass KV). Blueprint:
docs/inkling-forward-design.md. - Remaining kernels — ✅ landed (flash GQA/SWA, MoE NVFP4/MXFP8 routing + experts + reduce, KV-write, L2-clip, relpos). Each parity-verified.
- Executor — ✅ landed (full 48-visit forward on real weights).
- Weights → device — ✅ landed (resident
WeightCache, lazy expert load). - Serve wiring + first chat — ✅ landed (
strata-ctllink, EXACT parity, first real GUI conversation 2026-12-01). - M2 performance — ⏳ the current frontier: HIP graph capture (host CPU), batched prefill / prefix cache (time-to-first-token), expert-GEMV WMMA (decode tok/s). Measured against the reference, no unmeasured claims.
- M3 Lyra co-processor — remote drafting, semantic domain routing, domain-aware expert prefetch.
How to verify
# CPU workspace tests (host-independent, no GPU/toolchain needed):
RUSTFLAGS="-D warnings" cargo test --workspace
# Lean proofs (0 sorryAx, standard axioms):
lean proofs/slab_ring_dma.lean
lean proofs/bus_lifecycle.lean
lean proofs/serve_session.lean
lean proofs/arena_plan.lean
# Opt-in live tests against the real Inkling artifact:
cargo test -p vetta-infer-ld -- --ignored inkling
# GPU kernel parity (requires gfx1150 + ROCm; builds kernels via hipcc):
cargo test -p vetta-infer-hip --features hip -- --ignored
Where to read next
docs/ARCHITECTURE.md— the decision-complete spec (microkernel, services,.vbundle, plans, wire contract, milestones).docs/inkling-forward-design.md— the Inkling forward pass, extracted from the reference, that the graph emitter follows.proofs/*.lean— the verified state machines and arena plan.AGENTS.md— the engineering rules and hard invariants.
Welcome. Take your time with the mental model first; the code reads much more naturally once the five ideas above click.