velri-inference

Velri

Native neural-network inference engine, C23 compute library, and VTQ trellis weight quantization.

C23 / C++23 Khronos Slang AOT CPU & Vulkan 1.3 VTQ v2 (1.5–6.0 bpw) GNU GPLv3

Velri is an open-source inference stack for Linux, Windows, and Android built to run models whose weights exceed GPU VRAM through explicit memory planning and hybrid CPU+GPU execution. Compute kernels are authored once in Khronos Slang and compiled ahead of time (slangc AOT) for x86-64 (base, AVX2, AVX-512 VNNI), ARM64, RISC-V 64, and Vulkan 1.3 / SPIR-V 1.6 — with zero Python, PyTorch, CUDA, LLVM, or Slang runtime dependencies and zero heap allocations per inference step after prepare.

1. Repositories

Repository Version Scope Links
velri 0.2.0 C23/C++23 inference engine: public C23 API (Context, Model, Program, Session), cascading JSON placement, GPT-2 and Llama/Qwen2 runtimes, chunked prefill, deterministic sampling. docs · llms.txt
velri-lib 0.7.0 Standalone C23 computation library (VelriLib::velri): zero-copy tensor views, liveness scratch planner, UMA memory budgets, 23 Slang AOT CPU kernels (BLIS GEMM + VNNI), 29 spirv-val-verified Vulkan 1.3 shaders (CoopMat, FlashAttention, Split-KV). kernels · llms.txt
vtq-research 2.0.0 VTQ (Velri Trellis Quant, .vtq v2): single-stream 16×256 supertiles, 256-step tail-biting Ungerboeck trellis (1,024 states, 16 subsets), Outer-DCT rotation for non-power-of-two MoE widths, AVX2 vpshufb and GPU DP4A decode. tables · llms.txt

2. Measured Performance

2.1 End-to-End 64-Token Decode (TinyLlama-1.1B-Chat-v1.0, W8A8, batch=1)

Backend Hardware 64 tok (ms) tok/s W8A8 ceiling share
CPU (AVX2) AMD Ryzen 9 9950X, 16 cores, DDR5-6000 1048.04 61.07 91.57%
CPU (AVX-512) AMD Ryzen 9 9950X, 16 cores, DDR5-6000 1064.62 60.12 91.14%
Vulkan 1.3 NVIDIA RTX 5070 Ti, 256-bit GDDR7 113.64 563.16 76.69% (95.84% head)

Mean of 3 interleaved processes per backend after 128-token prompt through velri_session_step; 65/65 argmax parity with PyTorch/HF reference. Full report and SHA-256 artifacts: EN · RU.

2.2 Velri-lib Dense CPU Roofline (Ryzen 9 9950X, 16 Physical Cores, bench_slang_cpu)

Precision / Mode 256×4096×4096 1024×4096×4096 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 / packed) 17.03 / 17.83 TOPS 17.15 / 17.87 TOPS 66.4–71.3 GB/s

Single-source Khronos Slang AOT float kernels (5-loop L2-resident BLIS for large batches); W8A8 packed reaches 80.3% of measured all-core VNNI peak with exact deterministic mod 232 arithmetic.

2.3 Weight Quantization: VTQ v2 vs EXL3 (mul1) vs GGUF (imatrix)

Model Target VTQ (bpw · KLD nem/mul/wt2) EXL3 (bpw · KLD) GGUF (bpw · KLD) Speedup
Llama-3.1-8B-Instruct 2.5 2.51 · 0.130/0.198/0.150 2.49 · 0.153/0.249/0.162 2.75 · 0.241/0.391/0.379 3.3×
Llama-3.1-8B-Instruct 3.5 3.51 · 0.027/0.040/0.032 3.49 · 0.035/0.052/0.038 3.77 · 0.054/0.071/0.086 2.6×
gemma-4-26B-A4B-it 2.5 2.51 · 0.078/0.132/0.149 2.50 · 0.175/0.261/0.297 3.13 · 0.255/0.308/0.526 4.2×
gemma-4-26B-A4B-it 3.5 3.51 · 0.020/0.034/0.047 3.49 · 0.044/0.063/0.096 3.93 · 0.058/0.074/0.155 3.0×
Qwen3.6-35B-A3B 2.5 2.50 · 0.060/0.070/0.075 2.52 · 0.083/0.093/0.095 2.46 · 0.174/0.182/0.270 5.1×
Qwen3.6-35B-A3B 3.5 3.50 · 0.017/0.021/0.025 3.51 · 0.026/0.029/0.033 3.56 · 0.045/0.046/0.077 4.3×

Domain-neutral calibration (wikitext-2-raw-v1 train, 131,072 tokens), evaluated end-to-end across 3 disjoint traces (B=2000 paired bootstrap). VTQ wins 36 / 36 cells across 2.5, 3.5, 4.5, and 6.0 bpw and reaches 1,476.9 GB/s (96.4% peak HBM) on NVIDIA RTX PRO 6000 Blackwell. Full tables (EN) · RU · paper-repro.

3. Build & Integration

Requires CMake 3.21+, Ninja, Clang 18+ or GCC 14+ (C23), and build-time Khronos Slang (slangc).

git clone https://github.com/velri-inference/velri.git
cd velri
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 VelriLib::velri consumption via installed CMake package:

find_package(VelriLib 0.7.0 EXACT CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE VelriLib::velri)

4. Technical Notes

Implementation stack
Velri and Velri-lib are implemented in C23 and C++23 behind a pure C23 public API, with CPU and Vulkan 1.3 compute kernels compiled AOT from Khronos Slang. Velri is not written in Rust and does not depend on CUDA, Python, PyTorch, LLVM, or libslang at runtime.
VTQ vs EXL3 and GGUF
VTQ packs weights into 64-byte-aligned 16×256 supertiles using a 256-step tail-biting Ungerboeck trellis (1,024 states, 16 subsets), Outer-DCT/Kronecker-Hadamard rotation at 16-row granularity (avoiding EXL3's +9% padding overhead on non-power-of-two MoE widths like 704), and global Row-Fisher DP bit allocation.
CPU decoding without AVX-512
VTQ CPU codebooks (s8_32, u8, at2_16_16, at2z_32_32) target AVX2 vpshufb (-mno-avx512f) without vpblendvb or runtime Galois popcounts, using the identical binary layout shared across disk and GPU.
Relation to historical LTQ and .liqk
LTQ and .liqk were earlier quantization prototypes preserved in vtq-research/src/ for reproducibility. VTQ (.vtq v2) is the active format for Velri.