Website · English Docs · Русский · Velri-lib · VTQ Quantization · llms.txt · License: MIT
Velri is an open-source, native neural-network and LLM inference engine for Linux, Windows, and Android, designed to run large models whose weights exceed GPU VRAM through explicit memory planning and CPU+GPU offloading. Written in C23 and C++23 behind a public C23 API, Velri compiles composable Khronos Slang (slangc) kernels ahead of time (AOT) for both CPU (x86-64 AVX2, AVX-512 VNNI, ARM64, RISC-V 64) and Vulkan 1.3 / SPIR-V 1.6 — with zero Python, PyTorch, CUDA, LLVM, or Slang compiler dependencies at runtime.
| Repository | Role | Key Technologies |
|---|---|---|
| velri-inference/velri (this repo) | Inference engine, model composition, placement planner, and C23 runtime (Context, Model, Program, Session) |
C23/C++23, cascading JSON placement, GPT-2 / Llama / Qwen2 runtime |
velri-inference/velri-lib (also in velri-lib/) |
Standalone C23 computation library (VelriLib::velri) — tensor views, liveness scratch planner, graphs, and backends |
23 Slang AOT CPU kernels, 29 Vulkan 1.3 SPIR-V 1.6 shaders (CoopMat, FlashAttention) |
| velri-inference/vtq-research | VTQ (Velri Trellis Quant, .vtq v2) hardware-co-designed 16×256 trellis weight quantization (1.5–6.0 bpw) |
Tail-biting Ungerboeck TCQ, Outer-DCT rotation, AVX2 vpshufb & GPU DP4A (36/36 KLD wins vs EXL3 & GGUF) |
Single request after a 128-token prompt, 64 dependent greedy decode steps through the public velri_session_step API (mean of 3 interleaved processes per backend; full methodology and SHA-256 artifacts in English · Русский):
| Backend | Hardware | 64-Token Time | Decode Speed | W8A8 Projection Ceiling Share |
|---|---|---|---|---|
| CPU (AVX2) | AMD Ryzen 9 9950X (16 cores, DDR5-6000) | 1048.04 ms |
61.07 tok/s |
91.57% of streaming DRAM ceiling |
| CPU (AVX-512) | AMD Ryzen 9 9950X (16 cores, DDR5-6000) | 1064.62 ms |
60.12 tok/s |
91.14% of streaming DRAM ceiling |
| Vulkan 1.3 | NVIDIA RTX 5070 Ti (GDDR7) | 113.64 ms |
563.16 tok/s |
76.69% weighted (95.84% on 32000×2048) |
Measured via bench_slang_cpu --workers 16 (1024×4096×4096 GEMM and cold-DRAM single-token GEMV, 0 B hot-path allocations):
| Precision / Mode |
1024×4096×4096 GEMM |
Cold-DRAM GEMV | Notes |
|---|---|---|---|
FP32 (F32) |
4.02 TFLOPS |
66.4–71.3 GB/s |
5-loop L2-resident BLIS in portable Slang AOT |
FP16 → FP32 (F16) |
4.07 TFLOPS (4.17 TF at 256 rows) |
66.4–71.3 GB/s |
Shared IElement Slang component |
BF16 → FP32 (BF16) |
4.20 TFLOPS |
66.4–71.3 GB/s |
Shared IElement Slang component |
F32 × BF16 (F32xBF16) |
4.16 TFLOPS (4.29 TF at 256 rows) |
66.4–71.3 GB/s |
Mixed-precision linear |
FP64 (F64) |
2.02 TFLOPS (2.05 TF at 256 rows) |
66.4–71.3 GB/s |
Zero-spill AVX-512 BLIS microkernel |
| INT8 W8A8 (packed) |
17.87 TOPS (80.3% VNNI peak) |
66.4–71.3 GB/s |
Exact deterministic mod |
VelriLib::velri(aliasVelriLib::core, v0.7.0) is implemented and verified invelri-lib/:- Modular Lego-brick architecture (
-DVELRI_BACKENDS="cpu;vulkan", verified down to zero-backend builds bytools/check_architecture.pyandtest_core_contract): pure MatOps (ops/), backend-agnostic blocks (blocks/,layers/), liveness scratch planner, UMA-aware memory report, plan-shared weights (velri_plan_bind_weight_hostandvelri_plan_bind_weight_stream),velri_ext_op_desccustom-op plugin ABI, device-resident state with explicit host sync, and independent concurrent execution slots. - Slang-first AOT kernels compiled at build time for CPU (portable base, x86-64 AVX2/AVX-512, ARM64, RISC-V 64) and Vulkan 1.3 / SPIR-V 1.6 (
spirv-val-verified shaders withCoopMat, FlashAttention, Split-K/Split-KV, and a 4×16 MiB write-combined async upload ring), verified bytest_kernels(Kernels).
- Modular Lego-brick architecture (
- Velri Engine (
velri_engine) is implemented and verified:- Public C23 runtime (
include/velri/velri.h):Context,Model, single- and dual-planProgram(with live prepare progress callbacks andinspect),Session, lock-freeCancel, zero-alloc sampler, and cascading JSON placement configs (examples/example-dense.json). - Self-contained
.vtqv2 container reader (multi-shard dense F32/F16/BF16 +vtq.trellis_16x256AVX2/SPIR-V quantized ExtOp plugin), double-buffered2×16 MiBO_DIRECTdisk-to-VRAM weight streaming with sequential offset sorting and page-cache eviction (~5.6 GB/scold NVMe on GPT-2 XL F32), zero-dependency BPE tokenizer, and GPT-2 / Llama / Qwen2 models.
- Public C23 runtime (
- Standalone Apps (
apps/) are implemented and verified:apps/oai/(velri_oai): zero-dependency OpenAI-compatible HTTP/1.1 + SSE server library (/v1/chat/completions,/v1/completions,/v1/models,/health, CORS, UTF-8 safe streaming, stop sequences, pre-allocated session pool, client-disconnect cancellation, and per-request Prefill/Decode timings).apps/cli/(velri): UNIX-style CLI withvelri serveandvelri inspect(stdout/stderrseparation,-c -stdin config, live weight-load progress bar, Model Load Graph, server/hardware dashboard,inspect --json, and per-request Prefill/Decode speed logs).
- The earlier handwritten C23/SIMD CPU backend and deprecated
VelriLib::cpu_lineartarget are preserved for reference on brancharchive/c23-cpu-legacy. Next architecture and serving milestones live in Roadmap.
Requires CMake 3.21+, Ninja, Clang 18+ or GCC 14+ (C23 mode), and Khronos Slang (slangc) on PATH (or -DVELRI_SLANGC=/path/to/slangc):
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DVELRI_BACKENDS="cpu;vulkan"
cmake --build build -j
ctest --test-dir build --output-on-failureslangc is a build-time AOT tool only (no Slang or LLVM runtime dependency). Omit vulkan from -DVELRI_BACKENDS="cpu" for a CPU-only build with zero Vulkan SDK dependency, or pass -DVELRI_BUILD_BENCHMARKS=ON to build bench_session, bench_slang_cpu, and bench_vulkan. For standalone library builds, cross-compilation (Android, Windows, ARM64, RISC-V 64), and package installation, see velri-lib/README.md.
Run the UNIX CLI and OpenAI-compatible server directly after building:
./build/velri inspect # list devices (or --json)
./build/velri inspect -c config.json --json # inspect placement & memory plan
./build/velri serve -c config.json # start OpenAI HTTP/SSE serverWith benchmarks enabled, build/bench_session cpu 16 or build/bench_session vulkan times 64 consecutive greedy decode steps on one synthetic FP32 Llama session following a 128-token prompt. To benchmark a real checkpoint, convert a plain-RoPE Llama safetensors snapshot with python3 tools/prepare_session_weights.py SNAPSHOT weights.w8 (NumPy required), then run build/bench_session cpu 16 --isa avx2 --weights weights.w8 or build/bench_session vulkan 1 --weights weights.w8. See the measurement protocol and the 9950X / RTX 5070 Ti results (English · Русский).
- Composable kernels without copy-paste: share Slang components (
IElement,IActivation,IEpilogue,IKVSource) across operations and compile one source across target ISAs and GPU APIs viaslangcAOT — no duplicate AVX2 vs. AVX-512 kernel sources and zero compiler at runtime. - Blocks without family branches: assemble models from reusable blocks and operations; adding a model never hardcodes family names into shared kernels or backends.
- Values are not allocations:
KandVare input roles that may share storage or derive from other state; allocators reserve only declared storage. - Prepare once, zero heap allocations per step: pack weights, select AOT kernels, build pipelines, and allocate slots during
prepare. - Verify honestly: every kernel has an independent C23 reference, memory bounds checks (
guard pages+ ASan/UBSan), and full-call benchmarks compared against measured physical hardware ceilings.
English and Russian pages stay in 1:1 sync with reciprocal links on every page.
| English | Русский | Contents |
|---|---|---|
| Reading Guide | Карта документации | Overview and navigation |
| Architecture & Stack | Архитектура и стек | Engine pipeline, build, and dependencies |
| Blocks & Configuration | Блоки и конфигурация | Model composition and JSON placement schema |
| Public C API | Внешний C API | Context, Model, Program, Session, OpenAI-compatible HTTP/SSE API |
| Performance Methodology | Методика измерений | TFLOPS/TOPS, GB/s, ceilings, and tables |
| TinyLlama Decode64 Report | Отчёт Decode64 | 9950X CPU & RTX 5070 Ti Vulkan W8A8 decode results |
| Roadmap | План работ | Stages and acceptance criteria |
| Glossary | Словарь | Velri, velri-lib, Slang, and model terms |
| Model Architectures | Архитектуры моделей | Family references (Gemma 4, Qwen3.5, Qwen3.8, ...) |
| Velri-lib Architecture | Архитектура Velri-lib | Library boundary, graph, storage/K-V, backend registry |
| Slang-First Kernels | Кернелы на Slang | Composable Slang AOT for Vulkan and CPU |
| Execution & Sync | Исполнение и синхронизация | prepare, UMA budgets, hybrid CPU+Vulkan, cancellation |
- What language is Velri written in? C23 and C++23 behind a pure C23 public API, with compute kernels authored in Khronos Slang and compiled ahead of time (
slangcAOT). Velri is not written in Rust and does not require CUDA. - Does Velri need
slangc, LLVM, or Python at runtime? No.slangcis a build-time tool only; shipped binaries have zero runtime compiler, Python, or PyTorch dependencies. - What quantization format does Velri target? VTQ (Velri Trellis Quant,
.vtqv2) developed in velri-inference/vtq-research. VTQ supersedes earlierLTQand.liqkresearch prototypes, delivering strictly lower teacher-forced KLD than EXL3 and GGUF across1.5–6.0 bpwwith16×256supertiles shared across CPU (AVX2) and GPU. - Can I use the compute library without the full engine? Yes —
velri-libbuilds and installs standalone asVelriLib::velri(find_package(VelriLib 0.7.0 EXACT CONFIG REQUIRED)).
Licensed under the MIT License. If you reference Velri in code, benchmarks, or papers, see CITATION.cff.