Website · Format Spec (EN) / RU · Benchmarks (EN) / RU · Velri Engine · Velri-lib · llms.txt · License: GPL-3.0
VTQ (Velri Trellis Quant, .vtq) is a hardware-co-designed trellis weight quantization format for Large Language Models (LLMs), built for the Velri inference engine around self-contained 16×256 (4,096-weight) supertiles (1.5–6.0 bpw), targeting both AVX2 CPUs (vpshufb, compiled without AVX-512) and GPUs (FP32 and DP4A INT8 GEMV/GEMM) with a lower operation count per 256 weights than EXL3, 1.4–2.3× faster 4-bitrate suite quantization than EXL3 (up to 4.9× faster per bitrate), and strictly lower teacher-forced KL divergence than both EXL3 (mul1) and GGUF (imatrix) across dense, non-power-of-two MoE, and hybrid linear-attention MoE architectures.
- Specification & Kernels: EN (
docs/EN/vtq-format.md) | RU (docs/RU/vtq-format.md) — quantizersrc/vtq.py, YAQASketch-Atwo-sided GPTQ-2D solversrc/build_yaqa_sketch_a.py/src/vtq_gptq2d.py,.vtqv2 containersrc/vtq_format.py, AVX2 kernelsrc/cpu/vtq_avx2_bench.c, CUDAsm_120kernelsrc/cuda/vtq_matvec_bench.cu, optional C++ tile packer/unpacker EN / RU. - End-to-End Benchmarks & Reproduction: EN (
docs/EN/paper-benchmarks.md) | RU (docs/RU/paper-benchmarks.md) — runnersrc/run_paper_benchmarks.py, figure generatorsrc/plot_paper_benchmarks.py, raw JSONs inresults/.
-
Single-Stream
16×256Supertile (vtq_st16_*,816..3,184 B): coded trellis bitsc[16][16][2], sign planes, uncoded lattice/bit planes (Gosset[8,4,4],D4[4,3,2],D4_eq,1b/2b/4b),16-weight subgroup gain indices, and linearuint8 u_sb[16]superblock scales (× 1/128, no runtimeexp2f) live in one 64-byte-aligned contiguous struct shared identically across disk, CPU, and GPU (reaching up to1,476.9 GB/s=96.4%of peak HBM bandwidth onRTX PRO 6000 Blackwell). -
Zero-Shuffle
256-Step Tail-Biting Trellis (ν = 10,1,024states,nl = 16subsets): each16-column subgroup traverses all16rows of a supertile sequentially and wraps around (Block16-LDLQcausal Cholesky compensation + CUDA radix-4 Viterbi). On GPU, state advance + subset lookup reduces tos = ((s << 1) | bit) & 0x3FF+ one shared-memoryJoint-1024LUT load (0runtime Galois popcounts,0cross-row warp shuffles). On AVX2 CPU, state advance is a single_mm256_srli_epi16withvpshufb-only codebooks (s8_32,u8, additiveat2_16_16and bit-7-zeroedat2z_32_32withoutvpblendvb). -
YAQA
Sketch-ATwo-Sided GPTQ-2D & KL-BlendedH_inSolver (Default): a single reusable forward+backward pass (256 × 512open multi-domain calibration) builds both Kronecker factors — 5-outG_out(q, k, v, o/out, down, shared_down, moe_down) for two-sided16×16GPTQ-2D rounding (sigma_reg = 0.10) and KL-weightedH_in(0.50blend withH_stream, including layer-sharedmoe_guand per-expertmoe_down) — cutting KLD a further−2.4%..−13.6%vs 1D VTQ (22/36statistically significant wins,0significant losses) with zero changes to.vtqv2 bitstreams or Velri decode kernels (--fast-1dopts out to legacy 1D quantization). -
Kronecker Hadamard–DCT Input Rotation & Global Fisher Slice DP: orthogonal rotation $\mathcal{R}K = H{2^a} \otimes \operatorname{DCT\text{-}II}_q$ (Inner-DCT,
rot_block ∈ {-1, -2}) handles non-power-of-two widths (16-row granularity on$M$ instead of128, avoiding EXL3's+9%padding overhead on704-dim MoE layers), while inverse-CDF Row-Fisher sensitivities drive a global DP knapsack across20activenl = 16formats (1.5..6.0 bpw) plusVTQrow-ring quantization forembed_tokensandlm_head. -
.vtqv2 Container (MAGIC = b"VTQ\0",VERSION = 2): 64-byte header + 64-byte-aligned tensor/supertile payload + unlimited UTF-8 JSON footer (VtqFileremains backward-compatible with v1). Optional native C++17 tile I/O (src/vtq_native.py) speeds up FP32 weight materialization by6.2–8.3×over NumPy.
All formats (VTQ .vtq v2, EXL3 mul1, and GGUF imatrix) are quantized from the same BF16 checkpoint on the shared domain-neutral stream calibration corpus (wikitext-2-raw-v1 train, 64 × 2048 = 131,072 tokens; VTQ-SketchA adds one reusable 256 × 512 open multi-domain pass) and evaluated end-to-end (including quantized embed_tokens and lm_head, measured by full serialized text-model total_bpw = total_text_bytes * 8 / total_text_params) on three strictly disjoint held-out traces (WikiText-2 test, Nemotron agentic/reasoning dialogues, and 10-language Multilingual, paired bootstrap B = 4000).
Across all 3 models × 4 target bitrates (2.5, 3.5, 4.5, 6.0 bpw) × 3 traces (36 / 36 cells), VTQ (Sketch-A) achieves strictly lower teacher-forced KLD than both EXL3 (35 / 36 statistically significant wins: −27%..−34% on dense Llama-3.1-8B, −52%..−57% — over 2.1×–2.3× lower KLD — on gemma-4-26B-A4B-it at 2.5–4.5 bpw, and −21%..−35% on Qwen3.6-35B-A3B) and GGUF, while quantizing 1.4–2.3× faster across the full 4-bitrate suite (up to 4.9× faster per bitrate; --fast-1d 2.1–2.8× faster) than EXL3 (quantization time chart, full tables EN / RU).
| Model | Target | VTQ (Sketch-A) (total_bpw, KLD nem/mul/wt2) |
EXL3 (total_bpw, KLD nem/mul/wt2) |
GGUF (total_bpw, KLD nem/mul/wt2) |
Quant Speedup (Sketch-A vs EXL3) |
|---|---|---|---|---|---|
Llama-3.1-8B-Instruct (Dense 8B) |
2.5 bpw |
2.51 — 0.112 / 0.149 / 0.151 |
2.49 — 0.153 / 0.249 / 0.162 |
2.75 (IQ2_S) — 0.241 / 0.391 / 0.379 |
2.5× (211.3 s vs 527.5 s) |
Llama-3.1-8B-Instruct |
3.5 bpw |
3.51 — 0.024 / 0.031 / 0.033 |
3.49 — 0.035 / 0.052 / 0.038 |
3.77 (IQ3_M) — 0.054 / 0.071 / 0.086 |
2.0× (260.7 s vs 526.5 s) |
gemma-4-26B-A4B-it (128-Exp MoE, I=704) |
2.5 bpw |
2.51 — 0.072 / 0.120 / 0.159 |
2.50 — 0.175 / 0.261 / 0.297 |
3.13 (IQ2_S) — 0.255 / 0.308 / 0.526 |
3.4× (534.2 s vs 1811.4 s) |
gemma-4-26B-A4B-it |
3.5 bpw |
3.51 — 0.018 / 0.033 / 0.047 |
3.49 — 0.044 / 0.063 / 0.096 |
3.93 (IQ3_M) — 0.058 / 0.074 / 0.155 |
2.3× (623.6 s vs 1437.4 s) |
Qwen3.6-35B-A3B (256-Exp Hybrid MoE) |
2.5 bpw |
2.50 — 0.051 / 0.068 / 0.064 |
2.52 — 0.083 / 0.093 / 0.095 |
2.46 (IQ2_S) — 0.174 / 0.182 / 0.270 |
4.9× (823.8 s vs 4014.0 s) |
Qwen3.6-35B-A3B |
3.5 bpw |
3.50 — 0.015 / 0.019 / 0.023 |
3.51 — 0.026 / 0.029 / 0.033 |
3.56 (IQ3_M) — 0.045 / 0.046 / 0.077 |
4.0× (988.5 s vs 3905.6 s) |
Full 4-bitrate tables (2.5 / 3.5 / 4.5 / 6.0 bpw, VTQ-SketchA + VTQ 1D), $\Delta\text{PPL}$, and 4-bitrate suite timings (1.4×–2.3× faster end-to-end vs EXL3 incl. 1× Sketch-A prep on RTX PRO 6000 Blackwell) are in docs/EN/paper-benchmarks.md (RU).
Constraints held constant from the start: fast decoding on both GPU and AVX2 CPU (lookup tables fitting pshufb), a lower operation count per 256 weights than EXL3, quantization substantially faster than EXL3 conversion, and quality matching or beating EXL3 at equal total model bitrate. Steps 1–12 trace the earlier prototypes leading up to current VTQ (step 13).
-
GGUF
IQ2_K..IQ6_Kblock quants without changing the binary layout (.liqk v1, built on top of theIQ2_K..IQ6_K/JQ2_K..JQ6_Kformats fromllama.cppPR #30715 / #30718,GGML_TYPE_IQ2_K = 45 .. IQ6_K = 49). Adding block-sequential Cholesky error compensation (LDLQ) and analytical post-LDLQ superblock scale refitting cut teacher-forced KLD by−34..−49%while staying 100% byte-compatible with.gguffrom PR #30715/#30718. The remaining ceiling was the GGUF block header granularity itself. -
Custom
.liqk v2container. Vector grid banks in the sub-block header, half-bit formats, Hadamard-256 rotation, row-slice bit allocation via a Fisher-weighted DP knapsack, and scale polishing brought another−21..−44%KLD reduction — yet EXL3 remained ahead by+0.23..0.35equivalent bits on dense 8B models and+0.45bits on MoE. -
MoE insight: global bit allocation dominates per-expert Hessians. Ablating routed expert Hessians barely moved KLD, whereas shifting
+0.03 bpwonto attention (~3%of MoE parameters) cut end-to-end KLD by36–43%, motivating full-model slice DP over uniform per-layer rates. -
Core quantizer search -> Ungerboeck TCQ.
$E_8$ lattice coding only helped by+0.06..0.10bits near2 bpw, while wide bitshift-trellis tables broke AVX2pshufbbudgets. Ungerboeck TCQ (1coded bit/weight,10-bit trellis memory, parity-masked subset labels, joint Viterbi subgroup gain search) gained+0.23 / +0.12 / +0.09bits over.liqk v2on i.i.d. Gaussian sources at$K = 2 / 3 / 4$ and+0.15..0.25equivalent bits on real LLMs. -
CUDA Viterbi (
src/cuda/tcq_viterbi.cu). Cut 1B quantization from580 sto41 s; radix-4 transitions, in-register/shared traceback, and pre-filtered gain candidates made quantization3–5.6×faster than EXL3 on 3B. -
Closing the equal-bitrate gap with EXL3.
- Two-level scaling (per-row
fp16+ per-256superblock scale) for outlier-heavydown_proj/o_projmatrices. - Rate-matched
2–4bit subgroup gain headers, tail-biting trellis (−0.017..−0.020bits free of side information), extended8 / 16Ungerboeck subsets (shrinking the$K = 2$ gap to$R(D)$ from0.176to0.118bits), and higher relative Hessian damping (0.20–0.30). - Rejected after testing: 64-entry tables (
−20%CPU speed for noise-level KLD change), 32-weight shared headers across two output rows, headerless formats, output-side rotation, and alternating-row half-integer mixes.
- Two-level scaling (per-row
-
Eliminating the integer-rate mixing penalty. Mixing
2 bpwand3 bpwslices lost up to1.25×KLD against native2.5 bpw. Introducing fractional uncoded sub-lattices inside Viterbi (D2pairs,D4quads,Gossetoctads) reached0.25 bpwrate steps and matched/beat EXL3 on 1B and 3B. -
Deterministic Fisher sampling. Inverse-CDF token sampling with fixed seeds reduced cross-run DP allocation variance from
±5%KLD to~1%; removing Fisher weights degrades KLD by~2×. -
LTQprototype (19formats,2.04–5.29 bpw) and row rings. Frozen insrc/ltq_format.py(0mismatches across 19 tile + 17 ring formats) and validated on embeddings/PLE tables (Gemma 4 E4BPLE at4.25 bpw:1.39 GiBvs2.65 GiBint8). Early self-calibrated checks onQwen3-8B,Qwen3-30B-A3B, andQwen3.8-27Bshowed strong gains, motivating a strict domain-neutral calibration audit (WikiText-2train). -
From
LTQ/SoAto currentVTQ(.vtqv2). Replaced6-pointerSoAslices andexp2fexponents with the single-stream16×256vtq_st16_*supertile and linearuint8 u_sb[16], eliminated GPU Galois ALU and cross-row shuffles via the256-step intra-subblock trellis +Joint-1024shared-memory LUT, introducedat2_16_16/at2z_32_32vpblendvb-free AVX2 codebooks to bring fullnl = 16subsets toK = 1.5..6.0, used canonical Kronecker Hadamard–DCT rotation ($H_{2^a} \otimes \operatorname{DCT\text{-}II}_q$ ) for non-power-of-two shapes, and verified36 / 36neutral-calibration KLD wins over upstreamEXL3andGGUFacross8B–35Bmodels. -
YAQA
Sketch-ATwo-Sided GPTQ-2D + KL-BlendedH_inDefault Solver. Added single-pass Kronecker Hessian estimation (src/build_yaqa_sketch_a.py) and two-sided16×16GPTQ-2D +0.50H_inblending (src/vtq_gptq2d.py) across dense, MoE (moe_gu+ per-expertmoe_down), and hybrid architectures — cutting KLD another−2.4%..−13.6%(22/36sig wins,0sig losses vs 1D VTQ) with zero changes to.vtqv2 bitstreams or Velri decode kernels.
| Path | Contents |
|---|---|
src/vtq.py, src/vtq_format.py, docs/EN/vtq-format.md (RU) |
Current VTQ quantizer (16×256 supertiles, 20 nl = 16 formats + _FAST modes), .vtq v2 reader/writer (VtqWriter / VtqFile), and format specification |
src/quantize_vtq.py |
Standalone .vtq v2 quantizer CLI (--model, --trace, --bpw, auto-created --work-cache, --out-dir, --fast-1d, --verify) |
src/build_yaqa_sketch_a.py, src/vtq_gptq2d.py, src/test_vtq_gptq2d.py |
Default YAQA Sketch-A single-pass Hessian builder (5-out G_out + dense/MoE H_in), two-sided 16×16 GPTQ-2D engine, and CUDA round-trip tests |
src/run_paper_benchmarks.py, src/plot_paper_benchmarks.py, docs/EN/paper-benchmarks.md (RU) |
End-to-end neutral-calibration benchmark suite (VTQ vs EXL3 vs GGUF on Llama-3.1-8B, gemma-4-26B, Qwen3.6-35B) and SVG/PNG figure generator |
src/cpu/vtq_avx2_bench.c, src/cuda/vtq_matvec_bench.cu |
VTQ single-thread AVX2 (-mno-avx512f) and CUDA sm_120 FP32 / DP4A GEMV & GEMM decode kernels |
src/vtq_native.py, src/native/vtq_*tiles.cpp, docs/EN/vtq-native-io.md (RU) |
Optional C++17 tile packer/unpacker accelerating Python FP32 weight materialization by 6.2–8.3× |
src/tcq_proto.py, src/cuda/tcq_viterbi.cu |
CUDA radix-4 Viterbi & causal Block16-LDLQ trellis encoders, codebook training, Gaussian R(D) rig |
src/eval_kld.py, src/prepare_traces.py |
Teacher-forced KLD / Perplexity evaluator (B = 2000 paired bootstrap) and evaluation trace builder |
src/hybrid_quant.py, src/streaming_quant.py, src/gguf_utils.py |
Layer-streaming model loaders/evaluators and GGUF / libggml utilities (including legacy PR #30715 IQ2_K..IQ6_K support) |
src/iqk_format.py, src/liqk_v2.py, src/ltq_format.py, src/q4v.py |
Earlier research prototypes (.liqk v1 on IQ*_K, .liqk v2, LTQ, and experimental non-trellis Q4V1) |
results/, docs/figures/ |
Raw benchmark JSON artifacts (paper_*.json, kernel speed, selftests) and publication SVG/PNG charts |
Quantizing Any HuggingFace Model to .vtq v2 (src/quantize_vtq.py)
Requires a CUDA GPU (torch, transformers, safetensors, datasets, triton, and c++ for optional fast C++17 tile packing). Uses the default YAQA Sketch-A solver (5-out GPTQ-2D + 0.50 H_in) and automatically creates/reuses --work-cache (<out-dir>/.vtq_cache/<model> if omitted):
# 1. Quantize directly from HuggingFace Hub (or a local HF folder) at multiple bitrates with auto work cache:
python -m src.quantize_vtq \
--model Qwen/Qwen3.6-35B-A3B \
--bpw 2.5 3.5 4.5 \
--out-dir ./vtq_out \
--verify
# 2. Quantize fully offline with your own calibration trace + explicit reusable work cache:
python -m src.quantize_vtq \
--model /models/gemma-4-26B-A4B-it \
--trace ./calibration_trace.jsonl \
--bpw 2.5 3.5 4.5 \
--work-cache ./cache/gemma4 \
--out-dir ./vtq_out \
--skip-existing \
--verify
# 3. Split workflow: pre-build only the work cache first, then export bitrates (or use --fast-1d):
python -m src.quantize_vtq --model /models/Llama-3.1-8B-Instruct --trace wikitext2 --work-cache ./cache/llama8b --cache-only
python -m src.quantize_vtq --model /models/Llama-3.1-8B-Instruct --trace wikitext2 --bpw 3.5 --work-cache ./cache/llama8b --out-dir ./vtq_out --verify
python -m src.quantize_vtq --model /models/Llama-3.1-8B-Instruct --trace wikitext2 --bpw 3.5 --work-cache ./cache/llama8b --out-dir ./vtq_out --fast-1dSupported --trace inputs:
auto/multidomain(default): streams open English + 8-language + code calibration (FineWeb-Edu/FineWeb-2/python-edu);wikitext2:Salesforce/wikitext(wikitext-2-raw-v1train);- Local files:
.jsonl/.json(chat{"messages": [...]}, raw{"text": "..."}, or pre-tokenized{"sequences": [{"token_ids": [...]}]}), plain.txt/.raw,.safetensors(input_ids), or.pt.
Example calibration_trace.jsonl:
{"messages": [{"role": "user", "content": "Explain tail-biting trellis quantization."}, {"role": "assistant", "content": "..."}]}
{"text": "Domain-specific text or source code sample..."}Generated files:
--work-cache:cal_stream_*.safetensors,fisher.pt,vtq_profile.pt,sketch_a_hess/,libvtq_io.so, andcache_manifest.json(auto-invalidated if--traceor model changes; shared across all--bpwtargets).--out-dir:<model>-VTQ-<bpw>bpw.vtq(self-contained.vtqv2 file withconfig,tokenizer,chat_template, andquantization.formatsin the JSON footer) plus<model>-vtq-manifest.json.
Inspecting / decoding a .vtq v2 file in Python (VtqFile):
from pathlib import Path
from src.vtq_format import VtqFile
with VtqFile(Path("./vtq_out/Llama-3.1-8B-Instruct-VTQ-3.50bpw.vtq")) as vf:
print("version:", vf.version, "| solver:", vf.header["quantization"].get("quant_solver"))
print("tensors:", len(vf.header["tensors"]), "| formats:", len(vf.formats))
W = vf.decode_matrix("model.layers.0.self_attn.q_proj", device="cpu")
print("q_proj shape:", tuple(W.shape), W.dtype)main keeps data/ untracked; the complete turnkey reproduction setup with tracked held-out evaluation traces (data/wikitext2_test.raw and data/{,gemma4/,qwen35/}{nemotron,multilingual}_trace.json), SHA-256 checksums, and step-by-step instructions lives on the paper-repro branch (git checkout paper-repro).
python -m src.vtq_format # .vtq v2 container & 16x256 supertile round-trip self-test
python -m src.plot_paper_benchmarks # regenerate all SVG/PNG figures in docs/figures/ from results/paper_*.json| Repository | Role |
|---|---|
| velri-inference/velri | Native C23/C++23 + Khronos Slang AOT LLM inference engine (CPU & Vulkan 1.3) |
| velri-inference/velri-lib | Standalone C23 tensor, execution graph, and Slang AOT kernel library (VelriLib::velri) |
| velri-inference/vtq-research (this repo) | VTQ (Velri Trellis Quant, .vtq v2) format specification, quantizer, kernels, and benchmarks |
| velri-inference.github.io | Unified ecosystem website and full LLM reference (llms-full.txt) |
-
How does VTQ differ from EXL3 and GGUF? Unlike GGUF block quantizers, VTQ uses a 256-step tail-biting Ungerboeck trellis (
1,024states,nl = 16subsets) with global Row-Fisher DP bit allocation across1.5–6.0 bpw. Compared to EXL3, VTQ uses a single-stream16×256supertile with16-row Kronecker Hadamard–DCT ($H_{2^a} \otimes \operatorname{DCT\text{-}II}_q$ ) granularity (avoiding+9%padding overhead on non-power-of-two MoE dimensions such as704), runs zero-shuffle lookup decoding on both GPU and AVX2 CPU, quantizes1.4–2.3×faster (up to4.9×per bitrate), and achieves strictly lower KLD across36/36held-out cells. -
Does VTQ require AVX-512 on CPU? No. VTQ CPU codebooks (
s8_32,u8,at2_16_16,at2z_32_32) are co-designed specifically for AVX2vpshufb(-mno-avx512f) withoutvpblendvbor runtime Galois popcounts. -
What happened to LTQ and
.liqk?LTQand.liqkwere earlier research milestones documented in steps 1–9 above and preserved insrc/for reproducibility. VTQ (.vtqv2) is the current, actively developed format for Velri.
Licensed under the GNU General Public License v3.0. Machine-readable citation metadata lives in CITATION.cff:
@software{vemloir2026vtq,
author = {Vemloir},
title = {{VTQ}: Velri Trellis Quant --- Hardware-Co-Designed 16x256 Trellis Weight Quantization for {LLMs}},
year = {2026},
version = {2.0.0},
license = {GPL-3.0},
url = {https://github.com/velri-inference/vtq-research}
}