2.4 KiB
2.4 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). - Clear boundary: all control flow, parsing, caching, scheduling, speculative verification, protocol handling, and telemetry stay in safe, CPU-testable Rust crates.
unsafeis isolated tovetta-hip(FFI/DMA fence wrappers) andvetta-io(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: model non-trivial state machines, ring buffers, checkpoint pools, and speculative/rollback invariants in
proofs/*.lean(0 sorryAx, verified withlean) before writing the implementation.
Verification Commands
- Proofs:
lean proofs/slab_ring_dma.lean - CPU workspace tests:
cargo test --workspace - Commit prefixes:
[Core],[IO],[HIP],[Proto],[Telemetry],[Proofs],[Docs]