Results#
The workflow delivered a compiler whose programs pass on every benchmark workload that fits into the device’s memory. The results cover 16-bit floating-point (FP16) and bfloat16 (BF16) tensors on the GPUs and 32-bit floating-point (FP32) and 64-bit floating-point (FP64) tensors on the CPUs. On the general contractions among the benchmark workloads, the compiler’s programs outperform every baseline on all five devices, except on TCCG with FP64 tensors on the M4 CPU. On the general matrix multiplications (GEMMs), they trail transpose-transpose-GEMM-transpose (TTGT) on every set on the GB10 GPU and the M4 CPU, and with FP16 tensors also on the Radeon RX 9070 XT. They outperform the vendor GEMM, the GEMM that TTGT calls, on at least one set of GEMMs on the M4 GPU and the Ryzen AI Max PRO 390 CPU, and with BF16 tensors also on the Radeon RX 9070 XT. This chapter presents the performance, the use of TZIR, the heuristics with their performance models and the optimization over time.
Performance#
We summarize the programs on each benchmark set and device by the geometric mean over the set’s workloads. The means leave out the failed runs of the baselines and the batched GEMMs that Direct skips. The speedup on a workload is the time of the fastest baseline divided by the time of the compiler’s program (Figure 5). On the general contractions of TCCG and NWChem, the mean speedups of the compiler’s programs range from 1.01 to 5.00 on each set, device and datatype, except on TCCG with FP64 tensors on the M4 CPU. On the GEMMs of DeepGEMM, Muse and oneDNN, they range from 0.39 to 1.42.
Figure 5 Speedup of the compiler’s programs over the fastest of three baselines on each benchmark set, as the geometric mean over the set’s workloads. The gray line at 1 marks the fastest baseline.#
With FP64 tensors, the speedups of the compiler’s programs on the M4 CPU drop on every set. They reach 0.79 on TCCG, 1.38 on NWChem and 0.39 to 0.53 on the sets of GEMMs, against 1.45, 3.39 and 0.67 to 0.85 with FP32 tensors. The drop comes from the kernels of LIBXSMM that the backend of the M4 CPU uses. For FP64, LIBXSMM generates these kernels only with NEON vector instructions, so they leave the CPU’s Scalable Matrix Extension (SME) unused.
Figure 6 compares each program with the vendor GEMM. On NWChem, the compiler’s programs exceed the vendor GEMM’s performance on the Radeon RX 9070 XT and the M4 GPU, and with FP32 tensors also on the two CPUs. On TCCG, they exceed it only on the M4 GPU.
Figure 6 Performance of the compiler’s programs (Ours) and of three baselines on each benchmark set, relative to the vendor GEMM, the gray line at 1. Each marker gives a geometric mean on a logarithmic axis. Direct lacks a marker on NWChem on the Radeon RX 9070 XT, because it failed on every workload.#
Figure 7 shows each benchmark workload on one device at a time.
The compiler’s programs exceed the vendor GEMM’s performance most often on the M4 GPU, on 118 of 172 workloads with BF16 tensors and on 121 with FP16 tensors.
They exceed it least often on the M4 CPU with FP64 tensors, on 12 of 165 workloads.
The file benchmark-results.csv holds the times of the compiler’s programs, of the baselines and of the vendor GEMM on every workload, device and datatype.
Its column status marks the failed and skipped runs of the baselines.
Figure 7 Performance of each benchmark workload on one device, relative to the vendor GEMM, the gray line at 1. The x-axis numbers the workloads of each set in the order of their source. The y-axis is logarithmic. A gap marks a workload that does not fit into the device’s memory.#
Use of TZIR#
The heuristics either tile a contraction or leave the tiling to the backend. A heuristic tiles a program by moving axes into loops or placements, so that each tile operation works on tiles of the tensors. An untiled program applies its tile operations to whole tensors, and the code that the backend generates for these operations does the tiling.
We name each backend after its microarchitecture, such as Blackwell for the backend of the GB10 GPU (Table 1). On the benchmark workloads, the heuristics of Blackwell, Zen 5 and the M4 CPU tile every program. On Blackwell, 155 of the 173 programs also use on-chip buffers, among them every general contraction. Figure 2 shows one of them. The heuristic of RDNA 4 tiles 12 of the 66 general contractions and 49 of the 106 GEMMs, and each tiled program uses on-chip buffers. The heuristic of the M4 GPU tiles none of its programs and leaves all tiling to the backend. The target description of these programs declares the whole GPU as one unit and DRAM as its only memory space.
Heuristics and performance models#
On the visible workloads, the heuristics’ programs come close to the programs that the backend agents tuned for each workload. On the hidden workloads, the performance models meet the reviews’ bound.
On the 100 visible general contractions and GEMMs, the heuristics reach 83.4% to 101.0% of the performance of the tuned programs in the geometric mean (Figure 8). The heuristic of Blackwell outperforms its tuned programs. The backend agent of the M4 GPU tuned its programs on an M4 Max GPU, a larger GPU of the same microarchitecture, so the M4 GPU stays out of this comparison.
Figure 8 Performance of each heuristic’s programs relative to the tuned programs, as the geometric mean over the visible general contractions and GEMMs of each device and datatype. Each device has a row for each of its datatypes. The vertical line marks 100%.#
On the hidden workloads, the median relative errors of the performance models range from 2.8% to 10.6% (Figure 9). On the benchmark workloads, the errors grow on every device. They grow most on the M4 CPU, where they reach 24.0% with FP32 tensors. The agents developed the models on synthetic workloads, so the benchmark workloads test how the models carry over to applications.
Figure 9 Median relative error of each backend’s performance model on the hidden and the benchmark workloads. Each device has a row for each of its datatypes. Open markers give the error on the hidden workloads and filled markers the error on the benchmark workloads. A line joins the two markers of each row.#
Optimization over time#
Each review of an optimization task scored the heuristic on the hidden workloads of its device in both of its datatypes. A score is the geometric mean of the programs’ percentages of the roofline. Between the first and the last review of each optimization task, the heuristics’ scores rose by 0.8 to 16.6 percentage points (Figure 10). The agents requested their first review after 1.4 to 4.2 hours of work, so these gains leave out the work before it. On the Ryzen AI Max PRO 390 CPU, the heuristic of Zen 5 gained the most. Its score rose from 37.3% to 53.9% of the roofline. The heuristic of the M4 GPU gained the least.
Figure 10 Score of each backend’s heuristic in the reviews of its optimization task, with one panel per device. Each marker gives the score of one review at the working time of its request, filled for accepted commits and open for rejected ones. The y-axes start at different scores but span the same number of percentage points, so the slopes compare across devices.#