Papers
Topics
Authors
Recent
Search
2000 character limit reached

tritonBLAS: Analytical GEMM Kernel Selector

Updated 8 December 2025
  • tritonBLAS is an analytical framework that deterministically selects GEMM kernel parameters by modeling tile configurations with hardware-specific details like cache hierarchy and memory bandwidth.
  • It replaces costly runtime autotuning with a closed-form, roofline-based performance model that rapidly predicts optimal tiling parameters, achieving near-optimal throughput.
  • Implemented in the Triton programming environment, tritonBLAS enables reproducible and low-overhead kernel configuration for high-performance computing and machine learning workloads.

tritonBLAS is a deterministic, analytical framework for General Matrix Multiplication (GEMM) kernel parameter selection, implemented entirely within the Triton programming environment. It replaces runtime empirical autotuning with a closed-form model that incorporates architectural parameters—including cache hierarchy, memory bandwidths, register and shared memory capacities, and the topology of compute units—to rapidly select performant GPU kernel configurations. tritonBLAS achieves near-optimal throughput, with selection overhead several orders of magnitude lower than autotuned solutions, making it suitable for both high-performance computing (HPC) and ML production workloads (Swann et al., 3 Dec 2025).

1. Analytical Model for GEMM Kernel Selection

tritonBLAS models the GEMM operation CαAB+βCC \leftarrow \alpha \cdot A \cdot B + \beta \cdot C, where ARM×KA \in \mathbb{R}^{M \times K}, BRK×NB \in \mathbb{R}^{K \times N}, and CRM×NC \in \mathbb{R}^{M \times N}, as a tiling problem mapped to the GPU hardware. The framework partitions the computation across compute units (CUs) placing spatial “output” tiles with dimensions Mb×NbM_b \times N_b and reduction tiles along KK of size KbK_b.

The performance model builds upon the roofline approach, using the arithmetic intensity II (FLOP/byte):

I=2MNK4[MK+NK+MN]I = \frac{2 M N K}{4[M K + N K + M N]}

where 2 FLOPs per MAC and 2 bytes per FP16 element are assumed. The maximal achievable performance is:

Pmin(Fpeak,BmemI)P \leq \min (F_{peak}, B_{mem} \cdot I)

Per-tile latency comprises:

  • Compute latency ARM×KA \in \mathbb{R}^{M \times K}0, derived from matrix instruction shape ARM×KA \in \mathbb{R}^{M \times K}1 and instruction latency ARM×KA \in \mathbb{R}^{M \times K}2; for a tile, ARM×KA \in \mathbb{R}^{M \times K}3, with ARM×KA \in \mathbb{R}^{M \times K}4.
  • Memory latency ARM×KA \in \mathbb{R}^{M \times K}5, modeled across L1, L2 caches, and DRAM with bandwidths ARM×KA \in \mathbb{R}^{M \times K}6, ARM×KA \in \mathbb{R}^{M \times K}7, ARM×KA \in \mathbb{R}^{M \times K}8, and hit rates ARM×KA \in \mathbb{R}^{M \times K}9 estimated from tile footprints and reuse. Per-CU load latency is assigned by the bottleneck among memory hierarchy levels, accounting for uncached and cached loads.

Pipeline overhead (prologue/epilogue) and occupancy details, such as waves (BRK×NB \in \mathbb{R}^{K \times N}0) and active compute units, are incorporated. The total latency formula is:

BRK×NB \in \mathbb{R}^{K \times N}1

where BRK×NB \in \mathbb{R}^{K \times N}2 includes all compute, memory, pipeline, and store latencies, as explicated in the model.

Optimization seeks to select BRK×NB \in \mathbb{R}^{K \times N}3 minimizing BRK×NB \in \mathbb{R}^{K \times N}4, equivalently maximizing BRK×NB \in \mathbb{R}^{K \times N}5.

2. Architecture-Driven Parameterization

All model inputs are obtained from microbenchmarks executed on the target GPU. Key parameters include:

  • BRK×NB \in \mathbb{R}^{K \times N}6: Number of compute units (e.g., 80 on MI300X)
  • Matrix instruction shape BRK×NB \in \mathbb{R}^{K \times N}7 and latency BRK×NB \in \mathbb{R}^{K \times N}8
  • Registers per SIMD, registers per thread (impose loop unroll limits)
  • Shared memory per CU, L1/L2 cache size and bandwidth, DRAM bandwidth and latency
  • Architectural constraints: e.g., BRK×NB \in \mathbb{R}^{K \times N}9elem_bytes CRM×NC \in \mathbb{R}^{M \times N}0elem_bytes CRM×NC \in \mathbb{R}^{M \times N}1 smem_size

These values determine feasible tile factors and inform the performance cost function.

3. Blocking Notation and Optimization Constraints

Within this framework, tiling factors are notated as:

  • CRM×NC \in \mathbb{R}^{M \times N}2, CRM×NC \in \mathbb{R}^{M \times N}3: spatial output tile sizes
  • CRM×NC \in \mathbb{R}^{M \times N}4: reduction axis tile size

Constraints restrict candidate tiles:

  • CRM×NC \in \mathbb{R}^{M \times N}5 must respect shared memory and register file capacities
  • Shared memory per block: CRM×NC \in \mathbb{R}^{M \times N}6elem_bytes CRM×NC \in \mathbb{R}^{M \times N}7 SMEM_per_CU
  • Approximate register demand: CRM×NC \in \mathbb{R}^{M \times N}8

The optimization solves:

CRM×NC \in \mathbb{R}^{M \times N}9

subject to these constraints, over the valid factor set.

4. Static Enumeration and Selection Algorithm

tritonBLAS proceeds by statically enumerating potential tile sizes, invoking the analytical model for each candidate, and selecting the configuration with minimal predicted latency. No empirical testing or JIT compilation during selection is required.

Pseudocode encapsulates this process:

KK5

The candidate set Mb×NbM_b \times N_b0 is typically Mb×NbM_b \times N_b1–Mb×NbM_b \times N_b2 for FP16 kernels on contemporary GPUs, enabling sub-millisecond selection latency.

5. Triton-Based Implementation

The tritonBLAS workflow is embedded in Triton as a pure-Python module. The analytical selector and GEMM kernel are coupled as follows:

  • Selector determines optimal (Mb×NbM_b \times N_b3)
  • Kernel launch uses Triton’s grid mapping: Mb×NbM_b \times N_b4
  • All tile sizes are resolved pre-launch; no calls to @triton.autotune are issued

Example function signature:

KK6

and the user-facing routine:

KK7

Selection and launch overhead is Mb×NbM_b \times N_b5–Mb×NbM_b \times N_b6s, independent of matrix shape.

6. Performance Characterization

Empirical evaluation demonstrates:

GEMM Shape Tile Sizes Predicted Latency (μs) Measured Latency (μs) Error (%)
512×512×512 32×32×8 120 125 +4.2
1024×512×256 64×32×8 80 83 +3.8
2048×1024×512 128×64×16 240 253 +5.4

Over 150K random shapes up to Mb×NbM_b \times N_b7K dimension, tritonBLAS attains 94.7% of the peak performance found by exhaustive autotuning, with a median performance near 97%. Selection time is Mb×NbM_b \times N_b8–Mb×NbM_b \times N_b9 orders faster than runtime autotuning (e.g., KK080 μs vs. 12–50 s). GEMM throughput on MI300X (FP16) is within KK13% of vendor-optimized torch.matmul(), and achieves KK295% of the performance of autotuned cuBLAS/CUTLASS kernels across a wide arithmetic intensity range (0.5–50 FLOP/byte).

The timing model’s prediction error remains within KK3 across representative shapes and correctly ranks candidate tile configurations.

7. Strengths and Limitations

Strengths:

  • Eliminates runtime autotuning overhead, enabling rapid deployment and dynamic batching
  • Tile selection is deterministic and reproducible; identical shapes yield identical parameter choices
  • Portable across GPU architectures; calibration of model inputs suffices for adaptation
  • Delivers near-optimal performance (≥95% of exhaustive search), even for memory-bound workloads

Limitations:

  • Model abstracts away cache associativity and replacement details; not critical for GEMM’s regular access pattern
  • Framework operates under a single-GPU model; multi-GPU scenarios demand separate interconnect modeling
  • For extremely small GEMM problems (KK4), kernel launch overhead dominates achievable performance; tiling decisions have marginal effect
  • Model accuracy depends on precision of measured architectural parameters; recalibration is required for new hardware, but can be achieved rapidly (few μs)

A plausible implication is that tritonBLAS enables analytical optimization in dynamic and rapidly changing workload scenarios with negligible selection cost, while maintaining throughput competitive with state-of-the-art autotuned frameworks (Swann et al., 3 Dec 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to tritonBLAS.