QUANTBENCH
LLM Sub-Byte Quantization Studio
Zero-Cold-Start Client-Side CAD

Empirical Quantization Pareto Frontier & Sub-Byte Bit-Packing

Explore quality vs. compression Pareto curves, simulate BitNet 1.58b ternary and INT4 nibble bitshift registers, assess Transformer layer sensitivity, and inspect exact reconstruction SQNR in real time.

12
Configurations
7.50x
Max Compression
+0.009
INT8 ΔPPL
Interactive Pareto Frontier Scatter Explorer
Mapping Bit-Width & Compression Ratio against Signal-to-Quantization-Noise Ratio (SQNR) and Perplexity
Y-Axis: X-Axis:
Benchmark Configurations Table
Measured on deterministic Transformer evaluation block across 512 calibration tokens
Configuration ⇕ Bits / Wt ⇕ Ratio ⇕ VRAM (MB) ⇕ SQNR (dB) ⇕ Δ PPL ⇕ Hardware Acceleration Primary Use Case
Sub-Byte Bit-Packing Runtime Simulator
Zero-overhead vectorized bitshift packing into standard uint8 byte containers

1. Input Ternary Weights ((-1, 0, 1))

Select 4 ternary values. Each value is biased by +1 into u = v + 1 ∈ {0, 1, 2} and shifted into 2-bit slices of a single uint8 byte container.

2. Packed 8-Bit Register Layout

uint8 Byte = (u0 & 0x03) | ((u1 & 0x03) << 2) | ((u2 & 0x03) << 4) | ((u3 & 0x03) << 6)
0
Decimal uint8
0x00
Hexadecimal
7.50x
Memory Reduction
✓ Unpack Verification:
💡 Radix-3 Information Density: While 2-bit packing stores 4 values/byte, Radix-3 base-3 packing (3^5 = 243 < 256) fits 5 ternary values per byte, hitting the Shannon theoretical limit of log2(3) ≈ 1.585 bits/weight.
Transformer Layer Sensitivity Analysis
Layer-by-layer Signal-to-Quantization-Noise Ratio (SQNR) retention & Outlier Resilience
Scheme:

💡 Architectural Insights

  • Attention Q & K Projections: Most vulnerable to quantization. Phase drift in query/key dot-products leads to exponential attention softmax dispersion.
  • MLP Gate & Up Projections: Most resilient. Non-linear activations (SwiGLU/GeLU) naturally dampen small magnitude quantization errors.
  • MLP Down Projection: Acts as an information bottleneck compressing representations back into d_model, requiring higher precision or finer group sizes.
Mixed Precision Strategy:
Keep Q, K, and Down-proj in INT8 or INT4 AWQ (G=32), while compressing Gate, Up, and Value into aggressive 2-bit or INT4 (G=128) to achieve optimal throughput with 0 PPL degradation.
Live Quantizer & SQNR Lab
Test real weight distributions, observe scale factors, discrete integer bins, and exact dB SNR
Preset Tensor:
0.0000
Scale (S)
0
Zero-Point (Z)
0.0 dB
Exact SQNR

Reconstructed Tensor vs Original Comparison

Index Original (X) Quantized Discrete (Q) Dequantized (X̂) Error (X - X̂)
Python SDK & CLI Usage
Reproduce every evaluation result locally in 2 lines of Python
Installation:
pip install quantbench
Sub-Byte Bit-Packing Python Example:
import torch from quantbench.quant.packing.ternary_pack import pack_ternary, unpack_ternary from quantbench.quant.packing.int4_pack import pack_nibbles, unpack_nibbles from quantbench.quant.packing.sparse_pack import prune_and_compress_2_4 # 1. BitNet 1.58b Ternary Packing (7.5x compression) weights = torch.tensor([-1, 0, 1, -1, 0, 1, 1, -1], dtype=torch.int8) packed_bytes, orig_len = pack_ternary(weights, mode="2bit") unpacked = unpack_ternary(packed_bytes, original_length=orig_len, mode="2bit") assert torch.equal(weights, unpacked) # 2. INT4 Nibble Packing byte_val = pack_nibbles(low=-3, high=5) low, high = unpack_nibbles(byte_val, signed=True) print(f"Packed byte: 0x{byte_val:02X}, Unpacked: [{low}, {high}]") # 3. Ampere 2:4 Structured Sparsity dense_block = torch.tensor([[0.45, -0.12, 0.88, 0.05]]) compressed, indices = prune_and_compress_2_4(dense_block) print(f"Retained non-zeros: {compressed}")
CLI Pareto Frontier Evaluation:
# Run full automated Pareto frontier sweep on local model quantbench eval --model meta-llama/Llama-3.2-1B --schemes int8,int4_awq,fp8_e4m3,bitnet --device cuda