Auto Round Kernel binary package
Project description
What is AutoRound Kernel (ARK)?
AutoRound Kernel (ARK) is a low-bit acceleration library for Intel platform, providing three categories of optimized operators for LLM inference.
| Operator Category | CPU | XPU (Battlemage) |
|---|---|---|
| Weight-Only Quantized Linear (INT4/INT8/FP8/FP4) | ✅ | ✅ |
| MoE Grouped GEMM | ❌ | ✅ |
| SageAttention (SDPA / SAGE) | ❌ | ✅ |
Validated CPU: Intel Xeon Scalable (Sapphire Rapids / Emerald Rapids), Intel Xeon 6 (Sierra Forest / Granite Rapids)
Validated GPU: Intel Arc B-Series / Arc Pro B-Series (Battlemage)
Highlights — Ecosystem Integration
ARK kernels are integrated into the following projects:
| Project | Integration | Description |
|---|---|---|
| vllm | inc_wna16_linear.py |
INCXPUARKLinearMethod — weight-only quantized linear on XPU via auto_round_kernel.qlinear.QuantLinear. The goal is to support all AutoRound-quantized models. The plan is tracked in Intel Quantization Support Roadmap |
| vllm-omni | sage_attn.py |
SageAttentionBackend — diffusion model attention on XPU via ARK.sagev1 |
| Transformers (via auto-round) | backend.py |
All models quantized by AutoRound automatically use ARK on CPU/XPU by default; no additional configuration required. 6 backends registered: auto_round_kernel[_xpu] (GPTQ no-zp), auto_round_kernel_zp[_xpu] (GPTQ +zp), auto_round_kernel_awq[_xpu] (AWQ).CPU: INT2/INT4/INT8; XPU: INT4/INT8 |
1. Linear (Weight-Only Quantized GEMM)
Low-bit weight-only linear for LLM inference. Both CPU and XPU are supported.
API
| API | Description | Platform |
|---|---|---|
QuantLinear (example ↓) |
Unified PyTorch module (GPTQ/AWQ/raw quantized checkpoint) | CPU / XPU |
QuantLinearGPTQ |
GPTQ-format checkpoint loader | CPU / XPU |
QuantLinearAWQ |
AWQ-format checkpoint loader | CPU / XPU |
QuantLinearFP8 |
FP8 weight-only linear | CPU / XPU |
woqgemm |
Low-level weight-only GEMM (packed format) | CPU / XPU |
woqgemm_s8 |
Low-level INT8-weight GEMM with scale | CPU / XPU |
_repack_quantized_weight |
Repack raw qweight/qzero/scale → ARK format | CPU / XPU |
_unpack_weight |
Unpack ARK-format weight back to full precision | CPU / XPU |
Key Features
W4A8 / W2A8 Rescale (QQQ-style) — On XPU, ARK supports ~QQQ-style compute: low-bit weights (INT2/INT4) are re-scaled to INT8 and computed via INT8 GEMM, avoiding FP16 dequantization for better throughput. Enabled automatically via environment variable
ARK_AUTO_S8; see xpu_wrapper.hpp.
Supported Data Types
CPU
| Weight dtype | Compute dtype | Scale dtype | Algorithm |
|---|---|---|---|
| INT1–INT8 | INT8[1] / BF16 / FP32 | BF16 / FP32 | sym / asym |
| FP8 (E4M3, E5M2) | BF16 / FP32 | FP32 / FP8 (E8M0) | NA |
| FP4 (E2M1) | BF16 / FP32 | BF16 / FP32 | NA |
XPU
| Weight dtype | Compute dtype | Scale dtype | Algorithm |
|---|---|---|---|
| INT4, INT8 | INT8 / FP16 | FP16 | sym |
| FP8 (E4M3, E5M2) | FP16 | FP16 / FP8 (E8M0) | NA |
[1] INT8 compute includes dynamic activation quantization; results are dequantized to floating-point.
Example
import auto_round_kernel as ark
# Prepare quantized weight: qweight [K, N] int4/int2, scale [K/G, N] fp16/fp32, zp [K/G, N] int4/int2
packw = ark.repack_quantized_weight(
qweight,
scale,
zp,
blocksize=128,
compute_type="fp16",
weight_type="int4",
scale_type="fp16",
asym=False,
)
# Run weight-only quantized GEMM: activation [M, K] → output [M, N]
output = ark.woqgemm(
activation, # [M, K] fp16/bf16
packw, # packed weight blob (INT8)
bias, # [1, N] optional bias
n, # output features
k, # input features
groupsize=128,
compute_type="fp16",
weight_type="int4",
scale_type="fp16",
asym=False,
)
# Decompose back to full precision for verification
decompressed = ark.unpack_weight(
packw,
dtype=torch.float16,
n=n,
k=k,
groupsize=128,
compute_type="fp16",
weight_type="int4",
scale_type="fp16",
asym=False,
)
See test_weightonly.py for an end-to-end example of weight repack, verification, and woqgemm execution on CPU and XPU.
2. MoE (Mixture-of-Experts Grouped GEMM)
Grouped GEMM for MoE layers where different experts process varying numbers of tokens.
API
| Function | Description | Platform | Activation Dtype | Weight Dtype |
|---|---|---|---|---|
ark.moe_gemm(...) (example ↓) |
Grouped GEMM across experts | XPU | FP16 / BF16 | FP16 / BF16 |
ark.moe_gemm(...) (WIP) |
Grouped GEMM with INT4 weight | XPU | FP16 / BF16 | INT4 🚧 |
ark.moe_gemm(...) (WIP) |
Grouped GEMM with INT2 weight | XPU | FP16 / BF16 | INT2 🚧 |
ark.moe_gemm(...) (WIP) |
Grouped GEMM with INT8 weight | XPU | FP16 / BF16 | INT8 🚧 |
🚧 INT2 / INT4 / INT8 weight support is under active development. See #PR.
Details
| Parameter | Shape | Dtype |
|---|---|---|
| activations | [total_tokens, K] |
FP16 / BF16 |
| weights | [num_experts, K, N] (row-major) |
FP16 / BF16 |
| num_tokens_per_expert | [num_experts] |
INT32 |
| scales (optional) | [num_experts, N] |
FP16 / BF16 |
| output | [total_tokens, N] |
same as activations |
Example
# FP16/BF16 MoE
output = ark.moe_gemm(activations, weights, num_tokens_per_expert)
# INT4 MoE (coming soon)
# output = ark.moe_gemm(activations, q4_weights, num_tokens_per_expert, scales=scales)
Build requirement: ARK_SYCL_TLA=ON. See test_moe.py.
3. SageAttention (XPU SDPA Acceleration)
ARK provides a full family of scaled dot-product attention kernels on XPU, ranging from vanilla FP16 SDPA to INT8-quantized SageAttention variants.
API Overview
| Function | Description | Q/K/V Input | PV Precision | Head Dim |
|---|---|---|---|---|
ark.sdpa (example ↓) |
FP16/BF16 SDPA (flash attention) | FP16 / BF16 | FP16 | 64, 96, 128, 192 |
ark.sage |
Low-level INT8 SAGE (pre-quantized Q/K) | INT8 (Q/K), FP16 (V) | FP16 | 64, 128 |
ark.sage_pvi8 |
Low-level INT8 SAGE (pre-quantized Q/K/V) | INT8 | INT8 | 64, 128 |
ark.sagev1 |
High-level FP16 → internal Q/K quant → SAGE | FP16 / BF16 | FP16 | 64, 128 |
ark.sagev1_pvi8 |
High-level FP16 → internal Q/K/V quant → SAGE PV INT8 | FP16 / BF16 | INT8 | 64, 128 |
ark.sageattn |
Dispatcher (sageattention-compatible API) | FP16 / BF16 | FP16 / INT8 | 64, 128 |
ark.sage_dynquant |
Dynamic INT8 block-wise Q/K quant → SAGE (drop-in SDPA replacement) | FP16 / BF16 | FP16 | 64, 128 |
Comparison
| Feature | sdpa |
sagev1 |
sagev1_pvi8 |
sage_dynquant |
|---|---|---|---|---|
| Q/K quantization | None | Internal INT8 | Internal INT8 | Internal INT8 |
| PV quantization | None | None | Internal INT8 | None |
| quant_block_size | N/A | 1 / ≥32 | 1 / ≥32 | 1 / ≥32 |
| Additive mask | ✅ [B,1,Sq,Skv] FP32 | ✅ | ✅ | ✅ |
| Causal mask | ✅ | ✅ | ✅ | ✅ |
| GQA | ✅ | ✅ | ✅ | ✅ |
| Tensor layout | HND / NHD | HND / NHD | HND / NHD | HND |
Drop-in SDPA Replacement
Replace torch.nn.functional.scaled_dot_product_attention globally for lm-eval:
cd /path/to/auto_round_extension/ark
PYTHONPATH=$PWD python tools/lm_eval_with_ark_sdpa.py \
--model hf \
--model_args pretrained=/path/to/model,trust_remote_code=True,dtype=bfloat16 \
--tasks hellaswag,piqa,winogrande \
--device xpu:0 --batch_size 1
The patching logic (in auto_round_kernel/torch_sdpa_patch.py) routes to ARK on XPU when constraints are met; otherwise falls back to PyTorch SDPA.
Constraints
| Constraint | sdpa |
sagev1 / sagev1_pvi8 / sage_dynquant |
|---|---|---|
| Q/K/V dtype | FP16, BF16 | FP16, BF16 |
| Head dim | 64, 96, 128, 192 | 64, 128 |
dropout_p |
must be 0.0 | must be 0.0 |
| Boolean mask | falls back to torch | falls back to torch |
| Additive mask shape | [B, 1, Sq, Skv] FP32 |
[B, 1, Sq, Skv] FP32 |
| quant_block_size | N/A | 1 (per-token) or ≥32 |
Installation
Install via pip
pip install auto-round-lib
Install from Source
pip install . --no-build-isolation
# or
python setup.py bdist_wheel; pip install dist/*
Build with MoE / SageAttention support requires ARK_SYCL_TLA=ON.
Tests
| Test | Description |
|---|---|
| test_weightonly.py | WOQ GEMM pack/unpack/run on CPU & XPU |
| test_moe.py | MoE grouped GEMM |
| test_flash_attn.py | SDPA (flash attention) prefill |
| test_sdpa.py | SDPA benchmark suite |
| test_sdpa_parity.py | SDPA vs PyTorch parity check |
| test_sage_dynquant.py | SageAttention dynamic INT8 quant benchmarks |
| test_bench_bmg.py | BMG SDPA / SageAttention benchmarking |
| test_matmul.py | Low-level matmul |
| test_packq.py | Weight packing utilities |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_round_lib-0.14.0.tar.gz.
File metadata
- Download URL: auto_round_lib-0.14.0.tar.gz
- Upload date:
- Size: 387.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4324895a2c1063b8337636ee76c23ef1a04996c0f1d9483ff486719a38596725
|
|
| MD5 |
8babf6b5f8c762f23f8c6f511237e210
|
|
| BLAKE2b-256 |
38056ccfd257718acb2eddd01739d56382ba19b1731db2748226eeb5b373b4d8
|
File details
Details for the file auto_round_lib-0.14.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: auto_round_lib-0.14.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.3 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbef60d6db8d4a62dc38298c4732c60466af9287c506b0f7339fa75e4be89f22
|
|
| MD5 |
45e4217fee6acd55697c1e44862ba72c
|
|
| BLAKE2b-256 |
bbf244fc61a8bbbfdd32a9a6d6972fd8b092dc75a64a473ac515e5580868a3d3
|
File details
Details for the file auto_round_lib-0.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: auto_round_lib-0.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c9cd50a91a26195407e3ddc1563e17618f36c3d3c07b358d4e75df3b2290cef
|
|
| MD5 |
a225ebbe18aaa4ce6c4d11c04f3825e9
|
|
| BLAKE2b-256 |
c657c932a699e28f675e326a467c3042c3d590772b662a273cbc915e1841ae8c
|
File details
Details for the file auto_round_lib-0.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: auto_round_lib-0.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed86b9cd630513da86cee1c8dc40f8d5e1abad4937c985eb26d397dfe6e34d4e
|
|
| MD5 |
97d5c78d6aa7d165482b8f85f30fa558
|
|
| BLAKE2b-256 |
fc3bdcf35af60647bb03e7161172b9ae817ea34cca41ade5b54673a84edb5375
|
File details
Details for the file auto_round_lib-0.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: auto_round_lib-0.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
611e449cd37a772ee1ce8b4d584f9e21340194f6037c92d292a1c802b84f4ae1
|
|
| MD5 |
ac15b9db6633d8d045269f5716788335
|
|
| BLAKE2b-256 |
2c19c5e6361a3dd4a88ca52b7090c02fd7df868cffd58a717ff2a873a84c96d1
|
File details
Details for the file auto_round_lib-0.14.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: auto_round_lib-0.14.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9294aaa467c6ca0b11fcf1dd531261e10e4d0fac47bdbf855097041aa5ab41be
|
|
| MD5 |
5c52d2eaeefa2ef3ed25a446bd73b8ea
|
|
| BLAKE2b-256 |
c4f21bb76245e09e8c15a13d3b338506c612138f7242acec5edc2ded8fb76995
|