Skip to main content

AI kernel benchmarking harness

Project description

AI-bench: Unified AI Benchmarking Suite

Tests Lint KernelBench Perf Status

A benchmarking framework for evaluating AI kernel implementations across multiple backends (PyTorch, Triton) and devices (CPU, XPU).

Installation

The project is using uv package manager.

uv can be installed locally using:

pip install uv

The project can be installed with appropriate device-specific extensions using:

# CPU only
uv sync --extra cpu

# CPU + XPU
uv sync --extra xpu

Usage

Command Line Interface

After installation, the ai-bench command is available:

# Show help
ai-bench --help

# PyTorch on CPU (default)
ai-bench

# PyTorch on XPU
ai-bench --xpu

# PyTorch compile on XPU
ai-bench --xpu --torch-compile

# Triton on XPU
ai-bench --xpu --triton

# Benchmark mode (with timing)
ai-bench --xpu --bench

# Log results to CSV
ai-bench --xpu --bench --csv results.csv --note "baseline run"

Using Scripts Directly

Run KernelBench problems with different backends and devices:

# PyTorch on CPU (default)
python infra/scripts/run_kernel_bench.py

# PyTorch on XPU
python infra/scripts/run_kernel_bench.py --xpu

# PyTorch compile on XPU
python infra/scripts/run_kernel_bench.py --xpu --torch-compile

# Triton on XPU
python infra/scripts/run_kernel_bench.py --xpu --triton

# Benchmark mode (with timing)
python infra/scripts/run_kernel_bench.py --xpu --bench

# Triton benchmark on XPU
python infra/scripts/run_kernel_bench.py --xpu --triton --bench

As a Library

import ai_bench
import torch

# Configure paths if running outside project root
ai_bench.configure(
    specs_dir="/path/to/specs",
    kernels_dir="/path/to/kernels",
)

# Create benchmark runner
runner = ai_bench.KernelBenchRunner(
    spec_type=ai_bench.SpecKey.V_BENCH_GPU,
    device=torch.device("xpu"),
    backend=ai_bench.Backend.PYTORCH,
    flops_unit=ai_bench.FlopsUnit.TFLOPS,
    mem_bw_unit=ai_bench.MemBwUnit.GBS,
    csv_path="results.csv",
)
runner.run_kernels()

CSV Logging

Benchmark results can be logged to a CSV file using the --csv option:

# Log results to CSV
python infra/scripts/run_kernel_bench.py --xpu --triton --bench --csv results.csv

# Add a note to identify the run
python infra/scripts/run_kernel_bench.py --xpu --triton --bench --csv results.csv --note "BMG card test"

The CSV file includes the following columns:

  • kernel_name: Name of the kernel
  • kernel_type: Backend used (pytorch/triton)
  • problem_level: KernelBench problem level
  • flops: Number of floating-point operations
  • flops_val: Computed FLOPS value
  • flops_unit: FLOPS unit (GFLOPS/TFLOPS)
  • mem_bytes: Number of bytes transferred - input reads + output writes
  • mem_bw_val: Computed memory bandwidth value
  • mem_bw_unit: Memory bandwidth unit (MB/s or GB/s)
  • time_us: Execution time in microseconds
  • input_values: Input dimensions as JSON
  • note: User-provided note

Additionally, any environment variables prefixed with AIBENCH_ are automatically captured and included in the CSV output. This is useful for recording system configuration:

# Set environment variables for tracking
export AIBENCH_CARD="BMG"
export AIBENCH_SYSTEM="TestRig1"
python infra/scripts/run_kernel_bench.py --xpu --triton --bench --csv results.csv

Command Line Options

Option Description
--xpu Run on Intel XPU (default: CPU)
--triton Use Triton backend (default: PyTorch)
--torch-compile Use PyTorch compile mode
--bench Run benchmarks with timing (default: CI validation)
--gflops Report GFLOPS (default: TFLOPS)
--mbs Report MB/s (default: GB/s)
--csv PATH Log results to specified CSV file
--note TEXT Add a note to CSV output for identifying runs
--specs-dir PATH Path to specs directory (CLI only)
--kernels-dir PATH Path to kernels directory (CLI only)

Testing

Run tests with pytest:

pytest -v

Linting

The project uses pre-commit to run various checks automatically.

All checks can be run using:

pre-commit run -a

Config variables

Environment variables used for project configuration:

Variable Description
AIBENCH_LOG=INFO|DEBUG|... Globally overrides logging level
AIBENCH_SPECS_DIR Path to specs directory
AIBENCH_KERNELS_DIR Path to PyTorch kernels directory
AIBENCH_TRITON_KERNELS_DIR Path to Triton kernels directory

License

MIT License - see LICENSE for details.

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

ai_bench_suite-0.1.0b1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

ai_bench_suite-0.1.0b1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file ai_bench_suite-0.1.0b1.tar.gz.

File metadata

  • Download URL: ai_bench_suite-0.1.0b1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ai_bench_suite-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 ddf9c14a942ff532e7aa7edf2dd8262e742f2d66a4cc7de2f3db94decbe2d4f4
MD5 f9f688fb92f14c58fec4675f83bb637e
BLAKE2b-256 d04a4be080f83de0bf10bbd8c27e74575fe360b6623abb01eb8a073e9eba1fce

See more details on using hashes here.

File details

Details for the file ai_bench_suite-0.1.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_bench_suite-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 32c2740ac24172525627a71557cdc346a040c489329b439f4a7d964c762f148d
MD5 a907887d9f0968ebb8b08d335d162569
BLAKE2b-256 71fc3c1b6a6e635df0615c26d56d9e7caabe20de7694149429a8912ec4160c5e

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