Skip to main content

Auto Round Kernel binary package

Project description

What is AutoRound Kernel?

AutoRound Kernel (ARK) is a low-bit acceleration library for Intel platform, providing high-performance kernels for LLM inference including weight-only quantization, flash attention (with SageAttention v1 support), and Mixture-of-Experts (MOE) computation.

The kernels are optimized for the following CPUs:

  • Intel Xeon Scalable processor (formerly Sapphire Rapids, and Emerald Rapids)
  • Intel Xeon 6 processors (formerly Sierra Forest and Granite Rapids)

The kernels are optimized for the following GPUs:

  • Intel Arc B-Series Graphics and Intel Arc Pro B-Series Graphics (formerly Battlemage)

Key Features

AutoRound Kernel provides the following computational capabilities for LLM inference:

Weight-Only Quantization (WOQ) Linear

Weight dtype Compute dtype Scale dtype Algorithm[1]
INT8 INT8[2] / BF16 / FP32 BF16 / FP32 sym / asym
INT4 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT3 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT2 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT5 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT6 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT7 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
INT1 INT8 / BF16 / FP32 BF16 / FP32 sym / asym
FP8 (E4M3, E5M2) BF16 / FP32 FP32 / FP8 (E8M0) NA
FP4 (E2M1) BF16 / FP32 BF16 / FP32 NA

XPU Weight-Only Quantization

Weight dtype Compute dtype Scale dtype Algorithm
INT8 INT8 / FP16 FP16 sym
INT4 INT8 / FP16 FP16 sym
INT2 INT8 / FP16 FP16 sym
FP8 (E4M3, E5M2) FP16 FP16 / FP8 (E8M0) NA

[1]: Quantization algorithms for integer types: symmetric or asymmetric.
[2]: Includes dynamic activation quantization; results are dequantized to floating-point formats.

Flash Attention (XPU only)

ARK provides multiple attention backends for prefill and decode, with SageAttention v1 support — offering INT8-quantized attention variants for higher throughput on Intel Arc GPUs. (SageAttention v2/v3 are under development.)

Backend Description Q/K/V dtype Head dim Features
sdpa Standard flash attention (FP16/BF16) FP16 / BF16 64, 96, 128, 192 Causal mask, additive mask, GQA
sagev1 SageAttention v1 with INT8 Q/K quantization FP16 / BF16 64, 128 Block-wise INT8 QK, PV in half
sagev1_pvi8 SageAttention v1 with INT8 Q/K/V quantization FP16 / BF16 64, 128 Block-wise INT8 QK + INT8 PV
sage Low-level SageAttention with pre-quantized INT8 Q/K INT8 (Q/K), FP16 (V) 64, 128 External Q/K scales
sage_pvi8 Low-level SageAttention with pre-quantized INT8 Q/K/V INT8 (Q/K/V) 64, 128 External Q/K/V scales
sage_dynquant SageAttention with fused dynamic INT8 quantization FP16 64, 128 Auto-quantizes Q/K internally

All attention backends support both HND ([B, H, N, D]) and NHD ([B, N, H, D]) tensor layouts, as well as non-contiguous (sliced) input tensors.

MOE GEMM (XPU only)

Grouped GEMM for Mixture-of-Experts layers, supporting FP16/BF16 with variable token counts per expert.

Installation

1. Install via pip

pip install auto-round-lib

2. Install from Source

Requires a sourced oneAPI environment (2025.3+ recommended for SYCL TLA support).

# Source oneAPI environment
source /opt/intel/oneapi/setvars.sh

# Build and install
pip install . --no-build-isolation
# or
python setup.py bdist_wheel; pip install dist/*

The build system automatically detects the oneAPI version. SYCL TLA (Tensor Linear Algebra) kernels are enabled when oneAPI >= 2025.3.

Validated Hardware Environment

CPU based on Intel 64 architecture or compatible processors:

  • Intel Xeon Scalable processor (Granite Rapids)

GPU built on Intel's Xe architecture:

  • Intel Arc B-Series Graphics (Battlemage)

API Reference

QuantLinear (Weight-Only Quantization)

ARK exposes a unified weight-only linear interface through QuantLinear, QuantLinearGPTQ, QuantLinearAWQ, and QuantLinearFP8. Please refer to the QLinear for more integration details.

The expected lifecycle is: create the module, load quantized tensors from the checkpoint, call post_init() once to repack weights into the ARK-friendly layout, and then call forward() during inference.

Minimal usage:

from auto_round_kernel.qlinear import QuantLinear

qlinear = QuantLinear(
    bits=4,
    group_size=128,
    sym=True,
    in_features=in_features,
    out_features=out_features,
    bias=bias is not None,
    weight_dtype=weight_dtype,
)
# Load qweight, qzeros, scales, and bias from checkpoint.
qlinear.post_init()

# Run inference
y = qlinear(x)

Attention APIs

ark.sdpa — Standard Flash Attention

import auto_round_kernel as ark

output = ark.sdpa(
    query,
    key,
    value,
    attn_mask=None,
    dropout_p=0.0,
    is_causal=False,
    scale=None,
    tensor_layout="HND",  # "HND" or "NHD"
)
  • Q/K/V dtype: FP16 or BF16
  • Supported head dims: 64, 96, 128, 192
  • Supports GQA (grouped query attention) via different Hq/Hkv

ark.sagev1 — SAGE v1 Attention

output = ark.sagev1(
    query,
    key,
    value,
    attn_mask=None,
    dropout_p=0.0,
    is_causal=False,
    scale=None,
    enable_gqa=False,
    quant_block_size=64,  # block size for INT8 QK quantization
    tensor_layout="HND",
)
  • Q/K/V dtype: FP16 or BF16
  • Supported head dims: 64, 128
  • Internally quantizes Q/K to INT8 per block; PV computed in half precision
  • Falls back to ark.sdpa when quant_block_size <= 0

ark.sagev1_pvi8 — SAGE v1 with INT8 PV

Same interface as sagev1 but also quantizes V to INT8 internally for higher throughput.

ark.sage_dynquant — SAGE with Fused Dynamic Quantization

output = ark.sage_dynquant(
    query,
    key,
    value,
    attn_mask=None,
    dropout_p=0.0,
    is_causal=False,
    scale=None,
    enable_gqa=False,
    quant_block_size=64,
)
  • Takes FP16 Q/K/V, performs fused block-wise INT8 quantization of Q/K via SYCL kernel
  • Supports quant_block_size: 1 (per-token), 32, 64, 128, 256
  • Auto-pads sequence lengths for block alignment

ark.sageattn — SageAttention-Compatible Dispatcher

ARK provides a drop-in replacement for the sageattention.sageattn API, enabling seamless integration with existing SageAttention workflows:

import auto_round_kernel as ark

# Drop-in replacement for sageattention.sageattn
output = ark.sageattn(
    q,
    k,
    v,
    tensor_layout="HND",
    is_causal=False,
    sm_scale=None,
    return_lse=False,
    kernel="v1_pvhalf",  # or "v1_pvi8"
    **kwargs,
)

This mirrors the SageAttention interface for drop-in compatibility, allowing models using SageAttention to run on Intel Arc GPUs without code changes.

MOE GEMM

output = ark.moe_gemm(
    activations,  # [total_tokens, K] FP16/BF16
    weights,  # [num_experts, K, N] FP16/BF16
    num_tokens_per_expert,  # [num_experts] int32
    scales=None,  # optional [num_experts, N] FP16/BF16
)

Patching torch SDPA

ARK can globally replace torch.nn.functional.scaled_dot_product_attention for evaluation, including SageAttention backends:

import auto_round_kernel as ark

# Patch with standard SDPA backend
ark.patch_torch_sdpa(backend="sdpa")

# Patch with SageAttention v1 backend (INT8 QK, PV half)
ark.patch_torch_sdpa(backend="sagev1", quant_block_size=64)

# Patch with SageAttention v1 + INT8 PV backend
ark.patch_torch_sdpa(backend="sagev1_pvi8", quant_block_size=64)

# Restore original
ark.unpatch_torch_sdpa()

Or use the helper launcher 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

Low-Level Matrix Operations

# FP16/BF16 matrix multiply with bias
C = ark.matmul(A, B, bias)

# INT8 matrix multiply (s8s8s32)
C = ark.igemm_s8s8s32(A, B)

# Weight-only quantized GEMM with INT8 weights
C = ark.woqgemm_s8(A, B, scaleB, bias)

# General weight-only quantized GEMM
C = ark.woqgemm(A, B, bias, n, k, groupsize, compute_type, weight_type, scale_type, asym)

Testing

Unit tests are available in the test directory:

Test file Description
test_weightonly.py Weight-only quantized GEMM (CPU + XPU)
test_flash_attn.py Flash attention (sdpa) correctness
test_sdpa.py SDPA benchmark suite
test_sdpa_parity.py SDPA parity with non-contiguous inputs and layouts
test_sage_dynquant.py SageDynQuant block-wise benchmark
test_bench_bmg.py BMG comparison benchmark
test_matmul.py General matrix multiply
test_packq.py Weight packing/unpacking
test_moe.py MOE GEMM correctness

Notes

  • The SDPA patch only routes calls to ARK on XPU when inputs match kernel constraints; otherwise it falls back to the original torch SDPA.
  • Supported Q/K/V dtypes for attention are FP16 and BF16 (except SAGE variants which may use INT8 internally).
  • dropout_p must be 0.0 for all ARK attention paths.
  • Additive masks are supported when they can be normalized to [B, 1, Sq, Skv]; boolean masks fall back to torch.
  • Non-contiguous (sliced) input tensors are supported for all attention backends.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_round_lib-0.13.4.tar.gz (366.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

auto_round_lib-0.13.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

auto_round_lib-0.13.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

auto_round_lib-0.13.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

auto_round_lib-0.13.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

auto_round_lib-0.13.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file auto_round_lib-0.13.4.tar.gz.

File metadata

  • Download URL: auto_round_lib-0.13.4.tar.gz
  • Upload date:
  • Size: 366.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for auto_round_lib-0.13.4.tar.gz
Algorithm Hash digest
SHA256 d8f80502b5ff614b808daaa7a9f008d1556645003b7c3e3fb4541763c2d80c82
MD5 d8c8637b25ef514dcfb8a2d3e379f957
BLAKE2b-256 1648e6cd1d4fd4582a5dde3372d000a032b5bb000d015a82a200a1cde4ebc36b

See more details on using hashes here.

File details

Details for the file auto_round_lib-0.13.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auto_round_lib-0.13.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52006a5843c9cecf3fa383664a76b5c66666887af04d260695065e986c4e2610
MD5 99cef3730505139eb6e156ab06f959e2
BLAKE2b-256 41e111ce525825bb311ea050256430fcec05c5e448e7f9e40be68787248a0879

See more details on using hashes here.

File details

Details for the file auto_round_lib-0.13.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auto_round_lib-0.13.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 966d019be24369bc951b0043b80f24d5ba809ab7fa59c4ac2009c6ed0c9ce38f
MD5 7f1a2b8ef04a3db935a584e981e6caeb
BLAKE2b-256 2ee98788fd969cda33ec5e7112285cdce1c13b296c7a63331dd5aa83637bdc24

See more details on using hashes here.

File details

Details for the file auto_round_lib-0.13.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auto_round_lib-0.13.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8cd7ac4e9e1b01c9dfdaee1924b88e4c4e9066dd5cc4e0703a62c1658df2bd7c
MD5 e54e88db536dca4d13a606f8328cdfed
BLAKE2b-256 28a5f2a3b5b2599bde6aa7ee3acb809de66ef192b685fa0771ed21d8f4bed260

See more details on using hashes here.

File details

Details for the file auto_round_lib-0.13.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auto_round_lib-0.13.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c04053ffe9494ed0661e366ea3495995daf522f0cbb99cbe502f4534d450ffd4
MD5 ed4aeed5d053e307d37637edcba3e922
BLAKE2b-256 269a243c62c02530e1b7137dfa4ec7d0d6e8ce3d811eda312f6da7ac303c4fee

See more details on using hashes here.

File details

Details for the file auto_round_lib-0.13.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auto_round_lib-0.13.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ad5ff4a257cdfea96e91c282e778e5b243bf656c5acc36df48b01559296b66c
MD5 868cee3cdbd00fefc4b1a454e1165936
BLAKE2b-256 03028c3bcca0449997a217c40826df57fe0b845c16f6948d67a19860f2a58809

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page