Dissolve the M0 crates (core/io/proto/telemetry/hip/cli) into the approved service layout abi/kn/ld/cc/rt/lab/sp/nt/tm/gw (docs/ARCHITECTURE.md). - kn: Lean-verified control bus + service registry (bus_lifecycle.lean, 14 thms) and SlabRing/UMA broker; rt: PrefixState + hybrid checkpoint pool. - sp: faithful throughput-aware Adaptive-K port of clover_policy.h (cooldowns, probes, throughput guards) with scenario parity tests. - gw: strata-ctl-compatible wire emitters + serve session FSM (serve_session.lean, 10 thms); abi::serve accepts image= (Vision delta closed). - abi: pure contracts, checked JSON/VTC1/GEN parsers, zero-alloc sampler. - ld/cc: checked safetensors reader + write-once VTC1 writer / O_RDONLY reader. - tm: lock-free telemetry; nt: LyraRpc; lab shares the rt executor core. - Docs: ARCHITECTURE.md decision-complete spec (MoE-only scope, .vbundle, .vplan->CompiledPlan, wire contract, migration map); AGENTS.md Lean rule + tandem/review workflow. Verified live: cargo test --workspace -D warnings = 46/46 PASS; lean proofs = 34 theorems (slab_ring_dma 10, bus_lifecycle 14, serve_session 10), 0 sorryAx, standard axioms only; vetta-infer info on Inkling = 1244 tensors, 18.18 GiB, checked bounds.
3.7 KiB
3.7 KiB
AGENTS.md — vetta-infer
Rules and engineering standards for working on vetta-infer.
Architecture & Scope
- MoE-first microkernel engine in Rust (edition 2024) with minimal AMD ROCm HIP kernels (
gfx1150/ RDNA 3.5 primary target; UMA96 GiB+ dual NVMe). - Authoritative design:
docs/ARCHITECTURE.md(approved 2026-11-29) — pure microkernelvetta-infer-kn+ services (abi/kn/ld/cc/rt/lab/sp/nt/tm/gw), dual-step loader →.vbundle/,.vplan→CompiledPlanat boot. The crate realignment completed 2026-11-30 (M0 crates dissolved intovetta-infer-*); behavior is ported from the measured strata engines (../strata*worktrees), never re-invented from summaries. - Clear boundary: all control flow, parsing, caching, scheduling, speculative verification, protocol handling, and telemetry stay in safe, CPU-testable Rust crates.
unsafeis isolated tort(HIP FFI/DMA fence wrappers) andcc(io_uring/preadsyscalls). - No silent regressions or unmeasured claims: every performance or quality claim must carry real measurements and the exact hardware/model/flags used.
Hard Invariants (Eliminate Past Audit Classes By Construction)
- DMA / Async Transfer Ownership: never pass a stack variable or short-lived
VectohipMemcpyAsyncorio_uring. Every in-flight transfer owns or pins itsSlabSlotuntil its completion fence/CQE is observed (verified inproofs/slab_ring_dma.lean). - Checked Bounds Everywhere: all
.safetensorsheader offsets, slices, and NVMe disk-cache metadata counts MUST use checked integer arithmetic (checked_add,checked_sub,count <= blob.len() / MIN_REC_BYTES) before any allocation. - Write-Once /
O_RDONLYNVMe Caches: caches are written atomically via.tmp.<pid>+fsync+renameonly on miss, and opened strictlyO_RDONLYon every reload (0 SSD writes). - Typestate Prefix / MTP / Checkpoint Validity: never rely on loose integer pairs (
prefix_len,mtp_prefix_len) to infer device buffer initialization. Represent state via explicit enums (PrefixState), and commit pool metadata only after GPU allocations/copies succeed. - Zero-Allocation Hot-Path Sampling & Explicit Non-Finite Tracking: no per-token
O(V)heap allocations, no silent256-cap truncation whentop_k == 0withtop_p/min_p, centralizedmask_token_idsuppression, and explicit reporting of non-finite logits. - Formal Verification with Lean 4 (Federico's rule): simple correctness logic is written directly with ordinary CPU tests; complex logic (non-trivial state machines, ring buffers, checkpoint pools, speculative/rollback invariants, memory-arena plans) is modeled in
proofs/*.leanand verified by the Lean kernel (0 sorryAx, standard axioms only) before writing the implementation.
Tandem & Review Workflow
- Principal consumer:
strata-ctl(../strata-ctl), developed by a peer coder in tandem. The living wire contract isstrata-ctl/src/engine/protocol.rs+supervisor.rs; engine-side guarantees and known deltas are tracked indocs/ARCHITECTURE.md§6. - Mutual reviews: each coder periodically reviews the other's work; an external reviewer audits both. Wire-protocol changes land in coordinated review cycles across the two repos — never unilaterally.
- Parity discipline: every policy/kernel ported from strata ships a parity test against the measured reference behavior (e.g. Adaptive-K must match
clover_policy.h, not a simplified sketch).
Verification Commands
- Proofs:
lean proofs/slab_ring_dma.lean,lean proofs/bus_lifecycle.lean,lean proofs/serve_session.lean - CPU workspace tests:
cargo test --workspace - Commit prefixes:
[ABI],[KN],[LD],[CC],[RT],[LAB],[SP],[NT],[TM],[GW],[Proofs],[Docs]