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.14, cpu x0.10, whole-matrix x1.00 (1.00 is an M1).

Machine state: load 3.1/18 at the start, load 5.1/18 at the end; power mains.

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

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

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=48 EIGH_GPU_MIN_BATCH_TIMES_N=16384 EIGH_GPU_MIN_BATCH=1 EIGH_TRIDIAG_MIN_N=1024 EIGH_VALUES_TRIDIAG_MIN_N=1536 EIGH_TRIDIAG_MAX_BATCH=4 EIGH_VALUES_TRIDIAG_MAX_BATCH=2 EIGH_QL_MIN_N=12 EIGH_QL_MAX_N=64 EIGH_SHARE_MIN_BATCH=1024 EIGH_GPU_BIG_BATCH_MAX_N=64 EIGH_GPU_BIG_BATCH_MIN=1024 EIGH_VALUES_BAND_MIN_N=4096 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.0095 geometric-mean regret, worst 1.35x, 8 of 205 points losing more than 10%, and 1.000x 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 205 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 (‘8’, ‘96’, ‘none’, ‘none’) 1.0277 1.76x 17 1.003 0
fitted (‘0’, ‘96’, ‘none’, ‘none’) 1.0186 1.57x 10 1.003 0

3 of 128 (simd_max_n, block_min_n) pairs are within 0.5% of the best geomean: simd_max_n 0 .. 4, 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, 3072, 4096, none]
    y-axis "geometric-mean regret" 1.0 --> 2.54
    line [1.1951, 1.1013, 1.0369, 1.0186, 1.0432, 1.1130, 1.2388, 1.3805, 1.5499, 1.7232, 1.9359, 2.1199, 2.2580, 2.4049, 2.4633, 2.5231]
block_min_n 32 48 64 96 128 192 256 384 512 768 1024 1536 2048 3072 4096 none
geomean 1.1951 1.1013 1.0369 1.0186 1.0432 1.1130 1.2388 1.3805 1.5499 1.7232 1.9359 2.1199 2.2580 2.4049 2.4633 2.5231
worst 8.60x 4.71x 2.64x 1.57x 1.93x 2.24x 4.49x 6.04x 10.01x 15.74x 15.74x 15.74x 15.74x 15.74x 15.74x 15.74x
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.0186, 1.0207, 1.0223, 1.0277, 1.0417, 1.0601, 1.1021, 1.1683]
simd_max_n 0 2 4 8 12 16 24 32
geomean 1.0186 1.0207 1.0223 1.0277 1.0417 1.0601 1.1021 1.1683
worst 1.57x 1.57x 1.57x 1.76x 2.63x 2.63x 3.06x 4.85x

Held-out check of a batch-dependent crossover (block from a lower N once the batch is large enough). Fitted on 112 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.0229 1.0134 1.53x baseline
batch-dependent block crossover {“block_lo”: 64, “batch_hi”: 128} 1.0026 1.0071 1.49x rejected (better in 78% of resamples, median gain 0.6%)

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     q     q     t     t     q     q     t     q     q     q     q     s
          4     q     q     s     q     s     t     q     q     q     s     q     q     q
          8     t     s     q     q     t     t     q     t     s     t     s     s     s
         12     t     t     t     t     t     t     q     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     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     .     .     .     .     .     .     .     .     .     .
       3072     B     .     .     .     .     .     .     .     .     .     .     .     .
       4096     B     .     .     .     .     .     .     .     .     .     .     .     .
  N \ batch     1     2     4     8    16    32    64   128   256   512  1024  2048  4096
          2     t     t     t     t     t     t     t     t     t     t     t     t     t
          4     t     t     t     t     t     t     t     t     t     t     t     t     t
          8     t     t     t     t     t     t     t     t     t     t     t     t     t
         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     .     .     .     .     .     .     .     .     .     .
       3072     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 205 points against the best GPU backend, ql included. Chosen: N = 12 .. 64.

rule geomean regret worst >10% total time / oracle est. picks
without ql (the split alone) 1.1580 3.65x 48 1.010 0
with ql for N in (12, 64) 1.0474 1.62x 34 1.000 0

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

Held out: fitted on 112 points (window (2, 64)), scored on the other 93: geomean 1.0468x, worst 1.40x, against 1.1511x, worst 3.32x without ql.

ql over the best Jacobi backend, N x batch: 2x1 0.93x, 2x2 1.11x, 2x4 1.01x, 2x8 0.91x, 2x16 1.00x, 2x32 1.02x, 2x64 1.07x, 2x128 1.00x, 2x256 1.02x, 2x512 1.00x, 2x1024 1.07x, 2x2048 1.04x, 2x4096 1.00x, 4x1 1.06x, 4x2 1.09x, 4x4 0.95x, 4x8 1.03x, 4x16 0.96x, 4x32 0.97x, 4x64 1.22x, 4x128 1.27x, 4x256 1.03x, 4x512 0.94x, 4x1024 1.04x, 4x2048 1.11x, 4x4096 1.03x, 8x1 0.88x, 8x2 0.86x, 8x4 1.06x, 8x8 1.01x, 8x16 0.88x, 8x32 0.91x, 8x64 1.03x, 8x128 0.95x, 8x256 0.99x, 8x512 0.98x, 8x1024 0.96x, 8x2048 0.93x, 8x4096 0.96x, 12x1 0.95x, 12x2 0.92x, 12x4 0.87x, 12x8 0.95x, 12x16 0.95x, 12x32 0.96x, 12x64 1.00x, 12x128 1.00x, 12x256 1.19x, 12x512 1.19x, 12x1024 1.26x, 12x2048 1.40x, 12x4096 1.34x, 16x1 0.89x, 16x2 0.90x, 16x4 0.93x, 16x8 0.89x, 16x16 0.88x, 16x32 0.91x, 16x64 0.91x, 16x128 0.98x, 16x256 1.24x, 16x512 1.28x, 16x1024 1.48x, 16x2048 1.41x, 16x4096 1.46x, 24x1 0.77x, 24x2 0.77x, 24x4 0.69x, 24x8 0.75x, 24x16 0.74x, 24x32 0.76x, 24x64 0.92x, 24x128 1.19x, 24x256 1.93x, 24x512 1.93x, 24x1024 2.02x, 24x2048 2.17x, 24x4096 2.34x, 32x1 0.62x, 32x2 0.68x, 32x4 0.72x, 32x8 0.72x, 32x16 0.75x, 32x32 0.79x, 32x64 1.07x, 32x128 1.71x, 32x256 2.53x, 32x512 2.21x, 32x1024 2.72x, 32x2048 2.98x, 32x4096 3.05x, 48x1 0.80x, 48x2 0.81x, 48x4 0.85x, 48x8 0.81x, 48x16 0.87x, 48x32 1.13x, 48x64 1.76x, 48x128 2.68x, 48x256 2.48x, 48x512 3.11x, 48x1024 3.20x, 48x2048 3.32x, 48x4096 3.65x, 64x1 0.92x, 64x2 0.95x, 64x4 0.94x, 64x8 0.91x, 64x16 0.90x, 64x32 1.30x, 64x64 2.28x, 64x128 2.03x, 64x256 2.07x, 64x512 2.06x, 64x1024 2.17x, 64x2048 2.17x, 64x4096 2.16x

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 42 points where it was timed and ql is the GPU’s choice. Chosen: from batch 1024.

rule geomean regret worst >10% total time / oracle est. picks
ql alone 1.1334 1.94x 15 1.501 0
shared from batch 1024 1.0509 1.54x 7 1.043 0

ql_share over ql alone, N x batch: 12x64 0.70x, 12x128 0.69x, 12x256 0.62x, 12x512 0.74x, 12x1024 0.84x, 12x2048 0.88x, 12x4096 1.10x, 16x64 0.72x, 16x128 0.75x, 16x256 0.67x, 16x512 0.80x, 16x1024 0.78x, 16x2048 1.09x, 16x4096 1.13x, 24x64 0.81x, 24x128 0.82x, 24x256 0.76x, 24x512 0.65x, 24x1024 1.02x, 24x2048 1.08x, 24x4096 1.20x, 32x64 0.83x, 32x128 0.85x, 32x256 0.81x, 32x512 0.83x, 32x1024 1.10x, 32x2048 1.08x, 32x4096 1.19x, 48x64 0.87x, 48x128 0.88x, 48x256 1.54x, 48x512 1.23x, 48x1024 1.26x, 48x2048 1.41x, 48x4096 1.44x, 64x64 0.90x, 64x128 0.95x, 64x256 1.36x, 64x512 1.47x, 64x1024 1.72x, 64x2048 1.90x, 64x4096 1.94x

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 (‘48’, ‘16384’, ‘1’) 1.0095 1.35x 8 1.000 0
fitted (‘48’, ‘16384’, ‘1’) 1.0095 1.35x 8 1.000 0

Large batches: the GPU also for N above gpu_max_n up to 64 in a batch of at least 1024, 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.0165, worst 1.68x; chosen 1.0095, worst 1.35x).

24 of 1188 combinations are within 0.5% of the best geomean: gpu_max_n 48 .. 64, gpu_min_batch_times_n 8192 .. 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.87
    line [1.8511, 1.3465, 1.2350, 1.1542, 1.0982, 1.0609, 1.0323, 1.0159, 1.0092, 1.0095, 1.0487]
gpu_min_batch_times_n 0 64 128 256 512 1024 2048 4096 8192 16384 none
geomean 1.8511 1.3465 1.2350 1.1542 1.0982 1.0609 1.0323 1.0159 1.0092 1.0095 1.0487
worst 119.07x 11.75x 10.02x 5.88x 3.97x 3.00x 2.20x 1.54x 1.54x 1.35x 2.19x
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.0095, 1.0095, 1.0095, 1.0095, 1.0095, 1.0095]
gpu_min_batch 1 2 4 8 16 32
geomean 1.0095 1.0095 1.0095 1.0095 1.0095 1.0095
worst 1.35x 1.35x 1.35x 1.35x 1.35x 1.35x
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, 3072, 4096, none]
    y-axis "geometric-mean regret" 1.0 --> 1.37
    line [1.0107, 1.0107, 1.0102, 1.0095, 1.0123, 1.0433, 1.0885, 1.1479, 1.2031, 1.2589, 1.3027, 1.3362, 1.3509, 1.3509, 1.3509, 1.3509, 1.3509, 1.3509]
gpu_max_n 16 24 32 48 64 96 128 192 256 384 512 768 1024 1536 2048 3072 4096 none
geomean 1.0107 1.0107 1.0102 1.0095 1.0123 1.0433 1.0885 1.1479 1.2031 1.2589 1.3027 1.3362 1.3509 1.3509 1.3509 1.3509 1.3509 1.3509
worst 1.42x 1.42x 1.42x 1.35x 1.52x 3.62x 4.59x 6.54x 7.61x 10.55x 11.13x 14.00x 14.00x 14.00x 14.00x 14.00x 14.00x 14.00x

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

rule fitted on train train geomean test geomean test worst verdict
product rule [48, 16384, 1] 1.0099 1.0090 1.35x baseline
per-N table {“min_batch_by_n”: {“2”: 1024, “4”: 4096, “8”: null, “12”: 2048, “16”: 2048, “24”: 256, “32”: 512, “48”: 512, “64”: 2048, “96”: null, “128”: null, “192”: null, “256”: null, “384”: null, “512”: null, “768”: null, “1024”: null, “1536”: null, “2048”: null, “3072”: null, “4096”: null}} 1.0082 1.0183 1.48x rejected (better in 3% of resamples, median gain -0.8%)

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     q     c     s
          4     c     c     c     c     c     c     c     c     c     c     c     c     q
          8     c     c     c     c     c     c     c     c     c     c     s     s     s
         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     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     .     .     .     .     .     .     .     .     .     .
       3072     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     c
          4     c     c     c     c     c     c     c     c     c     c     c     c     t
          8     c     c     c     c     c     c     c     c     c     c     c     t     t
         12     c     c     c     c     c     c     c     c     c     c     c     Q     Q
         16     c     c     c     c     c     c     c     c     c     c     Q     Q     Q
         24     c     c     c     c     c     c     c     c     c     c     Q     Q     Q
         32     c     c     c     c     c     c     c     c     c     q     Q     Q     Q
         48     c     c     c     c     c     c     c     c     c     q     Q     Q     Q
         64     c     c     c     c     c     c     c     c     c     c     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     .     .     .     .     .     .     .     .     .     .
       3072     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.03  0.06  0.12  0.20  0.38  0.61  0.75  1.21  0.85  1.01
          4  0.01  0.03  0.05  0.12  0.11  0.22  0.37  0.71  0.49  0.72  0.81  0.98  1.19
          8  0.03  0.05  0.10  0.14  0.23  0.45  0.44  0.66  0.67  0.81  1.03  1.22  1.42
         12  0.03  0.08  0.10  0.15  0.28  0.34  0.62  0.60  0.79  0.94  1.10  1.27  1.40
         16  0.05  0.09  0.10  0.17  0.30  0.45  0.54  0.62  0.86  1.06  1.21  1.34  1.57
         24  0.08  0.11  0.14  0.27  0.35  0.47  0.52  0.68  1.08  1.26  1.42  1.87  1.82
         32  0.11  0.13  0.14  0.24  0.38  0.42  0.45  0.71  1.06  1.11  1.56  1.71  1.73
         48  0.12  0.14  0.15  0.25  0.29  0.33  0.50  0.85  0.88  1.15  1.26  1.32  1.34
         64  0.12  0.13  0.13  0.20  0.23  0.33  0.51  0.51  0.66  0.86  0.86  0.86  0.87
         96  0.08  0.09  0.09  0.11  0.14  0.16  0.21  0.30  0.31  0.30  0.29  0.28  0.28
        128  0.08  0.09  0.10  0.10  0.12  0.18  0.22  0.27  0.24  0.23  0.23  0.23  0.22
        192  0.13  0.13  0.13  0.15  0.16  0.19  0.21  0.19  0.16  0.16  0.16  0.15  0.15
        256  0.19  0.18  0.19  0.18  0.19  0.19  0.18  0.15  0.14  0.14  0.13     .     .
        384  0.22  0.20  0.21  0.19  0.14  0.13  0.10  0.10  0.10  0.09     .     .     .
        512  0.30  0.25  0.25  0.20  0.12  0.11  0.09  0.09     .     .     .     .     .
        768  0.30  0.28  0.21  0.13  0.08  0.08  0.07     .     .     .     .     .     .
       1024  0.39  0.34  0.19  0.12  0.11     .     .     .     .     .     .     .     .
       1536  0.40  0.24  0.12     .     .     .     .     .     .     .     .     .     .
       2048  0.41  0.26  0.16     .     .     .     .     .     .     .     .     .     .
       3072  0.32     .     .     .     .     .     .     .     .     .     .     .     .
       4096  0.49     .     .     .     .     .     .     .     .     .     .     .     .

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 205 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.0137 1.46x 12 1.004 0
eigh’s fitted boundary 1.0092 1.46x 9 1.001 0
fitted (‘48’, ‘16384’, ‘1’) 1.0137 1.46x 12 1.004 0

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

Held out: fitted on 112 points (‘48’, ‘16384’, ‘1’), scored on the other 93: geomean 1.0083x, worst 1.32x, against 1.0083x, worst 1.32x 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.0069 1.28x 1.1156 5.62x from 768, batch <= 2: 1.0225 vs 1.0350
eigenvalues alone 1536 2 1.0081 1.46x 1.0650 2.23x from 1536, batch <= 2: 1.0137 vs 1.0137

tridiag over the CPU (with eigenvectors), N x batch: 128x1 0.32x, 128x2 0.21x, 128x4 0.11x, 128x8 0.06x, 128x16 0.04x, 128x32 0.03x, 128x64 0.03x, 128x128 0.03x, 128x256 0.03x, 128x512 0.03x, 192x1 0.47x, 192x2 0.28x, 192x4 0.16x, 192x8 0.09x, 192x16 0.06x, 192x32 0.05x, 192x64 0.05x, 192x128 0.05x, 192x256 0.05x, 256x1 0.65x, 256x2 0.38x, 256x4 0.22x, 256x8 0.13x, 256x16 0.09x, 256x32 0.08x, 256x64 0.07x, 256x128 0.07x, 256x256 0.07x, 384x1 0.72x, 384x2 0.49x, 384x4 0.31x, 384x8 0.18x, 384x16 0.12x, 384x32 0.12x, 384x64 0.11x, 384x128 0.10x, 512x1 1.00x, 512x2 0.68x, 512x4 0.44x, 512x8 0.29x, 512x16 0.18x, 512x32 0.17x, 512x64 0.16x, 512x128 0.16x, 768x1 1.15x, 768x2 0.89x, 768x4 0.54x, 768x8 0.36x, 768x16 0.27x, 768x32 0.26x, 768x64 0.26x, 1024x1 1.58x, 1024x2 1.29x, 1024x4 0.78x, 1024x8 0.57x, 1024x16 0.55x, 1536x1 1.91x, 1536x2 1.44x, 1536x4 0.95x, 2048x1 2.48x, 2048x2 2.35x, 2048x4 1.66x, 3072x1 3.13x, 4096x1 5.62x

tridiag over the CPU (eigenvalues alone), N x batch: 128x1 0.23x, 128x2 0.13x, 128x4 0.07x, 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.04x, 192x32 0.04x, 192x64 0.03x, 192x128 0.03x, 192x256 0.03x, 256x1 0.41x, 256x2 0.23x, 256x4 0.13x, 256x8 0.08x, 256x16 0.05x, 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.77x, 512x2 0.45x, 512x4 0.26x, 512x8 0.16x, 512x16 0.10x, 512x32 0.10x, 512x64 0.09x, 512x128 0.08x, 768x1 1.15x, 768x2 0.66x, 768x4 0.39x, 768x8 0.23x, 768x16 0.16x, 768x32 0.14x, 768x64 0.12x, 1024x1 1.46x, 1024x2 0.83x, 1024x4 0.52x, 1024x8 0.31x, 1024x16 0.20x, 1536x1 1.84x, 1536x2 1.26x, 1536x4 0.65x, 2048x1 2.12x, 2048x2 1.42x, 2048x4 0.76x, 3072x1 2.15x, 4096x1 2.23x

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

Chosen: 4096 (in effect: never): 1.0212 geometric-mean regret, worst 1.46x; without band 1.0308, worst 1.46x.

band over tridiag, N x batch: 512x1 0.74x, 512x2 0.78x, 512x4 0.82x, 512x8 0.83x, 512x16 0.84x, 512x32 0.85x, 512x64 0.84x, 512x128 0.85x, 768x1 0.70x, 768x2 0.77x, 768x4 0.81x, 768x8 0.83x, 768x16 0.84x, 768x32 0.85x, 768x64 0.86x, 1024x1 0.75x, 1024x2 0.79x, 1024x4 0.86x, 1024x8 0.88x, 1024x16 0.90x, 1536x1 0.84x, 1536x2 0.95x, 1536x4 1.00x, 2048x1 0.82x, 2048x2 0.99x, 2048x4 1.10x, 3072x1 1.07x, 4096x1 1.30x

band over the CPU, N x batch: 512x1 0.57x, 512x2 0.35x, 512x4 0.21x, 512x8 0.13x, 512x16 0.09x, 512x32 0.08x, 512x64 0.07x, 512x128 0.07x, 768x1 0.81x, 768x2 0.51x, 768x4 0.31x, 768x8 0.19x, 768x16 0.13x, 768x32 0.12x, 768x64 0.11x, 1024x1 1.10x, 1024x2 0.66x, 1024x4 0.45x, 1024x8 0.27x, 1024x16 0.18x, 1536x1 1.55x, 1536x2 1.19x, 1536x4 0.65x, 2048x1 1.74x, 2048x2 1.41x, 2048x4 0.83x, 3072x1 2.30x, 4096x1 2.91x

Noise floor

Pass-to-pass ratio (max/min of the same measurement across passes), 1692 measurements: median 1.017, p90 1.120, max 3.77. 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 809 1.034 1.172 3.77
1-3 ms 185 1.008 1.069 1.62
3-10 ms 204 1.010 1.042 1.36
10-30 ms 152 1.012 1.048 1.46
30-100 ms 151 1.010 1.038 1.23
>100 ms 191 1.011 1.046 1.15