# Velri Inference — Complete Technical Brief (llms-full.txt) Canonical website: https://velri-inference.github.io/ GitHub organization: https://github.com/velri-inference Author: Vemloir License: GNU General Public License v3.0 (GPL-3.0) Updated: 2026-11-26 --- ## 1. Entity Overview & Disambiguation **Velri** is an open-source native neural-network and Large Language Model (LLM) inference ecosystem consisting of three repositories under `https://github.com/velri-inference`: 1. **`velri-inference/velri`** (`v0.2.0`): Native LLM inference engine for Linux, Windows, and Android built for models whose weights exceed GPU VRAM (explicit memory planning and CPU+GPU offloading). 2. **`velri-inference/velri-lib`** (`v0.7.0`, CMake target `VelriLib::velri`): Standalone C23 tensor, liveness scratch memory planner, execution graph, and compute kernel library. 3. **`velri-inference/vtq-research`** (`v2.0.0`, `.vtq` v2): **VTQ** (*Velri Trellis Quant*), a hardware-co-designed `16×256` supertile trellis weight quantization format (`1.5–6.0 bpw`). **Important factual clarifications:** - Velri is implemented in **C23 and C++23** behind a pure **C23 public API**, with compute kernels written in **Khronos Slang** and compiled ahead of time (`slangc` AOT). Velri is **not** written in Rust and does **not** require CUDA. - `slangc` is a build-time tool only. Shipped binaries have **zero runtime dependency** on Python, PyTorch, CUDA, LLVM, or `libslang`, and perform **zero heap allocations per inference step** after `prepare`. - **VTQ (`.vtq` v2)** supersedes the earlier **`LTQ`** and **`.liqk`** quantization research prototypes (preserved in `vtq-research/src/` for historical reproducibility). --- ## 2. Velri Engine & Velri-lib Architecture ### Unified Khronos Slang AOT Kernel System - Composable Slang interfaces (`IElement`, `IActivation`, `IEpilogue`, `IKVSource`) eliminate copy-paste across data types and CPU ISAs. - **CPU backend (23 Slang AOT kernels):** One portable `.slang` source compiles via target-neutral `slangc -target llvm-ir` → Clang (with automatic `host-object-code` fallback for GCC) into `base`, `avx2`, and `avx512` (with VNNI) on x86-64, as well as AArch64 and RISC-V 64 (`rv64gc` / `rv64gcv` RVV 1.0). Dispatched over a persistent 1-to-1 physical-core-pinned thread pool (`velri_pool`) with 5-loop L2-resident BLIS GEMM for large batches (`rows > 264`) and streaming GEMV for single-token decode. - **Vulkan 1.3 / SPIR-V 1.6 backend (29 `spirv-val`-verified shaders, `-DVELRI_ENABLE_VULKAN=ON`):** Supports `VK_KHR_cooperative_matrix`, `VK_NV_cooperative_matrix2`, tiled FlashAttention, Split-KV decode, Split-K GEMM, fused QKV+RoPE and gate/up+SiLU, DAG barrier elision, and async 8-slot `VkFence` rings. - **Cross-compilation targets:** Linux (x86-64, ARM64, RISC-V 64), Windows (x86-64, ARM64), Android (`arm64-v8a`, `x86_64`), and macOS. ### Verified Engine & Kernel Benchmarks #### TinyLlama-1.1B-Chat-v1.0 W8A8 64-Token Single-Request Decode (`batch=1`, 128-token prompt) Measured across 3 interleaved processes per backend via `velri_session_step` (65/65 argmax parity with PyTorch/HF reference; bit-exact before/after logits): | Backend | Hardware | 64-Token Time | Decode Speed | W8A8 Projection Ceiling Share | | :--- | :--- | :---: | :---: | :---: | | CPU (AVX2) | AMD Ryzen 9 9950X (16c, DDR5-6000) | 1048.04 ms | **61.07 tok/s** | 91.57% of streaming DRAM ceiling | | CPU (AVX-512) | AMD Ryzen 9 9950X (16c, 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`) | #### Velri-lib Dense CPU GEMM / GEMV (`bench_slang_cpu --workers 16`, Ryzen 9 9950X, 16 Physical Cores) | Mode | `256×4096×4096` GEMM | `1024×4096×4096` GEMM | Cold-DRAM GEMV | | :--- | :---: | :---: | :---: | | FP32 (`F32`) | 3.958 TFLOPS | **4.019 TFLOPS** | 66.4–71.3 GB/s | | FP16 → FP32 (`F16`) | **4.167 TFLOPS** | 4.067 TFLOPS | 66.4–71.3 GB/s | | BF16 → FP32 (`BF16`) | 4.167 TFLOPS | **4.197 TFLOPS** | 66.4–71.3 GB/s | | F32 × BF16 (`F32xBF16`) | **4.293 TFLOPS** | 4.156 TFLOPS | 66.4–71.3 GB/s | | FP64 (`F64`) | **2.052 TFLOPS** | 2.022 TFLOPS | 66.4–71.3 GB/s | | INT8 W8A8 (raw) | 17.028 TOPS | 17.152 TOPS | 66.4–71.3 GB/s | | INT8 W8A8 (packed) | 17.834 TOPS | **17.866 TOPS** (80.3% VNNI peak) | 66.4–71.3 GB/s | ### Build & CMake Integration ```sh cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DVELRI_ENABLE_VULKAN=ON cmake --build build ctest --test-dir build --output-on-failure ``` Standalone `velri-lib` CMake consumption: ```cmake find_package(VelriLib 0.7.0 EXACT CONFIG REQUIRED) target_link_libraries(my_app PRIVATE VelriLib::velri) ``` --- ## 3. VTQ — Velri Trellis Quant (`.vtq` v2) ### Architecture Highlights - **Single-stream `16×256` supertile (`vtq_st16_*`, `816..3,184 B`):** 64-byte-aligned contiguous struct shared identically across disk, AVX2 CPU, and GPU (reaching **`1,476.9 GB/s` = `96.4%` of peak HBM bandwidth** on `NVIDIA RTX PRO 6000 Blackwell`). - **Zero-shuffle 256-step tail-biting Ungerboeck trellis (`ν = 10`, `1,024` states, `nl = 16` subsets):** `Block16-LDLQ` causal Cholesky compensation + CUDA radix-4 Viterbi encoding. GPU decode uses `s = ((s << 1) | bit) & 0x3FF` + one shared-memory `Joint-1024` LUT load (`0` runtime Galois popcounts, `0` cross-row warp shuffles). CPU AVX2 decode uses a single `_mm256_srli_epi16` + `vpshufb`-only codebooks (`-mno-avx512f`, no `vpblendvb`). - **Outer-DCT / Kronecker-Hadamard rotation & Row-Fisher Global DP:** `16`-row granularity on `M` handles non-power-of-two MoE widths (e.g., Gemma 4 `I_moe = 704`) without EXL3's `+9%` padding overhead; global DP knapsack allocates across 20 active `nl = 16` formats (`1.5..6.0 bpw`) plus `VTQ` row-ring quantization for `embed_tokens` and `lm_head`. ### Verified End-to-End Benchmarks (`VTQ` vs `EXL3` `mul1` vs `GGUF` `imatrix`) Domain-neutral calibration (`wikitext-2-raw-v1` `train`, `64 × 2048` tokens), evaluated on three strictly disjoint held-out traces (`nemotron`, `multilingual`, `wikitext2`, paired bootstrap `B = 2000`) at full serialized `total_bpw`. **VTQ wins 36 / 36 cells** (3 models × 4 bitrates × 3 traces): | Model | Target | VTQ (`total_bpw`, KLD `nem`/`mul`/`wt2`, Time) | EXL3 (`total_bpw`, KLD `nem`/`mul`/`wt2`, Time) | GGUF (`total_bpw`, KLD `nem`/`mul`/`wt2`) | | :--- | :---: | :--- | :--- | :--- | | `Llama-3.1-8B-Instruct` | 2.5 bpw | `2.5072` · **0.1300 / 0.1975 / 0.1496** · **158.5 s** | `2.4925` · 0.1528 / 0.2494 / 0.1624 · 527.5 s | `2.7481` (`IQ2_S`) · 0.2408 / 0.3913 / 0.3795 | | `Llama-3.1-8B-Instruct` | 3.5 bpw | `3.5072` · **0.0267 / 0.0401 / 0.0321** · **199.3 s** | `3.4862` · 0.0346 / 0.0523 / 0.0380 · 526.5 s | `3.7706` (`IQ3_M`) · 0.0545 / 0.0711 / 0.0863 | | `Llama-3.1-8B-Instruct` | 4.5 bpw | `4.5072` · **0.0067 / 0.0102 / 0.0086** · **211.1 s** | `4.4789` · 0.0089 / 0.0138 / 0.0114 · 347.3 s | `4.6750` (`Q4_K_S`) · 0.0167 / 0.0203 / 0.0243 | | `Llama-3.1-8B-Instruct` | 6.0 bpw | `6.0072` · **0.0016 / 0.0018 / 0.0019** · **237.3 s** | `5.9681` · 0.0020 / 0.0026 / 0.0022 · 350.6 s | `6.5712` (`Q6_K`) · 0.0025 / 0.0028 / 0.0036 | | `gemma-4-26B-A4B-it` | 2.5 bpw | `2.5053` · **0.0778 / 0.1323 / 0.1494** · **431.8 s** | `2.5017` · 0.1752 / 0.2613 / 0.2970 · 1811.4 s | `3.1302` (`IQ2_S`) · 0.2552 / 0.3080 / 0.5258 | | `gemma-4-26B-A4B-it` | 3.5 bpw | `3.5053` · **0.0203 / 0.0336 / 0.0470** · **483.1 s** | `3.4906` · 0.0437 / 0.0635 / 0.0957 · 1437.4 s | `3.9290` (`IQ3_M`) · 0.0578 / 0.0742 / 0.1551 | | `gemma-4-26B-A4B-it` | 4.5 bpw | `4.5053` · **0.0079 / 0.0122 / 0.0192** · **523.9 s** | `4.4794` · 0.0187 / 0.0276 / 0.0423 · 1572.0 s | `4.9030` (`Q4_K_S`) · 0.0253 / 0.0318 / 0.0652 | | `gemma-4-26B-A4B-it` | 6.0 bpw | `6.0053` · **0.0036 / 0.0050 / 0.0107** · 1314.6 s | `5.9618` · 0.0049 / 0.0072 / 0.0131 · 1245.2 s | `7.1773` (`Q6_K`) · 0.0063 / 0.0072 / 0.0159 | | `Qwen3.6-35B-A3B` | 2.5 bpw | `2.5041` · **0.0597 / 0.0696 / 0.0753** · **791.2 s** | `2.5189` · 0.0835 / 0.0926 / 0.0951 · 4014.0 s | `2.4587` (`IQ2_S`) · 0.1741 / 0.1817 / 0.2702 | | `Qwen3.6-35B-A3B` | 3.5 bpw | `3.5041` · **0.0173 / 0.0210 / 0.0252** · **904.0 s** | `3.5113` · 0.0259 / 0.0290 / 0.0325 · 3905.6 s | `3.5638` (`IQ3_M`) · 0.0454 / 0.0463 / 0.0774 | | `Qwen3.6-35B-A3B` | 4.5 bpw | `4.5041` · **0.0068 / 0.0079 / 0.0113** · **919.5 s** | `4.5036` · 0.0083 / 0.0095 / 0.0135 · 1930.2 s | `4.5908` (`Q4_K_S`) · 0.0180 / 0.0191 / 0.0297 | | `Qwen3.6-35B-A3B` | 6.0 bpw | `6.0041` · **0.0035 / 0.0040 / 0.0069** · **1459.7 s** | `5.9918` · 0.0039 / 0.0044 / 0.0071 · 1914.2 s | `6.5813` (`Q6_K`) · 0.0046 / 0.0048 / 0.0087 | --- ## 4. Canonical Links - Website: https://velri-inference.github.io/ - Velri Engine: https://github.com/velri-inference/velri - Velri-lib: https://github.com/velri-inference/velri-lib - VTQ Research: https://github.com/velri-inference/vtq-research - VTQ Paper Benchmarks (EN): https://github.com/velri-inference/vtq-research/blob/main/docs/EN/paper-benchmarks.md - VTQ Format Spec (EN): https://github.com/velri-inference/vtq-research/blob/main/docs/EN/vtq-format.md - Velri Decode64 Report (EN): https://github.com/velri-inference/velri/blob/main/docs/performance/decode64/README.EN.md - Velri-lib Slang Kernels (EN): https://github.com/velri-inference/velri-lib/blob/main/docs/EN/kernels.md