Inference comparison
| Method | Precision | vs. BF16 |
|---|
Select a method to explore the comparison.
AI Team · Quantization
from the authors ofKVarN
MACaQ /məˈkɑːk/: Model Agnostic Calibrated Quantization. So easy to use, even a macaque could get the hang of it.
MACaQ calibrates 4-bit weights and activations one linear layer at a time. Channel balancing, small Hadamard transforms, and weight refinement improve low-precision representations while keeping every change inside the layer. The same recipe applies across architectures and modalities: text, images, video, audio, and 3D reconstruction.
Measured speed, fidelity, and complete model size.
| Method | Precision | vs. BF16 |
|---|
Select a method to explore the comparison.
relative to the original FP16 model
FP16 = 1×
PromptA spacious modern museum atrium with a curved white staircase, pale travertine walls and one small red sculptural chair on the floor, soft daylight from a circular skylight, precise architectural lines and realistic material textures, wide architectural photograph.
PromptWrite a Python function that finds the closest vectors using cosine similarity.
TextA quiet morning by the lake. The water is still, the air is clear, and a new story is about to begin.

InputTwo views of a university courtyard in autumn.
# Create an environment for this backend
python3.12 -m venv .venv-vllm
.venv-vllm/bin/pip install -r requirements/vllm-qwen35.txt
.venv-vllm/bin/pip install -r requirements/build.txt
.venv-vllm/bin/pip install --no-build-isolation --no-deps -e .# Supply representative UTF-8 calibration text
.venv-vllm/bin/python vllm/cli.py quantize \
--model Qwen/Qwen3.8-27B \
--calibration data/calibration.txt \
--output models/qwen38-27b-macaq --gpu 0# Serve the saved checkpoint; no recalibration
.venv-vllm/bin/python vllm/cli.py serve \
--model models/qwen38-27b-macaq --gpu 0
# HTTP chat API
# http://127.0.0.1:8000/v1/chat/completions# Create a separate environment and GPU runtime
python3.12 -m venv .venv-llamacpp
.venv-llamacpp/bin/pip install -r requirements/llamacpp-qwen35.txt
MACAQ_TOOLKIT=/usr/local/cuda
cmake -S llamacpp/llama.cpp -B llamacpp/llama.cpp/build \
-DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_COMPILER="$MACAQ_TOOLKIT/bin/nvcc" \
-DCUDAToolkit_ROOT="$MACAQ_TOOLKIT" -DCMAKE_CUDA_ARCHITECTURES=native
cmake --build llamacpp/llama.cpp/build -j 4 --target \
llama-imatrix llama-quantize llama-completion llama-perplexity llama-bench# First download the original HF checkpoint locally
.venv-llamacpp/bin/python llamacpp/llama.cpp/convert_hf_to_gguf.py \
models/Qwen3.8-27B --outtype f16 --outfile models/original-f16.gguf
.venv-llamacpp/bin/python llamacpp/macaq.py quantize \
--model models/original-f16.gguf --hf models/Qwen3.8-27B \
--calibration data/calibration.txt --format IQ4_XS --had-block 64 \
--device cuda --gpu 0 --gpu-layers 99 \
--output models/qwen38-27b-macaq.gguf --work-dir work/qwen38-27b# Compile preprocessing once for the inference device
.venv-llamacpp/bin/python llamacpp/compile_kernels.py \
--output work/kernels --gpu 0
.venv-llamacpp/bin/python llamacpp/macaq.py run \
--model models/qwen38-27b-macaq.gguf --kernel-dir work/kernels \
--gpu 0 --gpu-layers 99 --prompt "Explain quantization simply."Run from the MACaQ repository root. Use representative calibration text and keep evaluation text separate. Use Linux, Python 3.12 and a separate environment for each backend. Set MACAQ_TOOLKIT to your installed CUDA toolkit. Choose fresh output and work paths.
One local recipe. Across architectures and modalities.
Text, images, video, audio and 3D models share a building block: the linear layer.
MACaQ keeps its transforms and quantization decisions inside that layer. Nothing needs to be absorbed into a neighboring normalization, projection or residual branch.
The layer’s input and output stay in the original basis.
The same local recipe can be reused across the model.
Calibration and refinement happen offline. At inference, input scaling and a small Hadamard transform share the fused MXFP4 path.
vs. MXFP4 without scaling and rotation
Qwen3-32B · vLLM · batch 1 · context 512 · Paper, Figure 3BEYOND THE DEMO
Explore the layer-local design, Flip-Refinement and the experiments behind MACaQ. The full method, analysis and results are in the paper.
Read the paper
MACaQ · 16 pagesOpen paper