AI/TLDR

Intel Neural Compressor

Compress PyTorch, TensorFlow, and JAX models with quantization, pruning, and distillation

Overview

Intel Neural Compressor is an open-source Python library that applies model compression techniques to deep learning models. It supports popular methods such as static and dynamic quantization, SmoothQuant, weight-only quantization, quantization-aware training, and mixed precision, and works across PyTorch, TensorFlow, and JAX.

It is aimed at engineers who want to shrink a trained model and lower its precision so it runs faster and uses less memory at inference time. The library includes advanced quantization paths for large language models and vision-language models such as LLaMA, Qwen, and DeepSeek, through its integration with AutoRound.

Within the quantization and compression space, the toolkit leans toward Intel hardware. It has extensive testing on Intel Gaudi AI Accelerators, Core Ultra, and Xeon Scalable processors, plus Intel data center GPUs, with more limited testing on AMD CPU, ARM CPU, and NVIDIA GPU.

What it does

  • Multiple quantization methods, including static, dynamic, SmoothQuant, weight-only, quantization-aware training, and mixed precision
  • Works across PyTorch, TensorFlow, and JAX through framework-specific install packages
  • LLM and VLM quantization for models like LLaMA, Qwen, and DeepSeek via AutoRound integration
  • Low-precision data types including FP8, NVFP4, and MXFP8 / MXFP4 (several marked experimental)
  • Loads pre-quantized Hugging Face models, for example auto-gptq weight-only LLMs, and caches a converted format for later loads
  • Tested on Intel Gaudi, Core Ultra, and Xeon hardware, with limited testing on AMD CPU, ARM CPU, and NVIDIA GPU

Getting started

Install the package that matches your framework backend, then run a short quantization program. The example below performs FP8 quantization and is supported on the Intel Gaudi2 AI Accelerator.

Install from PyPI

Pick the install command for your framework. PyTorch and TensorFlow are available on PyPI; the JAX dependency is built from source.

bashbash
# Framework extension API + PyTorch dependency
pip install neural-compressor-pt
# Framework extension API + TensorFlow dependency
pip install neural-compressor-tf
# Framework extension API + JAX dependency, available since v3.8
# JAX only support build from source installation method
INC_JAX_ONLY=1 pip install .

Install the framework backend

Install the PyTorch build that matches your hardware (CPU, Intel GPU, or HPU). See the project's installation guide for the right intel_extension_for_pytorch or torch version.

Run FP8 quantization

Prepare the model with an FP8Config, run a calibration pass, then convert. This example targets Intel Gaudi2 (hpu).

pythonpython
from neural_compressor.torch.quantization import (
    FP8Config,
    prepare,
    convert,
)

import torch
import torchvision.models as models

model = models.resnet18()
qconfig = FP8Config(fp8_config="E4M3")
model = prepare(model, qconfig)

# Customer defined calibration. Below is a dummy calibration
model(torch.randn(1, 3, 224, 224).to("hpu"))

model = convert(model)

output = model(torch.randn(1, 3, 224, 224).to("hpu")).to("cpu")
print(output.shape)

Load a weight-only LLM

Load a pre-quantized weight-only model from Hugging Face. The first load converts the format and caches it locally, so it can take a while.

pythonpython
from neural_compressor.torch.quantization import load

model_name = "TheBloke/Llama-2-7B-GPTQ"
model = load(
    model_name_or_path=model_name,
    format="huggingface",
    device="hpu",
    torch_dtype=torch.bfloat16,
)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Quantize a trained PyTorch or TensorFlow model to lower precision to cut its memory footprint and speed up inference
  • Apply weight-only or FP8 quantization to large language models like LLaMA, Qwen, or DeepSeek before serving them
  • Run quantization-aware training or SmoothQuant to keep accuracy while reducing precision
  • Deploy compressed models on Intel hardware such as Gaudi accelerators or Xeon CPUs

How Intel Neural Compressor compares

Intel Neural Compressor alongside other open-source quantization & compression tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
BitNet★ 39.6kMicrosoft's inference framework for running extremely low-bit (1.58-bit) quantized LLMs efficiently on CPUs.
bitsandbytes★ 8.3kA library that adds 8-bit and 4-bit quantization to PyTorch models, widely used for loading and fine-tuning LLMs in low memory.
AWQ★ 3.6kThe reference implementation of Activation-aware Weight Quantization for compressing LLMs to 4-bit with little accuracy loss.
LLM Compressor★ 3.5kA library for applying quantization and sparsity methods to LLMs to produce compressed models that run faster in vLLM.
torchao★ 2.9kPyTorch's native library for quantizing and applying low-bit data types to models for faster training and inference.
Intel Neural Compressor★ 2.7kCompress PyTorch, TensorFlow, and JAX models with quantization, pruning, and distillation
GPTQModel★ 1.2kA model quantization toolkit, successor to AutoGPTQ, that compresses LLMs with GPTQ, AWQ, and other methods across many chips.
Optimum Quanto★ 1kA Hugging Face PyTorch toolkit for quantizing model weights and activations to formats like int8, int4, and float8.