Attention, quantization, model architectures, training, and inference built on numr, for CPU, CUDA, and WebGPU.
Docs · Crate · What works · Example · Feature Flags · Testing · Contributing
boostr is an ML framework for Rust. Use it to build LLM apps, run inference, and train models, with the role PyTorch and Hugging Face Transformers have in Python. It runs on CPU, CUDA, and WebGPU. The code is Rust. No Python is needed.
boostr extends numr with ML operations and adds no tensor type or runtime wrapper.
Its Tensor, Runtime, and client types come from numr.
ML operations attach to numr's clients as extension traits.
- Used to build: oxidizr (training), blazr (inference server), compressr (quantization), and voxr (audio and speech).
- Not supported yet: WebGPU computes in
F32only. Flash attention v3 needs a Hopper GPU. ROCm is not implemented.
| Backend | Feature | Needs | Limits |
|---|---|---|---|
| CPU | cpu, on by default |
Nothing | None |
| NVIDIA through CUDA | cuda |
CUDA toolkit 12.8 or newer, nvcc on PATH, compute capability 7.5 (Turing) or newer |
Flash attention v3 needs compute capability 9.0 (Hopper) |
| WebGPU | wgpu |
Vulkan, Metal, or DX12 driver | Computes in F32 only |
| Area | Contents | Feature |
|---|---|---|
| Text models | LLaMA, Mamba2, hybrid transformer and SSM, Qwen3.5, Qwen3-VL vision encoder, text encoders | None |
| Audio models | Whisper, Kokoro, VITS, VoxCPM2, NeuCodec, Silero VAD, CLAP | One per model, listed in Feature Flags |
| Text tagging | spaCy en_core_web_sm part-of-speech tagger |
spacy-tagger |
| Image models | SrVggCompact, RrdbNet |
super-resolution |
| Quantization | Simple blocks, K-quants, IQ, ternary, and low-bit formats | None |
| LLM apps | Build an app on your own models with no separate server: model loading, sampling, KV and prefix caches, speculative decoding, a sequence scheduler with batching, and GBNF or JSON schema output | None |
| Training | Optimizers, gradient scaling, and exact resume | None |
| Distributed training | ZeRO stages 1, 2 and 3, tensor parallelism, and pipeline parallelism with GPipe, 1F1B and ZeroBubble schedules. Trainers wire these in themselves | nccl for GPUs |
| Distributed inference | Disaggregated prefill and decode, pipeline stages, and KV transfer over nexar | distributed |
CI has no GPU. Some ops run on some backends only. docs/capabilities.md lists every capability, and docs/architecture.md holds the layout and design rules.
Needs Rust 1.95 or newer.
[dependencies]
boostr = "0.11" # CPU
# boostr = { version = "0.11", features = ["cuda"] }
# boostr = { version = "0.11", features = ["wgpu"] }Run flash attention on the CPU backend:
use boostr::ops::traits::attention::{AttnOutLayout, FlashAttentionOps};
use boostr::{CpuClient, CpuDevice, DType};
use boostr::RandomOps;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = CpuClient::new(CpuDevice::new());
// Random tensors via numr's RandomOps: [batch, heads, seq, dim]
let q = client.randn(&[1, 8, 32, 64], DType::F32)?;
let k = client.randn(&[1, 8, 32, 64], DType::F32)?;
let v = client.randn(&[1, 8, 32, 64], DType::F32)?;
let (output, _lse) = client.flash_attention_fwd(
&q,
&k,
&v,
8, // num_heads
8, // num_kv_heads
64, // head_dim
true, // causal
0, // window_size (0 = no sliding window)
None, // kv_seq_len
None, // kv_start
AttnOutLayout::HeadMajor, // output layout: [B, H, S_q, D]
)?;
Ok(())
}use boostr::format::Gguf;
use boostr::{CpuDevice, CpuRuntime};
// Open a GGUF file with buffered reads
let mut gguf = Gguf::open("model.gguf")?;
let device = CpuDevice::new();
// Load quantized tensors as QuantTensor and the others as f32
for name in gguf.tensor_names().map(|s| s.to_string()).collect::<Vec<_>>() {
let info = gguf.tensor_info(&name)?;
if info.ggml_type.is_quantized() {
let qt = gguf.load_tensor_quantized::<CpuRuntime>(&name, &device)?;
} else {
let t = gguf.load_tensor_f32::<CpuRuntime>(&name, &device)?;
}
}Use Gguf::open_with_mmap(path, true) to memory-map the file. Each loader call releases mapped pages after it copies a tensor.
use boostr::inference::PagedKvCache;
use boostr::{CpuClient, CpuDevice, CpuRuntime, DType, Tensor};
use boostr::RandomOps;
let device = CpuDevice::new();
let client = CpuClient::new(device.clone());
let (num_blocks, block_size, num_heads, head_dim) = (16, 16, 8, 64);
let cache = PagedKvCache::<CpuRuntime>::new(
num_blocks, block_size, num_heads, head_dim, DType::F32, &device,
)?;
// key and value: [num_tokens, num_heads, head_dim]
let k = client.randn(&[4, num_heads, head_dim], DType::F32)?;
let v = client.randn(&[4, num_heads, head_dim], DType::F32)?;
// slot_mapping: [num_tokens], I64. Slot s maps to block s / block_size, offset s % block_size.
let slots = Tensor::<CpuRuntime>::from_slice(&[0i64, 1, 2, 3], &[4], &device)?;
cache.update(&k, &v, &slots, &client)?;Copy .cargo/config.toml.example to .cargo/config.toml first. See CONTRIBUTING.md.
cargo build --release # CPU
cargo build --release --features cuda # CUDA
cargo build --release --features wgpu # WebGPU- CUDA binaries:
build.rscompiles kernels for the GPUs on the build host. SetNUMR_CUDA_ARCH=allfor a binary that runs on another machine. - boostr kernels only:
BOOSTR_CUDA_ARCHoverridesNUMR_CUDA_ARCH.
NUMR_CUDA_ARCH=all cargo build --release --features cudaBackends:
| Feature | Adds |
|---|---|
cpu |
CPU backend (default) |
cuda |
CUDA GPU backend |
wgpu |
WebGPU cross-platform GPU backend |
nccl |
Multi-GPU through NCCL |
distributed |
Distributed inference over nexar. Implies f16 |
Precision:
| Feature | Adds |
|---|---|
f16 |
Half-precision floats |
fp8 |
FP8 precision |
Models and signal ops. No model feature implies another:
| Feature | Adds |
|---|---|
audio |
Tensor-level signal ops (STFT, iSTFT, mel) |
whisper |
Whisper speech recognition. Implies audio |
kokoro |
Kokoro speech synthesis. Implies audio |
vits |
VITS / MMS-TTS speech synthesis. Implies audio |
neucodec |
NeuCodec audio codec. Implies audio |
voxcpm |
VoxCPM2 speech synthesis. Implies audio and f16 |
silero-vad |
Silero voice activity detection. Implies audio |
clap |
CLAP audio and text towers. Implies audio |
spacy-tagger |
spaCy CNN part-of-speech tagger |
super-resolution |
SrVggCompact for realesr-general-x4v3, and RrdbNet ×2 for RealESRGAN_x2plus and 2x_PureVision. Half precision also needs f16 |
Tokenizer vocabularies:
| Feature | Adds |
|---|---|
vocab-* |
One bundled splintr vocabulary each. See docs/capabilities.md |
vocabs |
Every bundled splintr vocabulary |
# CPU tests, no model gates
cargo test
# Every model gate on the CPU backend
cargo test --features whisper,kokoro,neucodec,voxcpm,silero-vad,vits,clap,spacy-tagger,super-resolution,f16
# CUDA tests
cargo test --features cuda,f16
# Show test output
cargo test -- --nocaptureRun the format and lint checks in CONTRIBUTING.md before you open a pull request.
boostr is part of the ml-rust organization:
- numr: Foundational numerical computing (tensors, ops, linalg, FFT)
- boostr: ML framework (this project)
- oxidizr: Training framework for Mamba2, MLA, and MoE (uses boostr)
- blazr: Inference server with an OpenAI-compatible API (uses boostr)
- compressr: Model quantization and compression (uses boostr)
- voxr: Audio and speech on top of boostr's models
- splintr: BPE tokenizer
Contributions are welcome. See CONTRIBUTING.md for conventions and checks.
Questions and design discussion happen on Discord.
Licensed under the Apache License, Version 2.0. See LICENSE.
Parts of boostr port code from other open-source projects. Their copyright lines and licenses are in THIRD_PARTY_NOTICES.md.