- proofs/arena_plan.lean: memory.vplan arena safety (8 theorems + 4 computational examples, 0 sorryAx): no overlap, checked index bounds, no use-before-write, overlap-rejection completeness. - abi::arena: validator mirroring the proof, checked offset arithmetic (invariant #2), explicit error per violation class; 8 tests. - abi::bundle: .vbundle manifest (ABI_VERSION=1, source+packer fingerprints, backend target; incompatible ABI rejected explicitly), checked memory.vplan/graph.vplan parsing, arena-validated compile(); 7 tests. - ld::bundle: read-only load_bundle_plans(dir) over manifest + plan/*.vplan; 3 tests (good bundle, missing file, ABI mismatch). - abi::vplan: encoder-lane opcodes (layer_norm, flash_full_attn, gelu_erf, mean_pool_l2norm) + wire name mapping for all 22 opcodes, roundtrip test. - Docs: utility-encoder scope carve-out (dense decoder LMs out, small fully-resident encoders in), embedder-lane wire proposal + characteristic parity vs vetta-semantics (cosine vs oracle, internal bit-exact goldens), 16-primitive kernel set, M1.5 milestone; README/AGENTS aligned (65 tests, 42 theorems across 4 proof files). - review/: tandem exchange with the strata-ctl coder (their request + observations, our formal reply: embedder accepted, M0 dir cleanup done). Verified live: RUSTFLAGS="-D warnings" cargo test --workspace = 65/65 PASS; lean proofs/{slab_ring_dma,bus_lifecycle,serve_session,arena_plan}.lean green, standard axioms only.
3.8 KiB
3.8 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,lean proofs/arena_plan.lean - CPU workspace tests:
cargo test --workspace - Commit prefixes:
[ABI],[KN],[LD],[CC],[RT],[LAB],[SP],[NT],[TM],[GW],[Proofs],[Docs]