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 3.9/18 at the start, load 4.7/18 at the end; power mains.

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

Generated by tuning/tune_eigh.py from 207 (N, batch) points, N in [2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096], 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, 96, 0, 0,   16, 8192, 1,   48, 16384, 1,   1024, 1024, 4, 2,   2, 64,   4096,   48, 256,   2048, 16},

To try it without rebuilding:

EIGH_SIMD_MAX_N=0 EIGH_BLOCK_MIN_N=96 EIGH_BLOCK_MIN_N_BATCHED=0 EIGH_BLOCK_MIN_BATCH=0 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=4 EIGH_VALUES_TRIDIAG_MAX_BATCH=2 EIGH_QL_MIN_N=2 EIGH_QL_MAX_N=64 EIGH_SHARE_MIN_BATCH=4096 EIGH_GPU_BIG_BATCH_MAX_N=48 EIGH_GPU_BIG_BATCH_MIN=256 EIGH_VALUES_BAND_MIN_N=2048 EIGH_VALUES_BAND_WIDTH=16 EIGH_VALUES_GPU_MAX_N=48 EIGH_VALUES_GPU_MIN_BATCH_TIMES_N=16384 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.0231 geometric-mean regret, worst 1.82x, 11 of 207 points losing more than 10%, and 1.004x 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 207 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.0195 1.64x 10 1.003 0
fitted (‘0’, ‘96’, ‘none’, ‘none’) 1.0195 1.64x 10 1.003 0

4 of 144 (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.

xychart-beta
    title "Regret by block_min_n"
    x-axis "block_min_n" [32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, none]
    y-axis "geometric-mean regret" 1.0 --> 2.63
    line [1.1977, 1.1019, 1.0367, 1.0195, 1.0436, 1.1138, 1.2383, 1.3780, 1.5459, 1.7163, 1.9240, 2.1035, 2.2382, 2.3804, 2.4372, 2.4952, 2.5547, 2.6157]
block_min_n 32 48 64 96 128 192 256 384 512 768 1024 1536 2048 2560 3072 3584 4096 none
geomean 1.1977 1.1019 1.0367 1.0195 1.0436 1.1138 1.2383 1.3780 1.5459 1.7163 1.9240 2.1035 2.2382 2.3804 2.4372 2.4952 2.5547 2.6157
worst 8.59x 4.74x 2.69x 1.64x 1.99x 2.46x 4.60x 5.83x 9.91x 16.14x 16.14x 16.14x 16.14x 16.14x 16.14x 16.14x 16.14x 16.14x
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.18
    line [1.0195, 1.0219, 1.0227, 1.0234, 1.0346, 1.0517, 1.0953, 1.1630]
simd_max_n 0 2 4 8 12 16 24 32
geomean 1.0195 1.0219 1.0227 1.0234 1.0346 1.0517 1.0953 1.1630
worst 1.64x 1.64x 1.64x 1.64x 1.64x 1.64x 3.15x 5.20x

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

rule fitted on train train geomean test geomean test worst verdict
two constants [0, 96, 1000000000, 1000000000] 1.0132 1.0273 1.64x baseline
batch-dependent block crossover {“block_lo”: 64, “batch_hi”: 32} 1.0028 1.0087 1.93x rejected (better in 93% of resamples, median gain 1.9%)

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     t     q     q     t     t     q     q     t     q     q     q     q     t
          4     t     q     q     q     q     q     t     s     t     q     q     q     q
          8     t     t     t     q     t     q     s     q     q     q     s     s     s
         12     t     t     t     t     t     t     t     q     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     t     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     t     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
        128     B     B     B     B     B     B     B     B     B     B     B     B     B
        192     B     B     B     B     B     B     B     B     B     B     B     B     B
        256     B     B     B     B     B     B     B     B     B     B     B     .     .
        384     B     B     B     B     B     B     B     B     B     B     .     .     .
        512     B     B     B     B     B     B     B     B     .     .     .     .     .
        768     B     B     B     B     B     B     B     .     .     .     .     .     .
       1024     B     B     B     B     B     .     .     .     .     .     .     .     .
       1536     B     B     B     .     .     .     .     .     .     .     .     .     .
       2048     B     B     B     .     .     .     .     .     .     .     .     .     .
       2560     B     .     .     .     .     .     .     .     .     .     .     .     .
       3072     B     .     .     .     .     .     .     .     .     .     .     .     .
       3584     B     .     .     .     .     .     .     .     .     .     .     .     .
       4096     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     B     B     B     B     B     B     B     B     B     B     B     B     B
        128     B     B     B     B     B     B     B     B     B     B     B     B     B
        192     B     B     B     B     B     B     B     B     B     B     B     B     B
        256     B     B     B     B     B     B     B     B     B     B     B     .     .
        384     B     B     B     B     B     B     B     B     B     B     .     .     .
        512     B     B     B     B     B     B     B     B     .     .     .     .     .
        768     B     B     B     B     B     B     B     .     .     .     .     .     .
       1024     B     B     B     B     B     .     .     .     .     .     .     .     .
       1536     B     B     B     .     .     .     .     .     .     .     .     .     .
       2048     B     B     B     .     .     .     .     .     .     .     .     .     .
       2560     B     .     .     .     .     .     .     .     .     .     .     .     .
       3072     B     .     .     .     .     .     .     .     .     .     .     .     .
       3584     B     .     .     .     .     .     .     .     .     .     .     .     .
       4096     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 207 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.1664 4.02x 42 1.009 0
with ql for N in (2, 64) 1.0474 1.74x 33 1.000 0

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

Held out: fitted on 114 points (window (2, 64)), scored on the other 93: geomean 1.0558x, worst 1.57x, against 1.1673x, worst 4.02x without ql.

ql over the best Jacobi backend, N x batch: 2x1 0.98x, 2x2 1.02x, 2x4 1.06x, 2x8 0.95x, 2x16 0.92x, 2x32 1.02x, 2x64 1.03x, 2x128 0.98x, 2x256 1.04x, 2x512 1.00x, 2x1024 1.01x, 2x2048 1.01x, 2x4096 0.98x, 4x1 0.97x, 4x2 1.04x, 4x4 1.04x, 4x8 1.01x, 4x16 1.04x, 4x32 1.02x, 4x64 0.97x, 4x128 0.99x, 4x256 1.00x, 4x512 1.02x, 4x1024 1.03x, 4x2048 1.07x, 4x4096 1.06x, 8x1 0.99x, 8x2 0.94x, 8x4 0.89x, 8x8 1.02x, 8x16 0.97x, 8x32 1.04x, 8x64 0.96x, 8x128 1.02x, 8x256 1.02x, 8x512 1.04x, 8x1024 0.98x, 8x2048 0.95x, 8x4096 0.95x, 12x1 0.76x, 12x2 0.92x, 12x4 0.96x, 12x8 0.97x, 12x16 0.98x, 12x32 0.96x, 12x64 0.96x, 12x128 1.00x, 12x256 1.23x, 12x512 1.24x, 12x1024 1.34x, 12x2048 1.37x, 12x4096 1.38x, 16x1 0.92x, 16x2 0.84x, 16x4 0.90x, 16x8 0.81x, 16x16 0.84x, 16x32 0.85x, 16x64 0.88x, 16x128 1.00x, 16x256 1.27x, 16x512 1.41x, 16x1024 1.56x, 16x2048 1.45x, 16x4096 1.54x, 24x1 0.74x, 24x2 0.77x, 24x4 0.73x, 24x8 0.72x, 24x16 0.71x, 24x32 0.72x, 24x64 0.90x, 24x128 1.26x, 24x256 1.98x, 24x512 2.09x, 24x1024 2.16x, 24x2048 2.42x, 24x4096 2.61x, 32x1 0.58x, 32x2 0.64x, 32x4 0.63x, 32x8 0.64x, 32x16 0.68x, 32x32 0.82x, 32x64 1.06x, 32x128 1.81x, 32x256 2.74x, 32x512 2.38x, 32x1024 2.98x, 32x2048 3.23x, 32x4096 3.56x, 48x1 0.85x, 48x2 0.80x, 48x4 0.82x, 48x8 0.81x, 48x16 0.80x, 48x32 1.06x, 48x64 1.80x, 48x128 2.74x, 48x256 2.65x, 48x512 3.47x, 48x1024 3.56x, 48x2048 3.74x, 48x4096 4.02x, 64x1 0.92x, 64x2 0.93x, 64x4 0.92x, 64x8 0.91x, 64x16 0.89x, 64x32 1.30x, 64x64 2.39x, 64x128 2.17x, 64x256 2.12x, 64x512 2.17x, 64x1024 2.16x, 64x2048 2.29x, 64x4096 2.30x

Stage 1c: sharing a batch with the CPU

From a batch 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 4096.

rule geomean regret worst >10% total time / oracle est. picks
ql alone 1.0945 1.90x 18 1.472 0
shared from batch 4096 1.0901 1.88x 16 1.226 0

ql_share over ql alone, N x batch: 2x64 1.03x, 2x128 1.13x, 2x256 0.52x, 2x512 0.51x, 2x1024 0.50x, 2x2048 0.52x, 2x4096 0.56x, 4x64 1.14x, 4x128 0.97x, 4x256 0.59x, 4x512 0.53x, 4x1024 0.53x, 4x2048 0.59x, 4x4096 0.65x, 8x64 1.23x, 8x128 0.58x, 8x256 0.55x, 8x512 0.58x, 8x1024 0.75x, 8x2048 0.62x, 8x4096 0.87x, 12x64 0.66x, 12x128 0.62x, 12x256 0.57x, 12x512 0.65x, 12x1024 0.60x, 12x2048 0.88x, 12x4096 1.09x, 16x64 0.73x, 16x128 0.70x, 16x256 0.65x, 16x512 0.73x, 16x1024 0.76x, 16x2048 1.05x, 16x4096 1.12x, 24x64 0.75x, 24x128 0.75x, 24x256 0.74x, 24x512 0.62x, 24x1024 1.00x, 24x2048 1.05x, 24x4096 1.10x, 32x64 0.81x, 32x128 0.81x, 32x256 0.82x, 32x512 0.84x, 32x1024 1.06x, 32x2048 1.06x, 32x4096 1.11x, 48x64 0.87x, 48x128 0.91x, 48x256 1.60x, 48x512 1.26x, 48x1024 1.29x, 48x2048 1.35x, 48x4096 1.45x, 64x64 0.89x, 64x128 0.95x, 64x256 1.36x, 64x512 1.48x, 64x1024 1.78x, 64x2048 1.88x, 64x4096 1.90x

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 (‘32’, ‘16384’, ‘1’) 1.0290 1.88x 16 1.003 0
fitted (‘16’, ‘8192’, ‘1’) 1.0231 1.82x 11 1.004 0

Large batches: the GPU also for N above gpu_max_n up to 48 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.0565, worst 2.31x; chosen 1.0231, worst 1.82x).

30 of 1320 combinations are within 0.5% of the best geomean: gpu_max_n 48 .. 64, gpu_min_batch_times_n 4096 .. 16384, 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.57
    line [1.5537, 1.1843, 1.1234, 1.0803, 1.0544, 1.0421, 1.0314, 1.0243, 1.0231, 1.0244, 1.0380]
gpu_min_batch_times_n 0 64 128 256 512 1024 2048 4096 8192 16384 none
geomean 1.5537 1.1843 1.1234 1.0803 1.0544 1.0421 1.0314 1.0243 1.0231 1.0244 1.0380
worst 123.08x 12.15x 7.00x 4.24x 3.24x 2.03x 1.82x 1.82x 1.82x 1.75x 2.00x
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.04
    line [1.0231, 1.0231, 1.0231, 1.0231, 1.0231, 1.0231]
gpu_min_batch 1 2 4 8 16 32
geomean 1.0231 1.0231 1.0231 1.0231 1.0231 1.0231
worst 1.82x 1.82x 1.82x 1.82x 1.82x 1.82x
xychart-beta
    title "Regret by gpu_max_n"
    x-axis "gpu_max_n" [16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, none]
    y-axis "geometric-mean regret" 1.0 --> 1.50
    line [1.0231, 1.0242, 1.0242, 1.0242, 1.0279, 1.0650, 1.1194, 1.1897, 1.2578, 1.3296, 1.3901, 1.4431, 1.4738, 1.4738, 1.4861, 1.4861, 1.4861, 1.4861, 1.4861, 1.4861]
gpu_max_n 16 24 32 48 64 96 128 192 256 384 512 768 1024 1536 2048 2560 3072 3584 4096 none
geomean 1.0231 1.0242 1.0242 1.0242 1.0279 1.0650 1.1194 1.1897 1.2578 1.3296 1.3901 1.4431 1.4738 1.4738 1.4861 1.4861 1.4861 1.4861 1.4861 1.4861
worst 1.82x 1.82x 1.82x 1.82x 1.88x 3.75x 4.77x 6.86x 7.89x 10.85x 11.47x 14.22x 14.22x 14.22x 14.22x 14.22x 14.22x 14.22x 14.22x 14.22x

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 114 points, scored on the other 93.

rule fitted on train train geomean test geomean test worst verdict
product rule [16, 16384, 1] 1.0223 1.0271 1.75x baseline
per-N table {“min_batch_by_n”: {“2”: null, “4”: null, “8”: null, “12”: 512, “16”: 512, “24”: 256, “32”: 256, “48”: 512, “64”: null, “96”: null, “128”: null, “192”: null, “256”: null, “384”: null, “512”: null, “768”: null, “1024”: null, “1536”: null, “2048”: null, “2560”: null, “3072”: null, “3584”: null, “4096”: null}} 1.0182 1.0300 1.75x rejected (better in 24% of resamples, median gain -0.3%)

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     c     c     c     t
          4     c     c     c     c     c     c     c     c     c     c     c     q     q
          8     c     c     c     c     c     c     Q     c     c     c     s     s     s
         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     c     Q     Q     Q     Q
         96     c     c     c     c     c     c     c     c     c     c     c     c     c
        128     c     c     c     c     c     c     c     c     c     c     c     c     c
        192     c     c     c     c     c     c     c     c     c     c     c     c     c
        256     c     c     c     c     c     c     c     c     c     c     c     .     .
        384     c     c     c     c     c     c     c     c     c     c     .     .     .
        512     c     c     c     c     c     c     c     c     .     .     .     .     .
        768     c     c     c     c     c     c     c     .     .     .     .     .     .
       1024     c     c     c     c     c     .     .     .     .     .     .     .     .
       1536     c     c     c     .     .     .     .     .     .     .     .     .     .
       2048     c     c     c     .     .     .     .     .     .     .     .     .     .
       2560     c     .     .     .     .     .     .     .     .     .     .     .     .
       3072     c     .     .     .     .     .     .     .     .     .     .     .     .
       3584     c     .     .     .     .     .     .     .     .     .     .     .     .
       4096     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     c     c     c     c     c
         96     c     c     c     c     c     c     c     c     c     c     c     c     c
        128     c     c     c     c     c     c     c     c     c     c     c     c     c
        192     c     c     c     c     c     c     c     c     c     c     c     c     c
        256     c     c     c     c     c     c     c     c     c     c     c     .     .
        384     c     c     c     c     c     c     c     c     c     c     .     .     .
        512     c     c     c     c     c     c     c     c     .     .     .     .     .
        768     c     c     c     c     c     c     c     .     .     .     .     .     .
       1024     c     c     c     c     c     .     .     .     .     .     .     .     .
       1536     c     c     c     .     .     .     .     .     .     .     .     .     .
       2048     c     c     c     .     .     .     .     .     .     .     .     .     .
       2560     c     .     .     .     .     .     .     .     .     .     .     .     .
       3072     c     .     .     .     .     .     .     .     .     .     .     .     .
       3584     c     .     .     .     .     .     .     .     .     .     .     .     .
       4096     c     .     .     .     .     .     .     .     .     .     .     .     .
  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2  0.01  0.02  0.04  0.05  0.06  0.11  0.22  0.39  0.75  0.85  0.73  0.91  1.21
          4  0.01  0.03  0.06  0.05  0.11  0.21  0.41  0.79  0.67  0.75  0.90  1.17  1.38
          8  0.02  0.04  0.09  0.13  0.23  0.49  0.89  0.63  0.75  0.90  1.09  1.40  1.52
         12  0.03  0.07  0.10  0.14  0.20  0.38  0.59  0.67  0.88  1.09  1.27  1.42  1.56
         16  0.04  0.09  0.09  0.18  0.28  0.36  0.56  0.67  0.99  1.24  1.38  1.51  1.79
         24  0.09  0.12  0.13  0.24  0.38  0.53  0.58  0.82  1.24  1.45  1.59  1.95  2.10
         32  0.11  0.13  0.13  0.24  0.41  0.39  0.48  0.76  1.19  1.21  1.67  1.98  2.06
         48  0.11  0.13  0.13  0.26  0.29  0.35  0.51  0.88  0.95  1.44  1.37  1.39  1.44
         64  0.11  0.13  0.13  0.21  0.24  0.33  0.52  0.53  0.70  0.86  0.92  0.93  0.90
         96  0.08  0.08  0.09  0.11  0.14  0.16  0.21  0.27  0.33  0.30  0.30  0.31  0.28
        128  0.08  0.09  0.10  0.11  0.12  0.18  0.22  0.25  0.24  0.23  0.22  0.22  0.21
        192  0.13  0.13  0.13  0.14  0.16  0.21  0.20  0.18  0.17  0.16  0.16  0.15  0.15
        256  0.20  0.18  0.18  0.18  0.17  0.19  0.16  0.14  0.13  0.13  0.13     .     .
        384  0.22  0.20  0.20  0.19  0.14  0.12  0.10  0.10  0.09  0.09     .     .     .
        512  0.30  0.26  0.23  0.19  0.13  0.10  0.09  0.09     .     .     .     .     .
        768  0.30  0.28  0.20  0.12  0.08  0.08  0.07     .     .     .     .     .     .
       1024  0.39  0.32  0.18  0.12  0.11     .     .     .     .     .     .     .     .
       1536  0.39  0.24  0.12     .     .     .     .     .     .     .     .     .     .
       2048  0.38  0.26  0.18     .     .     .     .     .     .     .     .     .     .
       2560  0.29     .     .     .     .     .     .     .     .     .     .     .     .
       3072  0.33     .     .     .     .     .     .     .     .     .     .     .     .
       3584  0.35     .     .     .     .     .     .     .     .     .     .     .     .
       4096  0.48     .     .     .     .     .     .     .     .     .     .     .     .

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 207 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.0492 3.75x 22 1.406 0
eigh’s fitted boundary 1.0638 3.75x 31 1.406 0
fitted (‘48’, ‘16384’, ‘1’) 1.0492 3.75x 22 1.406 0

144 combinations are within 0.5% of the best geomean: values_gpu_max_n 16 .. none, values_gpu_min_batch_times_n 16384 .. none, values_gpu_min_batch 1 .. 32.

Held out: fitted on 114 points (‘48’, ‘16384’, ‘1’), scored on the other 93: geomean 1.0310x, worst 1.57x, against 1.0449x, worst 1.76x 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.0116 1.50x 1.2566 8.86x from 768, batch <= 4: 1.0195 vs 1.0971
eigenvalues alone 1024 2 1.0181 1.60x 1.1133 3.75x from 1536, batch <= 2: 1.0162 vs 1.0460

tridiag over the CPU (with eigenvectors), N x batch: 128x1 0.30x, 128x2 0.19x, 128x4 0.10x, 128x8 0.06x, 128x16 0.04x, 128x32 0.03x, 128x64 0.03x, 128x128 0.03x, 128x256 0.03x, 128x512 0.03x, 192x1 0.48x, 192x2 0.28x, 192x4 0.15x, 192x8 0.09x, 192x16 0.06x, 192x32 0.06x, 192x64 0.05x, 192x128 0.05x, 192x256 0.04x, 256x1 0.69x, 256x2 0.38x, 256x4 0.21x, 256x8 0.13x, 256x16 0.08x, 256x32 0.07x, 256x64 0.07x, 256x128 0.06x, 256x256 0.06x, 384x1 0.85x, 384x2 0.52x, 384x4 0.30x, 384x8 0.18x, 384x16 0.12x, 384x32 0.11x, 384x64 0.10x, 384x128 0.10x, 512x1 1.16x, 512x2 0.79x, 512x4 0.44x, 512x8 0.27x, 512x16 0.18x, 512x32 0.17x, 512x64 0.16x, 512x128 0.16x, 768x1 1.50x, 768x2 1.07x, 768x4 0.58x, 768x8 0.39x, 768x16 0.28x, 768x32 0.27x, 768x64 0.26x, 1024x1 2.30x, 1024x2 1.60x, 1024x4 0.88x, 1024x8 0.65x, 1024x16 0.61x, 1536x1 3.14x, 1536x2 2.14x, 1536x4 1.22x, 2048x1 4.46x, 2048x2 3.58x, 2048x4 2.48x, 2560x1 4.66x, 3072x1 5.80x, 3584x1 6.58x, 4096x1 8.86x

tridiag over the CPU (eigenvalues alone), N x batch: 128x1 0.24x, 128x2 0.14x, 128x4 0.08x, 128x8 0.05x, 128x16 0.03x, 128x32 0.02x, 128x64 0.02x, 128x128 0.02x, 128x256 0.02x, 128x512 0.02x, 192x1 0.34x, 192x2 0.19x, 192x4 0.10x, 192x8 0.06x, 192x16 0.05x, 192x32 0.04x, 192x64 0.03x, 192x128 0.03x, 192x256 0.03x, 256x1 0.44x, 256x2 0.24x, 256x4 0.13x, 256x8 0.08x, 256x16 0.05x, 256x32 0.05x, 256x64 0.04x, 256x128 0.04x, 256x256 0.04x, 384x1 0.60x, 384x2 0.33x, 384x4 0.19x, 384x8 0.12x, 384x16 0.08x, 384x32 0.07x, 384x64 0.06x, 384x128 0.06x, 512x1 0.82x, 512x2 0.49x, 512x4 0.26x, 512x8 0.17x, 512x16 0.11x, 512x32 0.10x, 512x64 0.09x, 512x128 0.08x, 768x1 1.22x, 768x2 0.69x, 768x4 0.43x, 768x8 0.25x, 768x16 0.17x, 768x32 0.14x, 768x64 0.13x, 1024x1 1.57x, 1024x2 0.87x, 1024x4 0.55x, 1024x8 0.32x, 1024x16 0.21x, 1536x1 2.05x, 1536x2 1.31x, 1536x4 0.70x, 2048x1 2.25x, 2048x2 1.55x, 2048x4 0.80x, 2560x1 2.28x, 3072x1 2.35x, 3584x1 2.27x, 4096x1 2.35x

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 30 points where it was timed (N >= 512) against the CPU, tridiag and band.

Chosen: 2048 (in effect: 2048): 1.0184 geometric-mean regret, worst 1.22x; without band 1.0620, worst 1.60x.

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.127, 16 1.002, 32 1.324. 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, 2048.

band over tridiag, N x batch: 512x1 0.92x, 512x2 0.96x, 512x4 1.10x, 512x8 1.15x, 512x16 1.20x, 512x32 1.23x, 512x64 1.24x, 512x128 1.24x, 768x1 0.89x, 768x2 1.03x, 768x4 1.08x, 768x8 1.14x, 768x16 1.14x, 768x32 1.20x, 768x64 1.19x, 1024x1 0.89x, 1024x2 1.01x, 1024x4 1.12x, 1024x8 1.16x, 1024x16 1.21x, 1536x1 0.93x, 1536x2 1.10x, 1536x4 1.20x, 2048x1 0.98x, 2048x2 1.15x, 2048x4 1.34x, 2560x1 1.14x, 3072x1 1.27x, 3584x1 1.39x, 4096x1 1.55x

band over the CPU, N x batch: 512x1 0.75x, 512x2 0.47x, 512x4 0.29x, 512x8 0.19x, 512x16 0.13x, 512x32 0.12x, 512x64 0.11x, 512x128 0.10x, 768x1 1.09x, 768x2 0.71x, 768x4 0.47x, 768x8 0.28x, 768x16 0.20x, 768x32 0.17x, 768x64 0.15x, 1024x1 1.40x, 1024x2 0.89x, 1024x4 0.61x, 1024x8 0.37x, 1024x16 0.25x, 1536x1 1.92x, 1536x2 1.43x, 1536x4 0.84x, 2048x1 2.20x, 2048x2 1.78x, 2048x4 1.07x, 2560x1 2.60x, 3072x1 2.99x, 3584x1 3.15x, 4096x1 3.65x

Noise floor

Pass-to-pass ratio (max/min of the same measurement across passes), 1766 measurements: median 1.012, p90 1.071, max 2.59. 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 818 1.023 1.140 2.59
1-3 ms 177 1.007 1.038 1.43
3-10 ms 208 1.008 1.037 1.15
10-30 ms 169 1.008 1.028 1.05
30-100 ms 175 1.007 1.030 1.10
>100 ms 219 1.004 1.018 1.13