metal-linalg

Eigensolver routing on Apple M5 Pro (20 GPU cores)

What every section and number below means: reading-reports.md.

Cost model scaled to this device from one probe point: block x0.13, cpu x0.08, whole-matrix x1.00 (1.00 is an M1).

Machine state: load 2.9/18 at the start, load 6.8/18 at the end; power mains.

Probe point after the sweep relative to before it: block x1.00, cpu x0.99, tg x1.04 (stable).

Generated by tuning/tune_eigh.py from 132 (N, batch) points, N in [2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 256], batch in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096], four backends, two or more passes, min-of-repeats.

Answer

Row for kTuned[] in src/eigh.mm:

// device, GPU cores,   simd_max_n, block_min_n, block_min_n_batched, block_min_batch,   gpu_max_n, gpu_min_batch_times_n, gpu_min_batch,   values_gpu_max_n, values_gpu_min_batch_times_n, values_gpu_min_batch,   tridiag_min_n, values_tridiag_min_n, tridiag_max_batch, values_tridiag_max_batch,   ql_min_n, ql_max_n,   share_min_batch,   gpu_big_batch_max_n, gpu_big_batch_min,   values_band_min_n, values_band_width
{"Apple M5 Pro", 20,   0, 256, 64, 64,   16, 8192, 1,   48, 8192, 1,   1024, 1024, 128, 2,   2, 64,   256,   64, 256,   1536, 16,   512,   96, 1024, 128,   96, 256, 256,   48},

To try it without rebuilding:

EIGH_SIMD_MAX_N=0 EIGH_BLOCK_MIN_N=256 EIGH_BLOCK_MIN_N_BATCHED=64 EIGH_BLOCK_MIN_BATCH=64 EIGH_GPU_MAX_N=16 EIGH_GPU_MIN_BATCH_TIMES_N=8192 EIGH_GPU_MIN_BATCH=1 EIGH_TRIDIAG_MIN_N=1024 EIGH_VALUES_TRIDIAG_MIN_N=1024 EIGH_TRIDIAG_MAX_BATCH=128 EIGH_VALUES_TRIDIAG_MAX_BATCH=2 EIGH_QL_MIN_N=2 EIGH_QL_MAX_N=64 EIGH_SHARE_MIN_BATCH=256 EIGH_SHARE_MIN_N=48 EIGH_GPU_BIG_BATCH_MAX_N=64 EIGH_GPU_BIG_BATCH_MIN=256 EIGH_VALUES_BAND_MIN_N=1536 EIGH_VALUES_BAND_WIDTH=16 EIGH_BAND_MIN_N=512 EIGH_TRIDIAG_BATCH_MIN_N=96 EIGH_TRIDIAG_BATCH_MAX_N=1024 EIGH_TRIDIAG_BATCH_MIN_BATCH=128 EIGH_VALUES_TRIDIAG_BATCH_MIN_N=96 EIGH_VALUES_TRIDIAG_BATCH_MAX_N=256 EIGH_VALUES_TRIDIAG_BATCH_MIN_BATCH=256 EIGH_VALUES_GPU_MAX_N=48 EIGH_VALUES_GPU_MIN_BATCH_TIMES_N=8192 EIGH_VALUES_GPU_MIN_BATCH=1

The policy in effect on this device came from tuned:Apple M5 Pro. It differs from the fitted one; see the warnings.

Against the best measured backend at every point the whole rule scores 1.0031 geometric-mean regret, worst 1.22x, 1 of 132 points losing more than 10%, and 1.002x the oracle’s total time. The decision is fitted in two stages, below, because the CPU routing would otherwise hide the GPU backend crossover.

Warnings

Stage 1: which GPU backend

Scored against the best GPU backend at each of the 132 points, as if there were no CPU: this is the rule a forced-GPU call (EIGH_DEVICE=gpu) and the detail entry points follow, and it is what a GPU with more cores will lean on.

rule geomean regret worst >10% total time / oracle est. picks
policy in effect (‘0’, ‘96’, ‘none’, ‘none’) 1.0360 1.62x 12 1.103 0
fitted (‘0’, ‘256’, ‘64’, ‘64’) 1.0090 1.18x 2 1.001 0

4 of 48 (simd_max_n, block_min_n) pairs are within 0.5% of the best geomean: simd_max_n 0 .. 8, block_min_n 96 .. 96.

With the batch term adopted (below), 3 combinations are within 0.5% of the best: block_min_n 256 .. 256, block_min_n_batched 64 .. 64, block_min_batch 32 .. 128. The curves below vary one constant around the chosen combination.

xychart-beta
    title "Regret by block_min_n"
    x-axis "block_min_n" [32, 48, 64, 96, 256, none]
    y-axis "geometric-mean regret" 1.0 --> 1.35
    line [1.3330, 1.1688, 1.0620, 1.0195, 1.0090, 1.0209]
block_min_n 32 48 64 96 256 none
geomean 1.3330 1.1688 1.0620 1.0195 1.0090 1.0209
worst 9.68x 4.60x 2.63x 1.39x 1.18x 4.72x
xychart-beta
    title "Regret by block_min_n_batched"
    x-axis "block_min_n_batched" [32, 48, 64, 96]
    y-axis "geometric-mean regret" 1.0 --> 1.09
    line [1.0774, 1.0390, 1.0090, 1.0253]
block_min_n_batched 32 48 64 96
geomean 1.0774 1.0390 1.0090 1.0253
worst 5.23x 2.78x 1.18x 1.62x
xychart-beta
    title "Regret by block_min_batch"
    x-axis "block_min_batch" [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]
    y-axis "geometric-mean regret" 1.0 --> 1.08
    line [1.0620, 1.0523, 1.0426, 1.0327, 1.0230, 1.0130, 1.0090, 1.0102, 1.0152, 1.0227, 1.0314, 1.0399, 1.0483]
block_min_batch 1 2 4 8 16 32 64 128 256 512 1024 2048 4096
geomean 1.0620 1.0523 1.0426 1.0327 1.0230 1.0130 1.0090 1.0102 1.0152 1.0227 1.0314 1.0399 1.0483
worst 2.63x 2.63x 2.63x 2.63x 2.63x 1.85x 1.18x 1.39x 1.70x 1.93x 1.93x 1.93x 1.93x
xychart-beta
    title "Regret by simd_max_n"
    x-axis "simd_max_n" [0, 2, 4, 8, 12, 16, 24, 32]
    y-axis "geometric-mean regret" 1.0 --> 1.29
    line [1.0360, 1.0360, 1.0342, 1.0392, 1.0587, 1.0877, 1.1598, 1.2746]
simd_max_n 0 2 4 8 12 16 24 32
geomean 1.0360 1.0360 1.0342 1.0392 1.0587 1.0877 1.1598 1.2746
worst 1.62x 1.62x 1.62x 1.62x 2.00x 2.00x 3.16x 5.21x

Held-out check of a batch-dependent crossover (block from a lower N once the batch is large enough). Fitted on 71 points, scored on the other 61; the verdict is a bootstrap over the test points.

rule fitted on train train geomean test geomean test worst verdict
two constants [4, 96, 1000000000, 1000000000] 1.0287 1.0407 1.61x baseline
batch-dependent block crossover {“block_lo”: 64, “batch_hi”: 64} 1.0048 1.0101 1.28x justified (better in 99% of resamples, median gain 3.0%)

Best GPU backend per point (s simd, t threadgroup, B block, q ql, Q ql shared with the CPU), then what the split picks, the ql window of stage 1b included:

  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2     s     s     t     s     t     q     q     q     s     s     q     q     q
          4     q     q     s     q     s     q     s     s     s     q     q     q     q
          8     t     t     t     s     t     s     t     s     s     q     q     q     q
         12     t     t     q     t     t     t     t     t     q     q     q     q     q
         16     t     t     t     t     t     t     t     t     q     q     q     q     q
         24     t     t     t     t     t     t     q     q     q     q     q     q     q
         32     t     t     t     t     t     t     q     q     q     q     q     q     q
         48     t     t     t     t     t     q     q     q     q     q     q     q     q
         64     q     t     t     t     t     q     q     q     q     q     q     q     q
         96     t     t     t     t     t     B     B     B     B     B     B     B     B
        256     B     .     .     .     .     .     B     .     .     .     .     .     .
  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2     q     q     q     q     q     q     q     q     q     q     q     q     q
          4     q     q     q     q     q     q     q     q     q     q     q     q     q
          8     q     q     q     q     q     q     q     q     q     q     q     q     q
         12     q     q     q     q     q     q     q     q     q     q     q     q     q
         16     q     q     q     q     q     q     q     q     q     q     q     q     q
         24     q     q     q     q     q     q     q     q     q     q     q     q     q
         32     q     q     q     q     q     q     q     q     q     q     q     q     q
         48     q     q     q     q     q     q     q     q     Q     Q     Q     Q     Q
         64     q     q     q     q     q     q     q     q     Q     Q     Q     Q     Q
         96     t     t     t     t     t     t     B     B     B     B     B     B     B
        256     B     .     .     .     .     .     B     .     .     .     .     .     .

Stage 1b: the ql backend

Inside a window of N, ql (tridiagonalization and implicit QL, one threadgroup per matrix, N <= 87 on this device) instead of the Jacobi backend the split picks, fitted over the 132 points against the best GPU backend, ql included. Chosen: N = 2 .. 64.

rule geomean regret worst >10% total time / oracle est. picks
without ql (the split alone) 1.2785 4.07x 46 1.262 0
with ql for N in (2, 64) 1.0653 1.44x 35 1.004 0

2 windows are within 0.5% of the best geomean: ql_min_n 2 .. 4, ql_max_n 64 .. 64.

Held out: fitted on 71 points (window (2, 64)), scored on the other 61: geomean 1.0651x, worst 1.36x, against 1.2722x, worst 3.80x without ql.

ql over the best Jacobi backend, N x batch: 2x1 0.75x, 2x2 0.95x, 2x4 0.91x, 2x8 0.92x, 2x16 0.96x, 2x32 1.01x, 2x64 1.00x, 2x128 1.03x, 2x256 0.99x, 2x512 0.96x, 2x1024 1.01x, 2x2048 1.05x, 2x4096 1.15x, 4x1 1.05x, 4x2 1.01x, 4x4 0.88x, 4x8 1.00x, 4x16 0.98x, 4x32 1.06x, 4x64 0.96x, 4x128 0.94x, 4x256 0.95x, 4x512 1.00x, 4x1024 1.07x, 4x2048 1.13x, 4x4096 1.39x, 8x1 1.00x, 8x2 0.70x, 8x4 0.94x, 8x8 0.94x, 8x16 0.98x, 8x32 0.89x, 8x64 0.92x, 8x128 0.89x, 8x256 0.96x, 8x512 1.05x, 8x1024 1.24x, 8x2048 1.38x, 8x4096 1.60x, 12x1 0.76x, 12x2 0.78x, 12x4 1.01x, 12x8 0.88x, 12x16 0.86x, 12x32 0.88x, 12x64 0.93x, 12x128 0.86x, 12x256 1.07x, 12x512 1.29x, 12x1024 1.51x, 12x2048 1.54x, 12x4096 1.64x, 16x1 0.92x, 16x2 0.80x, 16x4 0.83x, 16x8 0.83x, 16x16 0.79x, 16x32 0.81x, 16x64 0.86x, 16x128 0.94x, 16x256 1.25x, 16x512 1.49x, 16x1024 1.80x, 16x2048 1.68x, 16x4096 1.94x, 24x1 0.86x, 24x2 0.88x, 24x4 0.82x, 24x8 0.81x, 24x16 0.78x, 24x32 0.80x, 24x64 1.00x, 24x128 1.37x, 24x256 2.14x, 24x512 2.10x, 24x1024 2.37x, 24x2048 2.57x, 24x4096 2.78x, 32x1 0.73x, 32x2 0.70x, 32x4 0.78x, 32x8 0.80x, 32x16 0.74x, 32x32 0.98x, 32x64 1.20x, 32x128 2.10x, 32x256 2.97x, 32x512 2.78x, 32x1024 3.60x, 32x2048 3.90x, 32x4096 4.07x, 48x1 0.85x, 48x2 0.81x, 48x4 0.80x, 48x8 0.80x, 48x16 0.82x, 48x32 1.09x, 48x64 1.70x, 48x128 2.85x, 48x256 2.65x, 48x512 3.29x, 48x1024 3.36x, 48x2048 3.70x, 48x4096 3.80x, 64x1 1.00x, 64x2 0.91x, 64x4 0.92x, 64x8 0.92x, 64x16 0.90x, 64x32 1.32x, 64x64 2.31x, 64x128 2.16x, 64x256 2.13x, 64x512 2.13x, 64x1024 2.21x, 64x2048 2.27x, 64x4096 2.28x

Stage 1c: sharing a batch with the CPU

From a batch and an N on, ql_share: ql and the CPU path at once on one batch, the GPU taking chunks from the front and the CPU from the back. Fitted against the best GPU backend, the shared one included, on the 63 points where it was timed and ql is the GPU’s choice. Chosen: from batch 256 and N = 48.

rule geomean regret worst >10% total time / oracle est. picks
ql alone 1.0894 1.88x 15 1.464 0
shared from batch 256, N >= 48 1.0201 1.20x 5 1.006 0

ql_share over ql alone, N x batch: 2x64 0.92x, 2x128 0.91x, 2x256 0.54x, 2x512 0.58x, 2x1024 0.49x, 2x2048 0.48x, 2x4096 0.46x, 4x64 1.20x, 4x128 0.59x, 4x256 0.62x, 4x512 0.48x, 4x1024 0.50x, 4x2048 0.55x, 4x4096 0.39x, 8x64 1.20x, 8x128 0.69x, 8x256 0.57x, 8x512 0.49x, 8x1024 0.53x, 8x2048 0.41x, 8x4096 0.55x, 12x64 0.67x, 12x128 0.67x, 12x256 0.62x, 12x512 0.58x, 12x1024 0.48x, 12x2048 0.68x, 12x4096 0.93x, 16x64 0.70x, 16x128 0.70x, 16x256 0.63x, 16x512 0.61x, 16x1024 0.61x, 16x2048 0.93x, 16x4096 0.93x, 24x64 0.74x, 24x128 0.72x, 24x256 0.72x, 24x512 0.66x, 24x1024 0.98x, 24x2048 0.99x, 24x4096 1.07x, 32x64 0.82x, 32x128 0.78x, 32x256 0.86x, 32x512 0.82x, 32x1024 0.97x, 32x2048 0.96x, 32x4096 1.06x, 48x64 0.89x, 48x128 0.86x, 48x256 1.61x, 48x512 1.27x, 48x1024 1.31x, 48x2048 1.34x, 48x4096 1.45x, 64x64 0.92x, 64x128 0.95x, 64x256 1.35x, 64x512 1.50x, 64x1024 1.74x, 64x2048 1.84x, 64x4096 1.88x

Stage 2: GPU or CPU

Given the split above, GPU iff N <= gpu_max_n, batch * N >= gpu_min_batch_times_n and batch >= gpu_min_batch, scored against the best of all four backends. worst is over the points where the chosen backend was timed; a pick the cost model had to guess is listed in the warnings instead.

rule geomean regret worst >10% total time / oracle est. picks
oracle (best per point) 1.0000 1.00x 0 1.000 0
policy in effect (‘16’, ‘8192’, ‘1’) 1.0165 1.72x 5 1.099 0
fitted (‘16’, ‘8192’, ‘1’) 1.0031 1.22x 1 1.002 0

Large batches: the GPU also for N above gpu_max_n up to 64 in a batch of at least 256, fitted with the product rule (per cap, the rule, the clause over it and the rule again given the clause, the best kept) (product rule alone 1.0869, worst 2.53x; chosen 1.0031, worst 1.22x).

6 of 462 combinations are within 0.5% of the best geomean: gpu_max_n 64 .. 64, gpu_min_batch_times_n 8192 .. 8192, gpu_min_batch 1 .. 32.

xychart-beta
    title "Regret by gpu_min_batch_times_n"
    x-axis "gpu_min_batch_times_n" [0, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, none]
    y-axis "geometric-mean regret" 1.0 --> 1.92
    line [1.9088, 1.2499, 1.1501, 1.0886, 1.0546, 1.0337, 1.0177, 1.0048, 1.0031, 1.0137, 1.0538]
gpu_min_batch_times_n 0 64 128 256 512 1024 2048 4096 8192 16384 none
geomean 1.9088 1.2499 1.1501 1.0886 1.0546 1.0337 1.0177 1.0048 1.0031 1.0137 1.0538
worst 151.31x 12.95x 7.14x 2.97x 2.97x 2.15x 1.63x 1.22x 1.22x 1.39x 2.44x
xychart-beta
    title "Regret by gpu_min_batch"
    x-axis "gpu_min_batch" [1, 2, 4, 8, 16, 32]
    y-axis "geometric-mean regret" 1.0 --> 1.02
    line [1.0031, 1.0031, 1.0031, 1.0031, 1.0031, 1.0031]
gpu_min_batch 1 2 4 8 16 32
geomean 1.0031 1.0031 1.0031 1.0031 1.0031 1.0031
worst 1.22x 1.22x 1.22x 1.22x 1.22x 1.22x
xychart-beta
    title "Regret by gpu_max_n"
    x-axis "gpu_max_n" [16, 24, 32, 48, 64, 96, 256]
    y-axis "geometric-mean regret" 1.0 --> 1.10
    line [1.0031, 1.0049, 1.0049, 1.0049, 1.0098, 1.0683, 1.0826]
gpu_max_n 16 24 32 48 64 96 256
geomean 1.0031 1.0049 1.0049 1.0049 1.0098 1.0683 1.0826
worst 1.22x 1.28x 1.28x 1.28x 1.89x 3.93x 5.75x

Held-out check of a per-N boundary (a lookup table of the smallest batch at which the GPU wins, per N) against the product rule. Fitted on 71 points, scored on the other 61.

rule fitted on train train geomean test geomean test worst verdict
product rule [16, 8192, 1] 1.0037 1.0023 1.08x baseline
per-N table {“min_batch_by_n”: {“2”: 512, “4”: 2048, “8”: 1024, “12”: 2048, “16”: 512, “24”: 512, “32”: 512, “48”: 512, “64”: 4096, “96”: null, “256”: null}} 1.0015 1.0474 1.63x rejected (better in 0% of resamples, median gain -4.2%)

Best backend per point (c CPU, s simd, t threadgroup, B block, q ql, Q ql shared with the CPU, . not measured), what the whole rule picks, and the speedup of the best GPU backend over the CPU:

  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2     c     c     c     c     c     c     c     c     c     s     c     q     q
          4     c     c     c     c     c     c     c     c     c     c     c     q     q
          8     c     c     c     c     c     c     c     c     c     c     q     q     q
         12     c     c     c     c     c     c     c     c     c     q     q     q     q
         16     c     c     c     c     c     c     c     c     c     q     q     q     q
         24     c     c     c     c     c     c     c     c     q     q     q     q     Q
         32     c     c     c     c     c     c     c     c     q     q     q     q     Q
         48     c     c     c     c     c     c     c     c     Q     Q     Q     Q     Q
         64     c     c     c     c     c     c     c     c     Q     Q     Q     Q     Q
         96     c     c     c     c     c     c     c     c     c     c     c     c     c
        256     c     .     .     .     .     .     c     .     .     .     .     .     .
  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2     c     c     c     c     c     c     c     c     c     c     c     c     q
          4     c     c     c     c     c     c     c     c     c     c     c     q     q
          8     c     c     c     c     c     c     c     c     c     c     q     q     q
         12     c     c     c     c     c     c     c     c     c     c     q     q     q
         16     c     c     c     c     c     c     c     c     c     q     q     q     q
         24     c     c     c     c     c     c     c     c     q     q     q     q     q
         32     c     c     c     c     c     c     c     c     q     q     q     q     q
         48     c     c     c     c     c     c     c     c     Q     Q     Q     Q     Q
         64     c     c     c     c     c     c     c     c     Q     Q     Q     Q     Q
         96     c     c     c     c     c     c     c     c     c     c     c     c     c
        256     c     .     .     .     .     .     c     .     .     .     .     .     .
  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2  0.01  0.02  0.04  0.09  0.07  0.11  0.30  0.39  0.69  1.22  0.81  1.00  1.36
          4  0.01  0.03  0.06  0.10  0.11  0.20  0.41  0.79  0.88  0.75  0.88  1.18  1.80
          8  0.01  0.04  0.09  0.13  0.24  0.48  0.88  0.52  0.73  0.95  1.39  1.90  2.44
         12  0.03  0.08  0.12  0.17  0.42  0.54  0.55  0.68  0.72  1.08  1.38  1.72  1.87
         16  0.04  0.09  0.09  0.17  0.61  0.41  0.56  0.65  0.88  1.32  1.57  1.76  2.26
         24  0.09  0.14  0.13  0.30  0.40  0.56  0.54  0.81  1.28  1.45  1.73  2.25  2.25
         32  0.12  0.12  0.15  0.23  0.43  0.39  0.53  0.89  1.33  1.41  2.32  2.33  2.37
         48  0.11  0.13  0.13  0.28  0.28  0.33  0.46  0.93  0.94  1.46  1.27  1.41  1.42
         64  0.16  0.13  0.13  0.21  0.22  0.32  0.50  0.53  0.74  0.86  0.91  0.88  0.91
         96  0.08  0.08  0.09  0.11  0.13  0.16  0.19  0.30  0.31  0.30  0.30  0.25  0.28
        256  0.16     .     .     .     .     .  0.17     .     .     .     .     .     .

Stage 3: GPU or CPU, eigenvalues alone

The same rule for eigvalsh, with its own thresholds (values_gpu_max_n, values_gpu_min_batch_times_n, values_gpu_min_batch), fitted on the _vals timings of 132 points given the split above. The CPU computes eigenvalues alone by LAPACK’s two-stage reduction from N = 128, so the boundary need not be eigh’s.

rule geomean regret worst >10% total time / oracle est. picks
policy in effect 1.0171 1.41x 9 1.049 0
eigh’s fitted boundary 1.0090 1.96x 3 1.008 0
fitted (‘48’, ‘8192’, ‘1’) 1.0112 1.39x 5 1.048 0

12 combinations are within 0.5% of the best geomean: values_gpu_max_n 48 .. 64, values_gpu_min_batch_times_n 8192 .. 16384, values_gpu_min_batch 1 .. 32.

Held out: fitted on 71 points (‘64’, ‘16384’, ‘1’), scored on the other 61: geomean 1.0246x, worst 1.96x, against 1.0828x, worst 3.22x for eigh’s boundary on the same points.

Stage 4: the tridiag backend instead of the CPU

Where the rule above chooses the CPU, the tridiag backend from a threshold N on (0: never), for batches up to a cap (0: any; it solves a batch one matrix after another, the CPU path spreads one over every core), fitted over the measured N and batches against the best of all backends, tridiag included, on the points where tridiag was timed (N >= 128, within the cost cap): the region the threshold decides.

  threshold batch cap geomean regret worst without tridiag: geomean worst held out (fitted on half)
with eigenvectors 1024 4 1.0029 1.21x 1.2122 8.14x from 1024, batch <= 4: 1.0000 vs 1.0682
eigenvalues alone 1024 2 1.0185 1.62x 1.1091 3.74x from 1024, batch <= 2: 1.0000 vs 1.0247

tridiag over the CPU (with eigenvectors), N x batch: 128x1 0.29x, 128x2 0.19x, 128x4 0.11x, 128x8 0.06x, 128x16 0.05x, 128x32 0.03x, 128x64 0.03x, 128x128 0.03x, 128x256 0.03x, 128x512 0.03x, 192x1 0.43x, 192x2 0.24x, 192x4 0.14x, 192x8 0.09x, 192x16 0.07x, 192x32 0.06x, 192x64 0.05x, 192x128 0.05x, 192x256 0.04x, 256x1 0.56x, 256x2 0.32x, 256x4 0.18x, 256x8 0.12x, 256x16 0.08x, 256x32 0.08x, 256x64 0.07x, 256x128 0.06x, 256x256 0.06x, 384x1 0.68x, 384x2 0.42x, 384x4 0.25x, 384x8 0.19x, 384x16 0.12x, 384x32 0.11x, 384x64 0.10x, 384x128 0.10x, 512x1 0.99x, 512x2 0.64x, 512x4 0.35x, 512x8 0.29x, 512x16 0.18x, 512x32 0.17x, 512x64 0.16x, 512x128 0.16x, 768x1 1.21x, 768x2 0.82x, 768x4 0.55x, 768x8 0.42x, 768x16 0.28x, 768x32 0.26x, 768x64 0.26x, 1024x1 1.88x, 1024x2 1.28x, 1024x4 1.19x, 1024x8 0.81x, 1024x16 0.59x, 1024x32 0.59x, 1024x64 0.60x, 1536x1 2.65x, 1536x2 1.66x, 1536x4 1.42x, 2048x1 3.76x, 2048x2 3.01x, 2048x4 2.17x, 2560x1 3.89x, 3072x1 4.93x, 3584x1 5.77x, 4096x1 8.14x

tridiag over the CPU (eigenvalues alone), N x batch: 128x1 0.24x, 128x2 0.13x, 128x4 0.09x, 128x8 0.05x, 128x16 0.03x, 128x32 0.02x, 128x64 0.02x, 128x128 0.02x, 128x256 0.02x, 128x512 0.02x, 192x1 0.33x, 192x2 0.18x, 192x4 0.10x, 192x8 0.06x, 192x16 0.05x, 192x32 0.03x, 192x64 0.03x, 192x128 0.03x, 192x256 0.03x, 256x1 0.42x, 256x2 0.23x, 256x4 0.13x, 256x8 0.08x, 256x16 0.06x, 256x32 0.05x, 256x64 0.04x, 256x128 0.04x, 256x256 0.04x, 384x1 0.58x, 384x2 0.33x, 384x4 0.19x, 384x8 0.12x, 384x16 0.08x, 384x32 0.07x, 384x64 0.06x, 384x128 0.06x, 512x1 0.83x, 512x2 0.46x, 512x4 0.29x, 512x8 0.16x, 512x16 0.11x, 512x32 0.10x, 512x64 0.08x, 512x128 0.08x, 768x1 1.21x, 768x2 0.68x, 768x4 0.38x, 768x8 0.24x, 768x16 0.16x, 768x32 0.14x, 768x64 0.13x, 1024x1 1.56x, 1024x2 0.89x, 1024x4 0.51x, 1024x8 0.31x, 1024x16 0.20x, 1024x32 0.20x, 1024x64 0.18x, 1536x1 1.99x, 1536x2 1.30x, 1536x4 0.71x, 2048x1 2.25x, 2048x2 1.47x, 2048x4 0.78x, 2560x1 2.29x, 3072x1 2.36x, 3584x1 2.19x, 4096x1 2.31x

Stage 4b: the band backend for eigenvalues alone

For eigenvalues alone, where the rules above choose the CPU or tridiag, the band backend (the two-stage reduction: A to a band on the GPU in blocks whose work is matrix products, the band to tridiagonal on the CPU’s cores, then bisection on the GPU) from a threshold N on (0: never), within tridiag’s batch cap, fitted on the 32 points where it was timed (N >= 512) against the CPU, tridiag and band.

Chosen: 1536 (in effect: 1536): 1.0135 geometric-mean regret, worst 1.21x; without band 1.0625, worst 1.62x.

Its band’s width: 16 (in effect: 16); geometric mean of each width’s time over the best width’s at each point: 8 1.137, 16 1.001, 32 1.332. 16, the default, unless another is better by more than 1%.

Thresholds within the fit’s tolerance of the best, and within 3% of it on the points where the two choose differently: 1536.

band over tridiag, N x batch: 512x1 0.91x, 512x2 1.09x, 512x4 1.17x, 512x8 1.23x, 512x16 1.24x, 512x32 1.27x, 512x64 1.29x, 512x128 1.29x, 768x1 0.90x, 768x2 1.02x, 768x4 1.12x, 768x8 1.20x, 768x16 1.25x, 768x32 1.25x, 768x64 1.24x, 1024x1 0.92x, 1024x2 1.00x, 1024x4 1.14x, 1024x8 1.21x, 1024x16 1.26x, 1024x32 1.29x, 1024x64 1.27x, 1536x1 1.00x, 1536x2 1.10x, 1536x4 1.21x, 2048x1 0.98x, 2048x2 1.17x, 2048x4 1.42x, 2560x1 1.17x, 3072x1 1.31x, 3584x1 1.47x, 4096x1 1.61x

band over the CPU, N x batch: 512x1 0.75x, 512x2 0.50x, 512x4 0.34x, 512x8 0.20x, 512x16 0.13x, 512x32 0.12x, 512x64 0.11x, 512x128 0.10x, 768x1 1.09x, 768x2 0.70x, 768x4 0.43x, 768x8 0.29x, 768x16 0.20x, 768x32 0.17x, 768x64 0.16x, 1024x1 1.44x, 1024x2 0.89x, 1024x4 0.59x, 1024x8 0.37x, 1024x16 0.25x, 1024x32 0.25x, 1024x64 0.22x, 1536x1 1.99x, 1536x2 1.43x, 1536x4 0.87x, 2048x1 2.21x, 2048x2 1.72x, 2048x4 1.11x, 2560x1 2.68x, 3072x1 3.09x, 3584x1 3.20x, 4096x1 3.71x

Stage 4c: the band backend with eigenvectors

With eigenvectors, where the rules above choose the CPU or tridiag, the band backend (the two-stage reduction, its reflectors and the chase’s applied to the eigenvectors on the GPU while the CPU chases and solves) from a threshold N on (0: never), within tridiag’s batch cap, fitted on the 68 points where it was timed (N >= 512) against the CPU, tridiag and band.

Chosen: 512 (in effect: [2560, 4]): 1.0116 geometric-mean regret, worst 1.28x; without band 1.1469, worst 3.79x.

Thresholds within the fit’s tolerance of the best, and within 3% of it on the points where the two choose differently: [512, 0], [512, 128], [512, 256], [512, 512].

band over tridiag, N x batch: 512x1 1.11x, 512x2 1.62x, 512x4 2.66x, 512x8 4.04x, 512x16 5.90x, 512x32 8.03x, 512x64 8.67x, 512x128 9.49x, 768x1 1.04x, 768x2 1.53x, 768x4 2.16x, 768x8 3.07x, 768x16 4.08x, 768x32 4.44x, 768x64 5.24x, 1024x1 1.03x, 1024x2 1.23x, 1024x4 1.87x, 1024x8 2.46x, 1024x16 3.23x, 1024x32 3.61x, 1024x64 3.79x, 1536x1 1.01x, 1536x2 0.85x, 1536x4 0.78x, 2048x1 1.04x, 2048x2 0.86x, 2048x4 0.84x, 2560x1 1.12x, 3072x1 1.20x, 3584x1 1.28x, 4096x1 1.36x

band over the CPU, N x batch: 512x1 1.10x, 512x2 1.04x, 512x4 0.94x, 512x8 1.17x, 512x16 1.06x, 512x32 1.35x, 512x64 1.36x, 512x128 1.49x, 768x1 1.26x, 768x2 1.25x, 768x4 1.20x, 768x8 1.30x, 768x16 1.15x, 768x32 1.17x, 768x64 1.38x, 1024x1 1.94x, 1024x2 1.57x, 1024x4 2.22x, 1024x8 1.99x, 1024x16 1.89x, 1024x32 2.14x, 1024x64 2.27x, 1536x1 2.68x, 1536x2 1.42x, 1536x4 1.11x, 2048x1 3.92x, 2048x2 2.58x, 2048x4 1.83x, 2560x1 4.35x, 3072x1 5.91x, 3584x1 7.36x, 4096x1 11.07x

Stage 5: the tridiag_batch backend for batches of mid-size matrices

Where the rules above choose the CPU, the tridiag_batch backend (the tridiag method for a whole batch at once: the reduction of every matrix by the same dispatches, the tridiagonal problems on the CPU’s cores, the back-transformation as batched products) for N in a window from a batch on, fitted on the points where it was timed (N 48-1024, batches from 16) against the CPU and whatever else the CPU’s side would pick. Inside the flat region the window in effect stays; otherwise the smallest worst case, then the largest batch and the narrowest window.

With eigenvectors (68 points): N 96-1024 from batch 128 (in effect: N 96-256 from batch 256): 1.0132 geometric-mean regret, worst 1.32x; without it 1.2707, worst 1.98x. Held out: the window fitted on half the points, [96, 1024, 64], scores 1.0317 on the other half, against 1.1883 without it.

tridiag_batch over the CPU, N x batch: 48x16 0.24x, 48x32 0.32x, 48x64 0.36x, 48x128 0.57x, 64x16 0.26x, 64x32 0.38x, 64x64 0.51x, 64x128 0.72x, 96x16 0.33x, 96x32 0.48x, 96x64 0.66x, 96x128 0.86x, 96x256 0.87x, 96x512 1.16x, 96x1024 1.35x, 96x2048 1.42x, 96x4096 1.45x, 128x16 0.57x, 128x32 0.64x, 128x64 0.86x, 128x128 0.94x, 128x256 1.23x, 128x512 1.41x, 128x1024 1.56x, 128x2048 1.86x, 128x4096 1.63x, 192x16 0.74x, 192x32 0.86x, 192x64 0.95x, 192x128 1.28x, 192x256 1.43x, 192x512 1.59x, 192x1024 1.59x, 192x2048 1.45x, 192x4096 1.52x, 256x16 0.76x, 256x32 1.00x, 256x64 1.32x, 256x128 1.47x, 256x256 1.55x, 256x512 1.76x, 256x1024 1.65x, 256x2048 1.71x, 256x4096 1.98x, 384x16 0.88x, 384x32 1.06x, 384x64 1.11x, 384x128 1.34x, 384x256 1.31x, 384x512 1.46x, 384x1024 1.49x, 384x2048 1.47x, 512x16 1.06x, 512x32 1.24x, 512x64 1.33x, 512x128 1.40x, 512x256 1.38x, 512x512 1.48x, 512x1024 1.52x, 768x16 1.13x, 768x32 1.20x, 768x64 1.29x, 768x128 1.20x, 768x256 1.21x, 1024x16 1.89x, 1024x32 2.17x, 1024x64 1.78x, 1024x128 2.01x

Eigenvalues alone (68 points): N 96-256 from batch 256 (in effect: N 96-128 from batch 128): 1.0003 geometric-mean regret, worst 1.02x; without it 1.0864, worst 1.74x. Held out: the window fitted on half the points, [96, 256, 256], scores 1.0000 on the other half, against 1.0866 without it.

tridiag_batch over the CPU, N x batch: 48x16 0.29x, 48x32 0.32x, 48x64 0.40x, 48x128 0.55x, 64x16 0.28x, 64x32 0.34x, 64x64 0.41x, 64x128 0.64x, 96x16 0.32x, 96x32 0.46x, 96x64 0.65x, 96x128 0.94x, 96x256 1.08x, 96x512 1.30x, 96x1024 1.51x, 96x2048 1.48x, 96x4096 1.74x, 128x16 0.33x, 128x32 0.49x, 128x64 0.74x, 128x128 0.94x, 128x256 1.23x, 128x512 1.41x, 128x1024 1.55x, 128x2048 1.62x, 128x4096 1.52x, 192x16 0.56x, 192x32 0.63x, 192x64 0.88x, 192x128 0.97x, 192x256 1.08x, 192x512 1.22x, 192x1024 1.30x, 192x2048 1.49x, 192x4096 1.44x, 256x16 0.65x, 256x32 0.82x, 256x64 0.81x, 256x128 0.90x, 256x256 0.98x, 256x512 1.13x, 256x1024 1.16x, 256x2048 1.16x, 256x4096 1.41x, 384x16 0.61x, 384x32 0.68x, 384x64 0.64x, 384x128 0.80x, 384x256 0.82x, 384x512 0.91x, 384x1024 0.92x, 384x2048 0.88x, 512x16 0.68x, 512x32 0.73x, 512x64 0.66x, 512x128 0.72x, 512x256 0.68x, 512x512 0.79x, 512x1024 0.76x, 768x16 0.71x, 768x32 0.66x, 768x64 0.63x, 768x128 0.59x, 768x256 0.56x, 1024x16 0.58x, 1024x32 0.62x, 1024x64 0.56x, 1024x128 0.56x

Noise floor

Pass-to-pass ratio (max/min of the same measurement across passes), 854 measurements: median 1.021, p90 1.104, max 1.85. The held-out verdicts use a bootstrap rather than this figure, since a mean over many points is far less noisy than one measurement.

runtime n median p90 max
<1 ms 248 1.031 1.141 1.85
1-3 ms 90 1.023 1.144 1.47
3-10 ms 118 1.020 1.116 1.53
10-30 ms 118 1.018 1.076 1.36
30-100 ms 132 1.014 1.058 1.22
>100 ms 148 1.016 1.055 1.34