Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

rivoli is a Rust workspace with one backend, HIP/ROCm. Its six crates are the layering: crate edges are the only layering Rust enforces, so the boundaries that matter are crates.

crateismay depend on
rivoli-corepure planning: residency, spans, legality, gates, tolerancesnothing
rivoli-artifactformats, per-model configs, sniffing, tokenizer, converterscore
rivoli-oraclesfrozen references, golden container, anchor readerscore
rivoli-backendthe waist: HIP streams, launchers, kernels; owns rocmnothing
rivoli-enginethe interpreter: fetch, executors, per-architecture loopsall above
rivoli (cli)thin main, serve and tool binariesengine

Pure core, imperative shell

rivoli-core is total functions over plain data. It emits values (directives, spans, verdicts) and never acts. rivoli-engine is the interpreter that spends those values on the device. Nothing in core can name a stream, a pointer or a weight format, and the dependency graph enforces it. That is what makes “residency selects arithmetic” impossible to write here, rather than merely tested against.

Types carry the rules

  • Newtypes for units. Bytes, tokens, layers and expert ids are never bare usize.
  • Typestate for lifecycles. A fetch ticket is consumed by waiting on it, a writer is sealed, and an unloaded artifact is a different type from a loaded one.
  • No panicking shortcuts. unwrap and expect are denied across the workspace.

Kernels in Rust

The device kernels are written in Rust (crates/kernels) and built with a pinned nightly toolchain against ROCm’s device bitcode. hipcc is not a build input. Every kernel is checked bit-for-bit against the original HIP C++ implementation it replaced, at a pinned tag.

The artifact is the model

rivoli <artifact> takes a converted artifact directory: a manifest, codebooks, resident tensors, per-layer expert files and a tokenizer. The artifact names its own architecture. CLI flags are checked against it at startup, and an illegal one is refused with the reason.