Skip to content

Accordo

Accordo automatically validates GPU kernel correctness by capturing and comparing kernel outputs from reference and optimized implementations.

Features

  • Automatic kernel extraction: Uses KernelDB to extract kernel signatures from binaries
  • Snapshot-based validation: Capture once, compare against multiple optimizations
  • Configurable tolerance: Set precision requirements for floating-point comparisons
  • Performance tracking: Measure and compare execution times

Installation

Terminal window
pip install "git+https://github.com/AMDResearch/intellikit.git#subdirectory=accordo"

Quick start

from accordo import Accordo
# Create validator for a specific kernel
validator = Accordo(binary="./app_ref", kernel_name="reduce_sum")
# Capture snapshots from reference and optimized binaries
ref = validator.capture_snapshot(binary="./app_ref")
opt = validator.capture_snapshot(binary="./app_opt")
# Compare with specified tolerance
result = validator.compare_snapshots(ref, opt, tolerance=1e-6)
if result.is_valid:
print(f"PASS: {result.num_arrays_validated} arrays matched")
else:
print(result.summary())

Testing multiple optimizations

validator = Accordo(binary="./ref", kernel_name="matmul")
ref = validator.capture_snapshot(binary="./ref")
for opt_binary in ["./opt_v1", "./opt_v2", "./opt_v3"]:
opt = validator.capture_snapshot(binary=opt_binary)
result = validator.compare_snapshots(ref, opt, tolerance=1e-6)
print(f"{opt_binary}: {'PASS' if result.is_valid else 'FAIL'}")

CLI

Terminal window
accordo validate \
--kernel-name NAME \
--ref-binary PATH_TO_EXECUTABLE \
--opt-binary PATH_TO_EXECUTABLE \
[--tolerance FLOAT] # default: 1e-6
[--timeout SECONDS] # per snapshot, default: 30
[--working-dir DIR] # default: .
[--kernel-args 'n1:t1,...']
[--log-level DEBUG|INFO|WARNING|ERROR]

Example:

Terminal window
accordo validate --kernel-name reduce_sum --ref-binary ./app_ref --opt-binary ./app_opt

API reference

Accordo(binary, kernel_name, **options)

Parameters:

  • binary (str | list) — binary path to extract kernel signature from
  • kernel_name (str) — name of the kernel to validate
  • working_directory (str) — working directory (default: ".")
  • log_level (str) — logging level (default: "WARNING")

Methods:

  • capture_snapshot(binary, timeout_seconds=30)Snapshot
  • compare_snapshots(reference, optimized, tolerance=1e-6)ValidationResult

Snapshot

AttributeTypeDescription
arrayslist[np.ndarray]Captured output arrays
execution_time_msfloatExecution time
grid_sizedict | NoneKernel grid dimensions
block_sizedict | NoneKernel block dimensions

ValidationResult

AttributeTypeDescription
is_validboolWhether validation passed
num_arrays_validatedintTotal arrays checked
num_mismatchesintFailed comparisons
mismatcheslist[ArrayMismatch]Detailed mismatch info

Methods:

  • summary()str — human-readable validation summary

Requirements

  • Python >= 3.8
  • ROCm toolchain
  • KernelDB (automatically installed)