NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

QIGen: Generating Efficient Kernels for Quantized Inference on Large Language Models

Tommaso Pegolotti, Elias Frantar, Dan Alistarh, Markus PüschelarXiv 2023 · DOI

Introduction

Large Language Models (LLMs) like LLaMA have revolutionized natural language processing but remain notoriously difficult to deploy on consumer-grade hardware. Their massive memory requirements often necessitate high-end GPUs, creating a significant barrier to entry. While "quantization"—the process of reducing weight precision from 32-bit floats to low-bit integers (e.g., 2, 3, or 4-bit)—drastically lowers the memory footprint, it introduces a new bottleneck: system support.

Existing solutions typically rely on manually written "kernels" (low-level code for matrix operations). However, hand-writing these kernels is a grueling, error-prone process that must be repeated for every new hardware architecture (Intel vs. ARM) and every new quantization format (4-bit vs. 3-bit). This "productivity wall" limits the speed at which researchers can experiment with new compression techniques. QIGen addresses this by providing an automatic code generation framework that tailors kernels specifically to a target CPU's cache and register layout.

The QIGen Framework

QIGen is an automatic generator that optimizes the Matrix-Vector multiplication (GEMV) operations central to LLM inference. Unlike the Matrix-Matrix (GEMM) operations used in training, inference is strictly memory-bound; performance is limited by how fast data moves from memory to the CPU rather than raw compute power.

Quantization process showing the transformation of a weight matrix W into quantized weights Wq, zero points z, and scales s.

To maximize throughput, QIGen employs a multi-step optimization strategy:

  • Performance Modeling: Rather than relying on trial and error, QIGen uses mathematical models to determine the ideal "blocking" strategy. It calculates how to partition data into "Mini-GEMV" blocks for the L1 cache and "Micro-GEMV" blocks for CPU registers, minimizing memory stalls.
  • Z-Curve Ordering: To improve spatial locality, weight matrices are stored using a Z-curve order. This reduces cache misses and Translation Lookaside Buffer (TLB) misses by keeping related data physically closer in memory.
  • SIMD Utilization: The generator leverages AVX2 intrinsics, allowing the CPU to process multiple data points in a single instruction cycle.
  • Flexible Bit-Widths and Grouping: QIGen supports various quantization granularities (group sizes) and bit-widths. It automatically generates the "unpacking" logic required to decompress integers back into usable numerical values during computation.

Experimental Results

The authors evaluated QIGen using the LLaMA family of models (7B, 13B, and 30B parameters) on an AMD EPYC 7742 64-core processor. Accuracy was measured via perplexity on the Wikitext2 dataset.

Throughput and Efficiency

QIGen demonstrated significant performance gains over popular manual implementations like llama.cpp. On the LLaMA-13B model, QIGen achieved up to a 2.6x speedup when using full-column quantization. Even with more complex grouped quantization (e.g., group sizes of 64 or 128), it maintained a roughly 2x performance lead.

Performance comparison (token/s) between llama.cpp and QIGen across different LLaMA model sizes and quantization group sizes.

Memory efficiency was equally impressive. The 3-bit kernels reduced memory usage by approximately 4x compared to standard 32-bit floating-point models. For instance, the LLaMA-30B model's memory footprint dropped from approximately 125 GB to just 31 GB, making it far more accessible for standard server hardware.

Accuracy

Using the GPTQ method, the 4-bit generated kernels achieved "near-lossless" accuracy compared to the uncompressed baseline. While 3-bit versions showed a slight increase in perplexity, they remained highly competitive and usable for most downstream tasks. The ability to automatically generate kernels for any group size allows researchers to find the optimal "sweet spot" between inference speed and model precision without manual code intervention.

Limitations and Future Work

While QIGen shows immense promise, the authors noted a performance anomaly in the LLaMA-30B model when using very small group sizes (16 and 32), where QIGen slightly lagged behind llama.cpp. This suggests that the underlying performance model requires further refinement for extremely large models with high-granularity quantization.

Future work will focus on expanding hardware support beyond AVX2 to include AVX512 and Intel’s Advanced Matrix Extensions (AMX). Additionally, the authors aim to integrate these efficient kernels into training and fine-tuning loops to accelerate the entire lifecycle of low-bit LLMs.

Summary updated

BibTeX
@misc{pegolotti2023qigen,
  author = {Tommaso Pegolotti and Elias Frantar and Dan Alistarh and Markus Püschel},
  title = {{QIGen: Generating Efficient Kernels for Quantized Inference on Large Language Models}},
  year = {2023},
  eprint = {2307.03738},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.03738},
}
Figure