metal-linalg

SVD 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: bidiag x1.00, bidiag_batch x1.00, block x0.23, cpu x0.07, gk x0.38, jacobi x0.09, qr x0.16, qrblock x0.22 (1.00 is an M1).

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

Probe point after the sweep relative to before it: block x1.01, cpu x1.01, gk x0.94, jacobi x0.94, qr x0.98, qrblock x1.01 (stable).

Generated by tuning/tune_svd.py from 253 (shape, batch) points, 37 shapes with M >= N, batch in [1, 4, 16, 64, 256, 1024, 4096], seven backends (and the CPU and bidiag again for singular values alone), two or more passes, min-of-repeats.

Answer

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

// device, GPU cores,   qr_min_rows, qr_min_k,   block_min_k, block_min_k_batched, block_min_batch,   gpu_max_k, gpu_min_batch_times_k, gpu_min_batch, gpu_max_l,   values_gpu_max_k, values_gpu_min_batch_times_k, values_gpu_min_batch, values_gpu_max_l,   bidiag_min_k, values_bidiag_min_k, bidiag_max_batch, values_bidiag_max_batch,   gk_min_k, gk_max_k,   share_min_batch,   gpu_big_batch_max_k, gpu_big_batch_min,   values_band_min_k, values_band_width,   band_min_k
{"Apple M5 Pro", 20,   256, 16,   256, 64, 64,   8, 4096, 1, 2048,   80, 8192, 1, 2048,   1024, 1024, 16, 2,   4, 80,   256,   80, 256,   768, 16,   512,   96, 1024, 64, kSvdNoLimit,   96, 1024, 64, kSvdNoLimit,   32},

To try it without rebuilding:

SVD_QR_MIN_ROWS=256 SVD_QR_MIN_K=16 SVD_BLOCK_MIN_K=256 SVD_BLOCK_MIN_K_BATCHED=64 SVD_BLOCK_MIN_BATCH=64 SVD_GPU_MAX_K=8 SVD_GPU_MIN_BATCH_TIMES_K=4096 SVD_GPU_MIN_BATCH=1 SVD_GPU_MAX_L=2048 SVD_BIDIAG_MIN_K=1024 SVD_VALUES_BIDIAG_MIN_K=1024 SVD_BIDIAG_MAX_BATCH=16 SVD_VALUES_BIDIAG_MAX_BATCH=2 SVD_GK_MIN_K=4 SVD_GK_MAX_K=80 SVD_SHARE_MIN_BATCH=256 SVD_SHARE_MIN_K=32 SVD_GPU_BIG_BATCH_MAX_K=80 SVD_GPU_BIG_BATCH_MIN=256 SVD_VALUES_BAND_MIN_K=768 SVD_VALUES_BAND_WIDTH=16 SVD_BAND_MIN_K=512 SVD_VALUES_GPU_MAX_K=80 SVD_VALUES_GPU_MIN_BATCH_TIMES_K=8192 SVD_VALUES_GPU_MIN_BATCH=1 SVD_VALUES_GPU_MAX_L=2048 SVD_BIDIAG_BATCH_MIN_K=96 SVD_BIDIAG_BATCH_MAX_K=1024 SVD_BIDIAG_BATCH_MIN_BATCH=64 SVD_BIDIAG_BATCH_MAX_L=4294967295 SVD_VALUES_BIDIAG_BATCH_MIN_K=96 SVD_VALUES_BIDIAG_BATCH_MAX_K=1024 SVD_VALUES_BIDIAG_BATCH_MIN_BATCH=64 SVD_VALUES_BIDIAG_BATCH_MAX_L=4294967295

The policy in effect on this device came from tuned-stale:Apple M5 Pro. Against the best measured backend at every point the fitted rule scores 1.0215 geometric-mean regret, worst 1.61x, 16 of 253 points losing more than 10%, and 1.269x the oracle’s total time.

Warnings

Stage 1: which GPU backend

Scored against the best GPU backend at each of the 253 points, as if there were no CPU: this is the rule a forced-GPU call (SVD_DEVICE=gpu) follows, and what a GPU with more cores will lean on. Two independent choices. Precondition with QR iff the long side is at least qr_min_rows, the short side at least qr_min_k, and the long side at least twice the short one. Block kernel iff the short side is at least block_min_k, or at least block_min_k_batched in a batch of block_min_batch or more.

rule geomean regret worst >10% total time / oracle est. picks
policy in effect (‘256’, ‘16’, ‘192’, ‘64’, ‘64’) 1.0342 1.92x 26 1.004 0
fitted (‘256’, ‘16’, ‘256’, ‘64’, ‘64’) 1.0342 1.92x 26 1.004 0

Without a batch term, 2 of 410 combinations are within 0.5% of the best geomean: qr_min_rows 256 .. 256, qr_min_k 32 .. 32, block_min_k 96 .. 128.

With the batch term adopted (below), 3 combinations are within 0.5% of the best: block_min_k 256 .. none, block_min_k_batched 56 .. 64, block_min_batch 64 .. 64. The curves vary one constant around the chosen combination.

xychart-beta
    title "Regret by block_min_k"
    x-axis "block_min_k" [32, 40, 48, 56, 64, 80, 96, 128, 256, none]
    y-axis "geometric-mean regret" 1.0 --> 1.40
    line [1.3868, 1.2139, 1.1762, 1.1496, 1.1302, 1.0702, 1.0588, 1.0504, 1.0342, 1.0379]
block_min_k 32 40 48 56 64 80 96 128 256 none
geomean 1.3868 1.2139 1.1762 1.1496 1.1302 1.0702 1.0588 1.0504 1.0342 1.0379
worst 7.04x 4.98x 4.09x 3.44x 2.99x 2.58x 2.08x 1.92x 1.92x 2.50x
xychart-beta
    title "Regret by block_min_k_batched"
    x-axis "block_min_k_batched" [32, 40, 48, 56, 64, 80, 96, 128]
    y-axis "geometric-mean regret" 1.0 --> 1.10
    line [1.0863, 1.0580, 1.0446, 1.0373, 1.0342, 1.0540, 1.0559, 1.0657]
block_min_k_batched 32 40 48 56 64 80 96 128
geomean 1.0863 1.0580 1.0446 1.0373 1.0342 1.0540 1.0559 1.0657
worst 3.23x 2.92x 2.23x 1.92x 1.92x 2.46x 2.46x 2.46x
xychart-beta
    title "Regret by block_min_batch"
    x-axis "block_min_batch" [4, 16, 64, 256, 1024, 4096]
    y-axis "geometric-mean regret" 1.0 --> 1.11
    line [1.0959, 1.0655, 1.0342, 1.0417, 1.0668, 1.0983]
block_min_batch 4 16 64 256 1024 4096
geomean 1.0959 1.0655 1.0342 1.0417 1.0668 1.0983
worst 2.99x 2.81x 1.92x 2.31x 2.51x 2.57x
xychart-beta
    title "Regret by qr_min_rows"
    x-axis "qr_min_rows" [16, 32, 64, 128, 256, 512, 1024, 2048, none]
    y-axis "geometric-mean regret" 1.0 --> 1.30
    line [1.0958, 1.0958, 1.0784, 1.0534, 1.0342, 1.0358, 1.0865, 1.1851, 1.2806]
qr_min_rows 16 32 64 128 256 512 1024 2048 none
geomean 1.0958 1.0958 1.0784 1.0534 1.0342 1.0358 1.0865 1.1851 1.2806
worst 2.53x 2.53x 2.53x 2.29x 1.92x 2.40x 4.66x 8.04x 11.22x
xychart-beta
    title "Regret by qr_min_k"
    x-axis "qr_min_k" [8, 16, 32, 64, 128]
    y-axis "geometric-mean regret" 1.0 --> 1.18
    line [1.0564, 1.0342, 1.0276, 1.0788, 1.1604]
qr_min_k 8 16 32 64 128
geomean 1.0564 1.0342 1.0276 1.0788 1.1604
worst 3.16x 1.92x 2.69x 8.04x 8.04x

Held-out check of a batch-dependent block crossover (block from a smaller k once the batch is large enough), fitted on 144 points and scored on the other 109; the verdict is a bootstrap over the test points.

rule fitted on train train geomean test geomean test worst verdict
one block crossover [“256”, “32”, “128”, “none”, “none”] 1.0691 1.0842 2.46x baseline
batch-dependent block crossover {“block_min”: “256”, “block_lo”: “64”, “batch_hi”: “64”} 1.0197 1.0381 2.25x justified (better in 100% of resamples, median gain 4.3%)

Best GPU backend per point (J whole-matrix kernel, B block kernel, j and b the same after QR, g gk, G gk shared with the CPU), then what the rule picks, the gk window included:

      M x N  \ batch     1     4    16    64   256  1024  4096
      4 x 4               g     g     J     J     J     g     g
      8 x 8               g     g     J     J     g     g     g
     16 x 8               g     g     g     J     g     g     g
     32 x 8               g     g     g     g     g     g     g
     64 x 8               g     g     g     J     g     J     g
    128 x 8               g     g     g     J     J     J     J
    256 x 8               g     J     g     J     J     J     J
     16 x 16              J     J     J     J     g     g     g
     32 x 16              g     J     J     g     g     g     g
     64 x 16              J     J     J     J     g     g     g
    128 x 16              J     g     J     J     g     g     g
    256 x 16              J     J     J     J     g     g     g
    512 x 16              J     J     J     J     g     g     g
     24 x 24              g     J     J     g     g     g     g
     32 x 32              J     J     J     g     g     g     g
     64 x 32              J     J     J     J     g     g     g
    128 x 32              J     J     J     J     g     g     g
    256 x 32              J     J     J     J     g     g     g
    512 x 32              J     J     J     j     g     g     g
   1024 x 32              j     j     j     g     g     g     g
     40 x 40              J     J     J     g     g     g     g
     48 x 48              J     J     J     g     g     g     g
     56 x 56              J     J     J     g     g     g     g
     64 x 64              J     J     J     g     g     g     g
    128 x 64              J     J     J     g     g     g     g
    256 x 64              j     j     J     g     g     g     g
    512 x 64              j     j     j     g     g     g     g
   1024 x 64              j     j     j     g     g     g     g
   2048 x 64              j     j     j     g     g     g     b
     80 x 80              J     J     J     g     g     g     g
     96 x 96              J     J     J     J     B     B     B
    128 x 128             J     J     J     B     B     B     B
    256 x 128             j     j     j     b     b     b     b
    512 x 128             j     j     j     b     b     b     b
   1024 x 128             j     j     j     b     b     b     b
   2048 x 128             j     j     j     b     b     b     .
    256 x 256             B     .     .     B     .     .     .
      M x N  \ batch     1     4    16    64   256  1024  4096
      4 x 4               g     g     g     g     g     g     g
      8 x 8               g     g     g     g     g     g     g
     16 x 8               g     g     g     g     g     g     g
     32 x 8               g     g     g     g     g     g     g
     64 x 8               g     g     g     g     g     g     g
    128 x 8               g     g     g     g     g     g     g
    256 x 8               g     g     g     g     g     g     g
     16 x 16              g     g     g     g     g     g     g
     32 x 16              g     g     g     g     g     g     g
     64 x 16              g     g     g     g     g     g     g
    128 x 16              g     g     g     g     g     g     g
    256 x 16              g     g     g     g     g     g     g
    512 x 16              g     g     g     g     g     g     g
     24 x 24              g     g     g     g     g     g     g
     32 x 32              g     g     g     g     G     G     G
     64 x 32              g     g     g     g     G     G     G
    128 x 32              g     g     g     g     G     G     G
    256 x 32              g     g     g     g     G     G     G
    512 x 32              g     g     g     g     G     G     G
   1024 x 32              g     g     g     g     G     G     G
     40 x 40              g     g     g     g     G     G     G
     48 x 48              g     g     g     g     G     G     G
     56 x 56              g     g     g     g     G     G     G
     64 x 64              g     g     g     g     G     G     G
    128 x 64              g     g     g     g     G     G     G
    256 x 64              g     g     g     g     G     G     G
    512 x 64              g     g     g     g     G     G     G
   1024 x 64              g     g     g     g     G     G     G
   2048 x 64              g     g     g     g     G     G     G
     80 x 80              g     g     g     g     G     G     G
     96 x 96              J     J     J     B     B     B     B
    128 x 128             J     J     J     B     B     B     B
    256 x 128             j     j     j     b     b     b     b
    512 x 128             j     j     j     b     b     b     b
   1024 x 128             j     j     j     b     b     b     b
   2048 x 128             j     j     j     b     b     b     .
    256 x 256             B     .     .     B     .     .     .

Stage 1b: the gk backend

Inside a window of k = min(M, N), gk (Householder bidiagonalization and implicit QR, one threadgroup per matrix, k <= 83 on this device; on the matrix itself where it fits, else after a QR) instead of the Jacobi backend the split picks, fitted over the 253 points against the best GPU backend, gk included. Chosen: k = 4 .. 56.

rule geomean regret worst >10% total time / oracle est. picks
without gk (the split alone) 1.2574 4.18x 119 1.099 0
with gk for k in (4, 56) 1.1443 2.47x 82 1.060 0

Refitted once stage 1c chose to share batches with the CPU (gk shared leads the Jacobi backends where gk alone did not): k = 4 .. 56 became k = 4 .. 80, the window in the row.

2 windows are within 0.5% of the best geomean: gk_min_k 4 .. 8, gk_max_k 56 .. 56.

Held out: fitted on 144 points (window (4, 56)), scored on the other 109: geomean 1.1512x, worst 2.47x, against 1.2853x, worst 4.18x without gk.

gk over the best Jacobi backend, M x N x batch: 4x4x1 1.29x, 4x4x4 1.31x, 4x4x16 0.92x, 4x4x64 0.90x, 4x4x256 0.97x, 4x4x1024 1.27x, 4x4x4096 1.98x, 8x8x1 1.13x, 8x8x4 1.00x, 8x8x16 0.84x, 8x8x64 0.94x, 8x8x256 1.33x, 8x8x1024 2.46x, 8x8x4096 3.51x, 16x8x1 1.07x, 16x8x4 1.41x, 16x8x16 1.54x, 16x8x64 0.91x, 16x8x256 1.35x, 16x8x1024 1.82x, 16x8x4096 2.53x, 32x8x1 1.39x, 32x8x4 1.15x, 32x8x16 1.02x, 32x8x64 1.74x, 32x8x256 1.36x, 32x8x1024 1.41x, 32x8x4096 1.82x, 64x8x1 1.11x, 64x8x4 1.08x, 64x8x16 1.35x, 64x8x64 1.00x, 64x8x256 1.08x, 64x8x1024 1.00x, 64x8x4096 1.02x, 128x8x1 1.10x, 128x8x4 1.19x, 128x8x16 1.29x, 128x8x64 0.91x, 128x8x256 0.96x, 128x8x1024 0.85x, 128x8x4096 0.95x, 256x8x1 1.04x, 256x8x4 0.89x, 256x8x16 1.23x, 256x8x64 0.84x, 256x8x256 0.89x, 256x8x1024 0.93x, 256x8x4096 0.87x, 16x16x1 0.76x, 16x16x4 0.77x, 16x16x16 0.78x, 16x16x64 0.99x, 16x16x256 1.87x, 16x16x1024 3.12x, 16x16x4096 4.09x, 32x16x1 1.05x, 32x16x4 0.79x, 32x16x16 0.72x, 32x16x64 1.01x, 32x16x256 1.65x, 32x16x1024 2.29x, 32x16x4096 2.57x, 64x16x1 0.62x, 64x16x4 0.64x, 64x16x16 0.65x, 64x16x64 0.81x, 64x16x256 1.36x, 64x16x1024 1.44x, 64x16x4096 1.45x, 128x16x1 0.72x, 128x16x4 1.38x, 128x16x16 0.76x, 128x16x64 0.89x, 128x16x256 1.28x, 128x16x1024 1.30x, 128x16x4096 1.26x, 256x16x1 0.83x, 256x16x4 0.78x, 256x16x16 0.85x, 256x16x64 0.95x, 256x16x256 1.12x, 256x16x1024 1.18x, 256x16x4096 1.03x, 512x16x1 0.67x, 512x16x4 0.52x, 512x16x16 0.57x, 512x16x64 0.61x, 512x16x256 1.12x, 512x16x1024 1.23x, 512x16x4096 1.24x, 24x24x1 1.93x, 24x24x4 0.63x, 24x24x16 0.81x, 24x24x64 1.27x, 24x24x256 2.45x, 24x24x1024 2.67x, 24x24x4096 2.99x, 32x32x1 0.68x, 32x32x4 0.59x, 32x32x16 0.63x, 32x32x64 1.38x, 32x32x256 3.03x, 32x32x1024 3.76x, 32x32x4096 4.09x, 64x32x1 0.41x, 64x32x4 0.56x, 64x32x16 0.40x, 64x32x64 0.99x, 64x32x256 1.46x, 64x32x1024 1.77x, 64x32x4096 1.70x, 128x32x1 0.42x, 128x32x4 0.41x, 128x32x16 0.43x, 128x32x64 0.96x, 128x32x256 1.23x, 128x32x1024 1.30x, 128x32x4096 1.11x, 256x32x1 0.53x, 256x32x4 0.47x, 256x32x16 0.43x, 256x32x64 0.94x, 256x32x256 1.49x, 256x32x1024 1.70x, 256x32x4096 1.74x, 512x32x1 0.63x, 512x32x4 0.53x, 512x32x16 0.54x, 512x32x64 1.00x, 512x32x256 1.32x, 512x32x1024 1.45x, 512x32x4096 1.44x, 1024x32x1 0.66x, 1024x32x4 0.75x, 1024x32x16 0.77x, 1024x32x64 1.00x, 1024x32x256 1.22x, 1024x32x1024 1.26x, 1024x32x4096 1.23x, 40x40x1 0.62x, 40x40x4 0.60x, 40x40x16 0.59x, 40x40x64 1.35x, 40x40x256 2.24x, 40x40x1024 2.78x, 40x40x4096 2.75x, 48x48x1 0.66x, 48x48x4 0.63x, 48x48x16 0.64x, 48x48x64 1.43x, 48x48x256 2.19x, 48x48x1024 3.07x, 48x48x4096 3.16x, 56x56x1 0.64x, 56x56x4 0.65x, 56x56x16 0.60x, 56x56x64 1.43x, 56x56x256 2.20x, 56x56x1024 2.42x, 56x56x4096 2.66x, 64x64x1 0.57x, 64x64x4 0.55x, 64x64x16 0.60x, 64x64x64 1.46x, 64x64x256 1.87x, 64x64x1024 1.84x, 64x64x4096 1.93x, 128x64x1 0.49x, 128x64x4 0.51x, 128x64x16 0.45x, 128x64x64 1.12x, 128x64x256 1.32x, 128x64x1024 1.34x, 128x64x4096 1.49x, 256x64x1 0.55x, 256x64x4 0.57x, 256x64x16 0.54x, 256x64x64 1.12x, 256x64x256 1.31x, 256x64x1024 1.24x, 256x64x4096 1.33x, 512x64x1 0.55x, 512x64x4 0.61x, 512x64x16 0.62x, 512x64x64 1.08x, 512x64x256 1.19x, 512x64x1024 1.20x, 512x64x4096 1.29x, 1024x64x1 0.59x, 1024x64x4 0.63x, 1024x64x16 0.64x, 1024x64x64 1.05x, 1024x64x256 1.10x, 1024x64x1024 1.07x, 1024x64x4096 1.14x, 2048x64x1 0.63x, 2048x64x4 0.65x, 2048x64x16 0.69x, 2048x64x64 1.02x, 2048x64x256 1.08x, 2048x64x1024 1.13x, 80x80x1 0.61x, 80x80x4 0.67x, 80x80x16 0.68x, 80x80x64 1.27x, 80x80x256 1.92x, 80x80x1024 2.14x, 80x80x4096 2.13x

gk over the CPU, M x N x batch: 4x4x1 0.02x, 4x4x4 0.08x, 4x4x16 0.20x, 4x4x64 0.73x, 4x4x256 0.76x, 4x4x1024 1.35x, 4x4x4096 2.51x, 8x8x1 0.02x, 8x8x4 0.06x, 8x8x16 0.36x, 8x8x64 0.59x, 8x8x256 0.94x, 8x8x1024 2.00x, 8x8x4096 4.01x, 16x8x1 0.03x, 16x8x4 0.11x, 16x8x16 0.51x, 16x8x64 0.66x, 16x8x256 1.09x, 16x8x1024 2.13x, 16x8x4096 3.93x, 32x8x1 0.05x, 32x8x4 0.09x, 32x8x16 0.45x, 32x8x64 0.70x, 32x8x256 1.25x, 32x8x1024 1.91x, 32x8x4096 3.22x, 64x8x1 0.04x, 64x8x4 0.09x, 64x8x16 0.35x, 64x8x64 0.69x, 64x8x256 1.05x, 64x8x1024 1.35x, 64x8x4096 1.86x, 128x8x1 0.06x, 128x8x4 0.14x, 128x8x16 0.73x, 128x8x64 0.80x, 128x8x256 1.03x, 128x8x1024 1.12x, 128x8x4096 1.55x, 256x8x1 0.06x, 256x8x4 0.15x, 256x8x16 0.45x, 256x8x64 0.76x, 256x8x256 0.94x, 256x8x1024 1.44x, 256x8x4096 1.18x, 16x16x1 0.05x, 16x16x4 0.13x, 16x16x16 0.40x, 16x16x64 0.60x, 16x16x256 1.31x, 16x16x1024 2.46x, 16x16x4096 3.76x, 32x16x1 0.11x, 32x16x4 0.15x, 32x16x16 0.37x, 32x16x64 0.81x, 32x16x256 1.90x, 32x16x1024 2.90x, 32x16x4096 3.84x, 64x16x1 0.08x, 64x16x4 0.15x, 64x16x16 0.38x, 64x16x64 0.71x, 64x16x256 1.40x, 64x16x1024 1.66x, 64x16x4096 2.02x, 128x16x1 0.11x, 128x16x4 0.15x, 128x16x16 0.38x, 128x16x64 0.75x, 128x16x256 1.08x, 128x16x1024 1.62x, 128x16x4096 1.56x, 256x16x1 0.14x, 256x16x4 0.19x, 256x16x16 0.51x, 256x16x64 0.72x, 256x16x256 0.87x, 256x16x1024 1.24x, 256x16x4096 1.16x, 512x16x1 0.12x, 512x16x4 0.15x, 512x16x16 0.30x, 512x16x64 0.52x, 512x16x256 1.00x, 512x16x1024 1.34x, 512x16x4096 1.43x, 24x24x1 0.10x, 24x24x4 0.13x, 24x24x16 0.30x, 24x24x64 0.73x, 24x24x256 1.52x, 24x24x1024 1.99x, 24x24x4096 2.41x, 32x32x1 0.13x, 32x32x4 0.15x, 32x32x16 0.35x, 32x32x64 0.70x, 32x32x256 1.75x, 32x32x1024 2.32x, 32x32x4096 2.86x, 64x32x1 0.10x, 64x32x4 0.12x, 64x32x16 0.26x, 64x32x64 0.56x, 64x32x256 1.01x, 64x32x1024 1.47x, 64x32x4096 1.58x, 128x32x1 0.10x, 128x32x4 0.13x, 128x32x16 0.30x, 128x32x64 0.56x, 128x32x256 0.80x, 128x32x1024 1.09x, 128x32x4096 1.11x, 256x32x1 0.12x, 256x32x4 0.15x, 256x32x16 0.27x, 256x32x64 0.56x, 256x32x256 1.27x, 256x32x1024 1.50x, 256x32x4096 1.69x, 512x32x1 0.17x, 512x32x4 0.22x, 512x32x16 0.33x, 512x32x64 0.68x, 512x32x256 1.32x, 512x32x1024 1.53x, 512x32x4096 1.52x, 1024x32x1 0.21x, 1024x32x4 0.32x, 1024x32x16 0.43x, 1024x32x64 0.92x, 1024x32x256 1.34x, 1024x32x1024 1.52x, 1024x32x4096 1.39x, 40x40x1 0.10x, 40x40x4 0.12x, 40x40x16 0.25x, 40x40x64 0.58x, 40x40x256 0.99x, 40x40x1024 1.50x, 40x40x4096 1.48x, 48x48x1 0.10x, 48x48x4 0.13x, 48x48x16 0.25x, 48x48x64 0.56x, 48x48x256 1.04x, 48x48x1024 1.38x, 48x48x4096 1.37x, 56x56x1 0.10x, 56x56x4 0.13x, 56x56x16 0.22x, 56x56x64 0.52x, 56x56x256 0.87x, 56x56x1024 0.98x, 56x56x4096 0.98x, 64x64x1 0.11x, 64x64x4 0.12x, 64x64x16 0.20x, 64x64x64 0.53x, 64x64x256 0.75x, 64x64x1024 0.85x, 64x64x4096 0.87x, 128x64x1 0.12x, 128x64x4 0.15x, 128x64x16 0.20x, 128x64x64 0.57x, 128x64x256 0.82x, 128x64x1024 0.93x, 128x64x4096 0.94x, 256x64x1 0.13x, 256x64x4 0.18x, 256x64x16 0.23x, 256x64x64 0.80x, 256x64x256 0.95x, 256x64x1024 1.01x, 256x64x4096 0.94x, 512x64x1 0.17x, 512x64x4 0.25x, 512x64x16 0.37x, 512x64x64 0.95x, 512x64x256 1.17x, 512x64x1024 1.21x, 512x64x4096 1.19x, 1024x64x1 0.23x, 1024x64x4 0.34x, 1024x64x16 0.64x, 1024x64x64 1.15x, 1024x64x256 1.32x, 1024x64x1024 1.31x, 1024x64x4096 1.17x, 2048x64x1 0.31x, 2048x64x4 0.58x, 2048x64x16 0.83x, 2048x64x64 1.20x, 2048x64x256 1.34x, 2048x64x1024 1.26x, 80x80x1 0.14x, 80x80x4 0.17x, 80x80x16 0.21x, 80x80x64 0.46x, 80x80x256 0.69x, 80x80x1024 0.71x, 80x80x4096 0.66x

Stage 1c: sharing a batch with the CPU

From a batch and a k on, gk_share: gk 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 92 points where it was timed and gk is the GPU’s choice. Chosen: from batch 256 and k = 32.

rule geomean regret worst >10% total time / oracle est. picks
gk alone 1.1150 1.81x 33 1.230 0
shared from batch 256, k >= 32 1.0470 1.63x 16 1.031 0

gk_share over gk alone, M x N x batch: 4x4x64 0.63x, 4x4x256 0.51x, 4x4x1024 0.47x, 4x4x4096 0.53x, 8x8x64 0.68x, 8x8x256 0.55x, 8x8x1024 0.42x, 8x8x4096 0.44x, 16x8x64 0.63x, 16x8x256 0.55x, 16x8x1024 0.45x, 16x8x4096 0.58x, 32x8x64 0.62x, 32x8x256 0.55x, 32x8x1024 0.55x, 32x8x4096 0.69x, 64x8x64 0.64x, 64x8x256 0.66x, 64x8x1024 0.82x, 64x8x4096 0.96x, 128x8x64 0.63x, 128x8x256 0.75x, 128x8x1024 1.08x, 128x8x4096 1.10x, 256x8x64 0.73x, 256x8x256 0.92x, 256x8x1024 1.14x, 256x8x4096 1.21x, 16x16x64 0.68x, 16x16x256 0.65x, 16x16x1024 0.63x, 16x16x4096 0.43x, 32x16x64 0.67x, 32x16x256 0.69x, 32x16x1024 0.58x, 32x16x4096 0.50x, 64x16x64 0.74x, 64x16x256 0.84x, 64x16x1024 1.03x, 64x16x4096 1.05x, 128x16x64 0.74x, 128x16x256 1.08x, 128x16x1024 1.12x, 128x16x4096 1.22x, 256x16x64 0.80x, 256x16x256 1.22x, 256x16x1024 1.47x, 256x16x4096 1.61x, 512x16x64 0.86x, 512x16x256 1.02x, 512x16x1024 0.92x, 512x16x4096 0.90x, 24x24x64 0.75x, 24x24x256 0.79x, 24x24x1024 0.96x, 24x24x4096 1.06x, 32x32x64 0.85x, 32x32x256 0.89x, 32x32x1024 0.93x, 32x32x4096 0.99x, 64x32x64 0.83x, 64x32x256 1.53x, 64x32x1024 1.22x, 64x32x4096 1.34x, 128x32x64 0.87x, 128x32x256 1.25x, 128x32x1024 1.57x, 128x32x4096 1.71x, 256x32x64 0.84x, 256x32x256 1.13x, 256x32x1024 1.09x, 256x32x4096 1.00x, 512x32x64 0.92x, 512x32x256 1.11x, 512x32x1024 0.94x, 512x32x4096 1.00x, 1024x32x64 0.94x, 1024x32x256 1.20x, 1024x32x1024 0.94x, 1024x32x4096 1.12x, 40x40x64 0.88x, 40x40x256 1.57x, 40x40x1024 1.10x, 40x40x4096 1.42x, 48x48x64 0.88x, 48x48x256 1.61x, 48x48x1024 1.38x, 48x48x4096 1.58x, 56x56x64 0.93x, 56x56x256 1.10x, 56x56x1024 1.74x, 56x56x4096 1.81x

Stage 2: GPU or CPU

GPU iff k <= gpu_max_k, l <= gpu_max_l (l = max(M, N)), batch * k >= gpu_min_batch_times_k and batch >= gpu_min_batch, with k = min(M, N), scored against the best of the CPU and the GPU backends (gk included). 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 (‘8’, ‘4096’, ‘1’, ‘2048’) 1.0215 1.61x 16 1.269 1
fitted (‘8’, ‘4096’, ‘1’, ‘2048’) 1.0215 1.61x 16 1.269 1

36 of 4125 combinations are within 0.5% of the best geomean: gpu_max_k 64 .. 80, gpu_min_batch_times_k 4096 .. 8192, gpu_min_batch 1 .. 16, gpu_max_l 1024 .. none.

Large batches: the GPU also for k above gpu_max_k up to 80 (and l <= gpu_max_l) 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.1598, worst 3.84x; chosen 1.0215, worst 1.61x).

xychart-beta
    title "Regret by gpu_min_batch_times_k"
    x-axis "gpu_min_batch_times_k" [0, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, none]
    y-axis "geometric-mean regret" 1.0 --> 1.25
    line [1.2378, 1.0575, 1.0508, 1.0316, 1.0303, 1.0215, 1.0204, 1.0215, 1.0227, 1.0344, 1.0596]
gpu_min_batch_times_k 0 64 128 256 512 1024 2048 4096 8192 16384 none
geomean 1.2378 1.0575 1.0508 1.0316 1.0303 1.0215 1.0204 1.0215 1.0227 1.0344 1.0596
worst 57.20x 4.96x 2.86x 1.69x 1.69x 1.61x 1.61x 1.61x 1.61x 2.13x 4.01x
xychart-beta
    title "Regret by gpu_max_l"
    x-axis "gpu_max_l" [16, 24, 32, 40, 48, 56, 64, 80, 96, 128, 256, 512, 1024, 2048, none]
    y-axis "geometric-mean regret" 1.0 --> 1.18
    line [1.1659, 1.1568, 1.1247, 1.1173, 1.1088, 1.1041, 1.0809, 1.0770, 1.0770, 1.0607, 1.0464, 1.0327, 1.0207, 1.0215, 1.0215]
gpu_max_l 16 24 32 40 48 56 64 80 96 128 256 512 1024 2048 none
geomean 1.1659 1.1568 1.1247 1.1173 1.1088 1.1041 1.0809 1.0770 1.0770 1.0607 1.0464 1.0327 1.0207 1.0215 1.0215
worst 3.84x 3.84x 2.16x 2.16x 2.13x 2.13x 1.90x 1.90x 1.90x 1.87x 1.87x 1.87x 1.87x 1.61x 1.61x
xychart-beta
    title "Regret by gpu_min_batch"
    x-axis "gpu_min_batch" [1, 4, 16]
    y-axis "geometric-mean regret" 1.0 --> 1.04
    line [1.0215, 1.0215, 1.0215]
gpu_min_batch 1 4 16
geomean 1.0215 1.0215 1.0215
worst 1.61x 1.61x 1.61x
xychart-beta
    title "Regret by gpu_max_k"
    x-axis "gpu_max_k" [8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 128, 256]
    y-axis "geometric-mean regret" 1.0 --> 1.09
    line [1.0215, 1.0215, 1.0215, 1.0215, 1.0215, 1.0215, 1.0215, 1.0262, 1.0293, 1.0431, 1.0714, 1.0775]
gpu_max_k 8 16 24 32 40 48 56 64 80 96 128 256
geomean 1.0215 1.0215 1.0215 1.0215 1.0215 1.0215 1.0215 1.0262 1.0293 1.0431 1.0714 1.0775
worst 1.61x 1.61x 1.61x 1.61x 1.61x 1.61x 1.61x 1.90x 2.17x 2.79x 2.79x 4.25x

Held-out check of a per-k boundary against the product rule, fitted on 144 points and scored on the other 109; the verdict is a bootstrap.

rule fitted on train train geomean test geomean test worst verdict
product rule [8, 2048, 1, 1024] 1.0148 1.0261 1.87x baseline
per-k table {“min_batch_by_k”: {“4”: 1024, “8”: 256, “16”: 256, “24”: 4096, “32”: 256, “40”: 4096, “48”: 256, “56”: 1024, “64”: 256, “80”: 256, “96”: null, “128”: 16, “256”: null}} 1.0561 1.0804 2.58x rejected (better in 0% of resamples, median gain -5.0%)

Best backend per point (c CPU, J whole-matrix kernel, B block kernel, j and b the same after QR, g gk, G gk shared with the CPU, . not measured), what the rule picks, and the speedup of the best GPU backend over the CPU:

      M x N  \ batch     1     4    16    64   256  1024  4096
      4 x 4               c     c     c     c     c     g     g
      8 x 8               c     c     c     c     c     g     g
     16 x 8               c     c     c     c     g     g     g
     32 x 8               c     c     c     c     g     g     g
     64 x 8               c     c     c     c     g     J     g
    128 x 8               c     c     c     c     J     J     G
    256 x 8               c     c     c     c     J     G     G
     16 x 16              c     c     c     c     g     g     g
     32 x 16              c     c     c     c     g     g     g
     64 x 16              c     c     c     c     g     G     G
    128 x 16              c     c     c     c     G     G     G
    256 x 16              c     c     c     c     G     G     G
    512 x 16              c     c     c     c     G     g     g
     24 x 24              c     c     c     c     g     g     G
     32 x 32              c     c     c     c     g     g     g
     64 x 32              c     c     c     c     G     G     G
    128 x 32              c     c     c     c     c     G     G
    256 x 32              c     c     c     c     G     G     G
    512 x 32              c     c     c     c     G     g     g
   1024 x 32              c     c     c     c     G     g     G
     40 x 40              c     c     c     c     G     G     G
     48 x 48              c     c     c     c     G     G     G
     56 x 56              c     c     c     c     c     G     G
     64 x 64              c     c     c     c     G     G     G
    128 x 64              c     c     c     c     G     G     G
    256 x 64              c     c     c     c     G     G     G
    512 x 64              c     c     c     c     G     G     G
   1024 x 64              c     c     j     G     G     G     G
   2048 x 64              c     c     j     G     G     G     c
     80 x 80              c     c     c     c     G     G     G
     96 x 96              c     c     c     c     c     c     c
    128 x 128             c     c     c     c     c     c     c
    256 x 128             c     c     c     c     c     c     c
    512 x 128             c     c     c     c     c     c     c
   1024 x 128             c     c     c     c     b     c     c
   2048 x 128             c     c     j     b     b     c     .
    256 x 256             c     .     .     c     .     .     .
      M x N  \ batch     1     4    16    64   256  1024  4096
      4 x 4               c     c     c     c     c     g     g
      8 x 8               c     c     c     c     c     g     g
     16 x 8               c     c     c     c     c     g     g
     32 x 8               c     c     c     c     c     g     g
     64 x 8               c     c     c     c     c     g     g
    128 x 8               c     c     c     c     c     g     g
    256 x 8               c     c     c     c     c     g     g
     16 x 16              c     c     c     c     g     g     g
     32 x 16              c     c     c     c     g     g     g
     64 x 16              c     c     c     c     g     g     g
    128 x 16              c     c     c     c     g     g     g
    256 x 16              c     c     c     c     g     g     g
    512 x 16              c     c     c     c     g     g     g
     24 x 24              c     c     c     c     g     g     g
     32 x 32              c     c     c     c     G     G     G
     64 x 32              c     c     c     c     G     G     G
    128 x 32              c     c     c     c     G     G     G
    256 x 32              c     c     c     c     G     G     G
    512 x 32              c     c     c     c     G     G     G
   1024 x 32              c     c     c     c     G     G     G
     40 x 40              c     c     c     c     G     G     G
     48 x 48              c     c     c     c     G     G     G
     56 x 56              c     c     c     c     G     G     G
     64 x 64              c     c     c     c     G     G     G
    128 x 64              c     c     c     c     G     G     G
    256 x 64              c     c     c     c     G     G     G
    512 x 64              c     c     c     c     G     G     G
   1024 x 64              c     c     c     c     G     G     G
   2048 x 64              c     c     c     c     G     G     G
     80 x 80              c     c     c     c     G     G     G
     96 x 96              c     c     c     c     c     c     c
    128 x 128             c     c     c     c     c     c     c
    256 x 128             c     c     c     c     c     c     c
    512 x 128             c     c     c     c     c     c     c
   1024 x 128             c     c     c     c     c     c     c
   2048 x 128             c     c     c     c     c     c     .
    256 x 256             c     .     .     c     .     .     .
      M x N  \ batch     1     4    16    64   256  1024  4096
      4 x 4            0.02  0.08  0.22  0.81  0.78  1.35  2.51
      8 x 8            0.02  0.06  0.43  0.63  0.94  2.00  4.01
     16 x 8            0.03  0.11  0.51  0.73  1.09  2.13  3.93
     32 x 8            0.05  0.09  0.45  0.70  1.25  1.91  3.22
     64 x 8            0.04  0.09  0.35  0.69  1.05  1.36  1.86
    128 x 8            0.06  0.14  0.73  0.88  1.07  1.32  1.63
    256 x 8            0.06  0.17  0.45  0.91  1.06  1.54  1.36
     16 x 16           0.06  0.17  0.51  0.60  1.31  2.46  3.76
     32 x 16           0.11  0.19  0.51  0.81  1.90  2.90  3.84
     64 x 16           0.12  0.23  0.58  0.88  1.40  1.66  2.02
    128 x 16           0.15  0.15  0.50  0.84  1.08  1.62  1.56
    256 x 16           0.17  0.25  0.60  0.76  0.87  1.24  1.16
    512 x 16           0.18  0.29  0.53  0.85  1.00  1.34  1.43
     24 x 24           0.10  0.20  0.37  0.73  1.52  1.99  2.41
     32 x 32           0.19  0.25  0.56  0.70  1.75  2.32  2.86
     64 x 32           0.24  0.22  0.65  0.56  1.01  1.47  1.58
    128 x 32           0.25  0.33  0.68  0.59  0.80  1.09  1.11
    256 x 32           0.22  0.32  0.64  0.59  1.27  1.50  1.69
    512 x 32           0.27  0.41  0.61  0.68  1.32  1.53  1.52
   1024 x 32           0.32  0.42  0.55  0.92  1.34  1.52  1.39
     40 x 40           0.16  0.20  0.43  0.58  0.99  1.50  1.48
     48 x 48           0.15  0.20  0.39  0.56  1.04  1.38  1.37
     56 x 56           0.16  0.19  0.36  0.52  0.87  0.98  0.98
     64 x 64           0.19  0.23  0.34  0.53  0.75  0.85  0.87
    128 x 64           0.25  0.29  0.45  0.57  0.82  0.93  0.94
    256 x 64           0.24  0.32  0.43  0.80  0.95  1.01  0.94
    512 x 64           0.31  0.41  0.60  0.95  1.17  1.21  1.19
   1024 x 64           0.39  0.54  1.00  1.15  1.32  1.31  1.17
   2048 x 64           0.49  0.90  1.20  1.20  1.34  1.26  0.95
     80 x 80           0.24  0.25  0.31  0.46  0.69  0.71  0.66
     96 x 96           0.25  0.31  0.37  0.38  0.49  0.47  0.42
    128 x 128          0.23  0.29  0.37  0.42  0.45  0.40  0.39
    256 x 128          0.31  0.40  0.47  0.62  0.69  0.64  0.60
    512 x 128          0.35  0.36  0.66  0.76  0.85  0.78  0.71
   1024 x 128          0.41  0.49  0.86  0.93  1.03  0.96  0.55
   2048 x 128          0.60  0.75  1.06  1.11  1.19  0.99     .
    256 x 256          0.23     .     .  0.24     .     .     .

Stage 2b: GPU or CPU for singular values alone

The rule of stage 2 again, with constants of its own, for svdvals: both sides skip the vectors, by different amounts. Fitted on the 209 points where gk and the CPU were timed for singular values alone and gk is the GPU’s choice. Chosen: GPU iff k <= 80, l <= 2048, batch * k >= 8192 and batch >= 1.

rule geomean regret worst >10% total time / oracle est. picks
CPU always 1.2033 3.75x 73 1.638 0
as with vectors (stage 2’s rule) 1.0236 1.61x 15 1.012 0
fitted (‘80’, ‘8192’, ‘1’, ‘2048’) 1.0294 1.61x 18 1.014 0

Held out: fitted on 119 points ((‘80’, ‘8192’, ‘1’, ‘1024’)), scored on the other 90: geomean 1.0387x, worst 1.75x, against 1.0239x, worst 1.52x as with vectors.

gk over the CPU for singular values alone, M x N x batch: 4x4x1 0.02x, 4x4x4 0.08x, 4x4x16 0.17x, 4x4x64 0.65x, 4x4x256 1.40x, 4x4x1024 1.16x, 4x4x4096 2.69x, 8x8x1 0.02x, 8x8x4 0.07x, 8x8x16 0.17x, 8x8x64 0.59x, 8x8x256 0.84x, 8x8x1024 1.69x, 8x8x4096 3.20x, 16x8x1 0.03x, 16x8x4 0.12x, 16x8x16 0.24x, 16x8x64 0.76x, 16x8x256 1.00x, 16x8x1024 2.03x, 16x8x4096 3.75x, 32x8x1 0.03x, 32x8x4 0.12x, 32x8x16 0.39x, 32x8x64 1.51x, 32x8x256 1.13x, 32x8x1024 1.81x, 32x8x4096 2.82x, 64x8x1 0.02x, 64x8x4 0.13x, 64x8x16 0.38x, 64x8x64 0.55x, 64x8x256 1.07x, 64x8x1024 1.53x, 64x8x4096 2.40x, 128x8x1 0.04x, 128x8x4 0.11x, 128x8x16 0.44x, 128x8x64 0.90x, 128x8x256 1.00x, 128x8x1024 1.84x, 128x8x4096 2.01x, 256x8x1 0.03x, 256x8x4 0.16x, 256x8x16 0.62x, 256x8x64 0.83x, 256x8x256 1.01x, 256x8x1024 1.29x, 256x8x4096 1.51x, 16x16x1 0.03x, 16x16x4 0.10x, 16x16x16 0.46x, 16x16x64 0.68x, 16x16x256 1.10x, 16x16x1024 1.96x, 16x16x4096 3.56x, 32x16x1 0.04x, 32x16x4 0.08x, 32x16x16 0.41x, 32x16x64 0.75x, 32x16x256 1.46x, 32x16x1024 2.17x, 32x16x4096 2.91x, 64x16x1 0.04x, 64x16x4 0.10x, 64x16x16 0.27x, 64x16x64 0.59x, 64x16x256 1.06x, 64x16x1024 1.27x, 64x16x4096 1.78x, 128x16x1 0.05x, 128x16x4 0.12x, 128x16x16 0.33x, 128x16x64 0.67x, 128x16x256 0.94x, 128x16x1024 1.59x, 128x16x4096 1.39x, 256x16x1 0.07x, 256x16x4 0.17x, 256x16x16 0.48x, 256x16x64 0.72x, 256x16x256 0.90x, 256x16x1024 1.24x, 256x16x4096 1.05x, 512x16x1 0.13x, 512x16x4 0.21x, 512x16x16 0.45x, 512x16x64 0.64x, 512x16x256 1.60x, 512x16x1024 1.52x, 512x16x4096 1.55x, 24x24x1 0.05x, 24x24x4 0.10x, 24x24x16 0.68x, 24x24x64 0.58x, 24x24x256 1.22x, 24x24x1024 1.68x, 24x24x4096 2.23x, 32x32x1 0.07x, 32x32x4 0.13x, 32x32x16 0.36x, 32x32x64 0.72x, 32x32x256 1.40x, 32x32x1024 2.00x, 32x32x4096 2.68x, 64x32x1 0.05x, 64x32x4 0.08x, 64x32x16 0.27x, 64x32x64 0.46x, 64x32x256 0.69x, 64x32x1024 1.09x, 64x32x4096 0.97x, 128x32x1 0.06x, 128x32x4 0.11x, 128x32x16 0.32x, 128x32x64 0.47x, 128x32x256 0.58x, 128x32x1024 0.78x, 128x32x4096 0.69x, 256x32x1 0.16x, 256x32x4 0.23x, 256x32x16 0.43x, 256x32x64 0.66x, 256x32x256 1.44x, 256x32x1024 1.52x, 256x32x4096 1.78x, 512x32x1 0.19x, 512x32x4 0.29x, 512x32x16 0.48x, 512x32x64 0.97x, 512x32x256 1.33x, 512x32x1024 1.53x, 512x32x4096 1.60x, 1024x32x1 0.25x, 1024x32x4 0.35x, 1024x32x16 0.58x, 1024x32x64 0.92x, 1024x32x256 1.33x, 1024x32x1024 1.41x, 1024x32x4096 1.37x, 40x40x1 0.04x, 40x40x4 0.06x, 40x40x16 0.23x, 40x40x64 0.33x, 40x40x256 0.65x, 40x40x1024 1.13x, 40x40x4096 1.05x, 48x48x1 0.04x, 48x48x4 0.07x, 48x48x16 0.19x, 48x48x64 0.38x, 48x48x256 0.66x, 48x48x1024 0.98x, 48x48x4096 0.95x, 56x56x1 0.05x, 56x56x4 0.07x, 56x56x16 0.17x, 56x56x64 0.30x, 56x56x256 0.69x, 56x56x1024 0.76x, 56x56x4096 0.79x, 64x64x1 0.05x, 64x64x4 0.07x, 64x64x16 0.16x, 64x64x64 0.31x, 64x64x256 0.55x, 64x64x1024 0.66x, 64x64x4096 0.64x, 128x64x1 0.07x, 128x64x4 0.10x, 128x64x16 0.16x, 128x64x64 0.37x, 128x64x256 0.67x, 128x64x1024 0.74x, 128x64x4096 0.79x, 256x64x1 0.08x, 256x64x4 0.12x, 256x64x16 0.20x, 256x64x64 0.49x, 256x64x256 0.84x, 256x64x1024 0.87x, 256x64x4096 0.85x, 512x64x1 0.10x, 512x64x4 0.16x, 512x64x16 0.27x, 512x64x64 0.73x, 512x64x256 1.08x, 512x64x1024 1.16x, 512x64x4096 1.16x, 1024x64x1 0.14x, 1024x64x4 0.22x, 1024x64x16 0.41x, 1024x64x64 0.84x, 1024x64x256 1.13x, 1024x64x1024 1.16x, 1024x64x4096 0.96x, 2048x64x1 0.19x, 2048x64x4 0.39x, 2048x64x16 0.67x, 2048x64x64 0.88x, 2048x64x256 1.03x, 2048x64x1024 0.98x, 80x80x1 0.10x, 80x80x4 0.13x, 80x80x16 0.19x, 80x80x64 0.40x, 80x80x256 0.86x, 80x80x1024 0.87x, 80x80x4096 0.87x

Stage 3: the bidiag backend instead of the CPU

Where the rule above chooses the CPU, the bidiag backend (GPU bidiagonalization, then LAPACK’s bidiagonal solve) from a threshold k = min(M, 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 on the points where bidiag was timed (k >= 128, within the cost cap): the region the threshold decides. With vectors it is scored against the best of all backends, bidiag included; for singular values alone (svdvals), bidiag against the CPU at the points where the rule chooses the CPU.

  threshold batch cap geomean regret worst without bidiag: geomean worst held out (fitted on half)
with vectors 1024 4 1.0204 1.65x 1.1230 3.40x from 1024, batch <= 4: 1.0227 vs 1.0839
singular values alone 1024 2 1.0060 1.42x 1.0876 2.70x from 1024, batch <= 2: 1.0000 vs 1.0684

bidiag over the CPU (with vectors), M x N x batch: 128x128x1 0.36x, 128x128x4 0.14x, 128x128x16 0.04x, 128x128x64 0.04x, 128x128x256 0.04x, 256x128x1 0.44x, 256x128x4 0.17x, 256x128x16 0.06x, 256x128x64 0.05x, 256x128x256 0.05x, 512x128x1 0.48x, 512x128x4 0.16x, 512x128x16 0.07x, 512x128x64 0.06x, 512x128x256 0.05x, 1024x128x1 0.54x, 1024x128x4 0.19x, 1024x128x16 0.09x, 1024x128x64 0.07x, 1024x128x256 0.07x, 2048x128x1 0.77x, 2048x128x4 0.31x, 2048x128x16 0.14x, 2048x128x64 0.12x, 2048x128x256 0.12x, 192x192x1 0.41x, 192x192x4 0.13x, 192x192x16 0.05x, 192x192x64 0.04x, 192x192x256 0.04x, 256x256x1 0.54x, 256x256x4 0.18x, 256x256x16 0.08x, 256x256x64 0.06x, 512x256x1 0.59x, 512x256x4 0.20x, 512x256x16 0.08x, 512x256x64 0.07x, 1024x256x1 0.72x, 1024x256x4 0.24x, 1024x256x16 0.11x, 1024x256x64 0.09x, 2048x256x1 0.97x, 2048x256x4 0.32x, 2048x256x16 0.16x, 2048x256x64 0.15x, 384x384x1 0.67x, 384x384x4 0.23x, 384x384x16 0.11x, 384x384x64 0.09x, 512x512x1 0.99x, 512x512x4 0.34x, 512x512x16 0.17x, 512x512x64 0.16x, 768x768x1 1.21x, 768x768x4 0.43x, 768x768x16 0.30x, 1024x1024x1 1.71x, 1024x1024x4 0.76x, 1024x1024x16 0.74x, 1280x1280x1 1.60x, 1280x1280x2 1.09x, 1280x1280x4 0.61x, 1536x1536x1 1.95x, 1536x1536x2 1.34x, 1536x1536x4 0.84x, 1792x1792x1 1.87x, 1792x1792x2 1.51x, 1792x1792x4 1.44x, 2048x2048x1 2.59x, 2048x2048x2 2.09x, 2048x2048x4 1.75x, 3072x3072x1 3.07x, 4096x4096x1 3.40x

bidiag over the CPU (singular values alone), M x N x batch: 128x128x1 0.38x, 128x128x4 0.15x, 128x128x16 0.04x, 128x128x64 0.04x, 128x128x256 0.04x, 256x128x1 0.39x, 256x128x4 0.15x, 256x128x16 0.05x, 256x128x64 0.04x, 256x128x256 0.04x, 512x128x1 0.39x, 512x128x4 0.15x, 512x128x16 0.05x, 512x128x64 0.04x, 512x128x256 0.04x, 1024x128x1 0.41x, 1024x128x4 0.13x, 1024x128x16 0.06x, 1024x128x64 0.04x, 1024x128x256 0.04x, 2048x128x1 0.57x, 2048x128x4 0.21x, 2048x128x16 0.09x, 2048x128x64 0.07x, 2048x128x256 0.07x, 192x192x1 0.31x, 192x192x4 0.11x, 192x192x16 0.04x, 192x192x64 0.03x, 192x192x256 0.03x, 256x256x1 0.46x, 256x256x4 0.15x, 256x256x16 0.06x, 256x256x64 0.05x, 512x256x1 0.42x, 512x256x4 0.15x, 512x256x16 0.06x, 512x256x64 0.05x, 1024x256x1 0.53x, 1024x256x4 0.18x, 1024x256x16 0.07x, 1024x256x64 0.06x, 2048x256x1 0.69x, 2048x256x4 0.23x, 2048x256x16 0.11x, 2048x256x64 0.09x, 384x384x1 0.60x, 384x384x4 0.19x, 384x384x16 0.09x, 384x384x64 0.07x, 512x512x1 0.87x, 512x512x4 0.29x, 512x512x16 0.13x, 512x512x64 0.11x, 768x768x1 1.02x, 768x768x4 0.35x, 768x768x16 0.24x, 1024x1024x1 1.73x, 1024x1024x4 0.57x, 1024x1024x16 0.72x, 1280x1280x1 1.55x, 1280x1280x2 0.93x, 1280x1280x4 0.47x, 1536x1536x1 1.85x, 1536x1536x2 1.18x, 1536x1536x4 0.67x, 1792x1792x1 1.67x, 1792x1792x2 1.18x, 1792x1792x4 0.84x, 2048x2048x1 2.35x, 2048x2048x2 1.78x, 2048x2048x4 1.42x, 3072x3072x1 2.64x, 4096x4096x1 2.70x

Stage 3b: the band backend for singular values alone

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

Chosen: 768 (in effect: 768): 1.0709 geometric-mean regret, worst 2.94x; without band 1.3586, worst 3.66x.

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.079, 16 1.015, 32 1.462. 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: 768.

band over bidiag, M x N x batch: 512x512x1 0.99x, 512x512x4 1.17x, 512x512x16 1.25x, 512x512x64 1.28x, 768x768x1 1.05x, 768x768x4 1.19x, 768x768x16 1.27x, 1024x1024x1 1.07x, 1024x1024x4 1.28x, 1024x1024x16 1.38x, 1280x1280x1 1.21x, 1280x1280x2 1.36x, 1280x1280x4 1.51x, 1536x1536x1 1.35x, 1536x1536x2 1.54x, 1536x1536x4 1.67x, 1792x1792x1 1.47x, 1792x1792x2 1.72x, 1792x1792x4 1.82x, 2048x2048x1 1.64x, 2048x2048x2 1.91x, 2048x2048x4 2.07x, 3072x3072x1 2.67x, 4096x4096x1 3.66x

band over the CPU, M x N x batch: 512x512x1 0.86x, 512x512x4 0.34x, 512x512x16 0.17x, 512x512x64 0.14x, 768x768x1 1.07x, 768x768x4 0.42x, 768x768x16 0.30x, 1024x1024x1 1.84x, 1024x1024x4 0.73x, 1024x1024x16 0.99x, 1280x1280x1 1.88x, 1280x1280x2 1.27x, 1280x1280x4 0.71x, 1536x1536x1 2.50x, 1536x1536x2 1.81x, 1536x1536x4 1.13x, 1792x1792x1 2.45x, 1792x1792x2 2.03x, 1792x1792x4 1.53x, 2048x2048x1 3.85x, 2048x2048x2 3.40x, 2048x2048x4 2.94x, 3072x3072x1 7.04x, 4096x4096x1 9.86x

Stage 3c: the band backend with vectors

With singular vectors, where the rules above choose the CPU or bidiag, the band backend (the two-stage reduction, its band 16 wide; both stages’ reflectors applied on the GPU, Q1 Q2 and P1 P2 formed while the CPU chases the band and solves the bidiagonal problem) from a threshold k on (0: never), within bidiag’s batch cap, fitted on the 74 points where it was timed (k >= 512) against the CPU, bidiag and band.

Chosen: 512 (in effect: [1024, 4]): 1.0121 geometric-mean regret, worst 1.60x; without band 1.1148, worst 3.63x.

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, 16], [512, 64], [512, 256].

band over bidiag, M x N x batch: 512x512x1 1.14x, 512x512x4 3.01x, 512x512x16 5.90x, 512x512x64 8.56x, 768x768x1 1.14x, 768x768x4 2.51x, 768x768x16 4.91x, 1024x1024x1 1.21x, 1024x1024x4 2.43x, 1024x1024x16 3.63x, 1280x1280x1 1.27x, 1280x1280x2 1.02x, 1280x1280x4 1.04x, 1536x1536x1 1.32x, 1536x1536x2 1.13x, 1536x1536x4 1.05x, 1792x1792x1 1.38x, 1792x1792x2 1.15x, 1792x1792x4 1.11x, 2048x2048x1 1.58x, 2048x2048x2 1.26x, 2048x2048x4 1.26x, 3072x3072x1 2.04x, 4096x4096x1 2.46x

band over the CPU, M x N x batch: 512x512x1 1.12x, 512x512x4 1.02x, 512x512x16 1.02x, 512x512x64 1.35x, 768x768x1 1.38x, 768x768x4 1.08x, 768x768x16 1.49x, 1024x1024x1 2.07x, 1024x1024x4 1.85x, 1024x1024x16 2.69x, 1280x1280x1 2.02x, 1280x1280x2 1.11x, 1280x1280x4 0.63x, 1536x1536x1 2.58x, 1536x1536x2 1.51x, 1536x1536x4 0.88x, 1792x1792x1 2.58x, 1792x1792x2 1.74x, 1792x1792x4 1.60x, 2048x2048x1 4.11x, 2048x2048x2 2.64x, 2048x2048x4 2.19x, 3072x3072x1 6.28x, 4096x4096x1 8.35x

Stage 4: the bidiag_batch backend for batches of mid-size matrices

Where the rules above choose the CPU, the bidiag_batch backend (bidiag’s method for a whole batch at once: the bidiagonalization of every matrix by the same dispatches, the bidiagonal problems on the CPU’s cores, the back-transformations as batched products) for k in a window, l up to a cap, from a batch on, fitted on the points where it was timed (k from 32, l up to 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, the narrowest window and the lowest cap on l.

With singular vectors (92 points): k 96-1024, from batch 64 (in effect: never): 1.0139 geometric-mean regret, worst 1.38x; without it 1.2444, worst 3.05x. Held out: the window fitted on half the points, k 96-1024, from batch 64, scores 1.0093 on the other half, against 1.2136 without it.

bidiag_batch over the CPU, M x N x batch: 32x32x16 0.20x, 32x32x64 0.33x, 64x32x16 0.18x, 64x32x64 0.29x, 128x32x16 0.20x, 128x32x64 0.31x, 256x32x16 0.22x, 256x32x64 0.38x, 512x32x16 0.27x, 512x32x64 0.55x, 1024x32x16 0.37x, 1024x32x64 0.77x, 40x40x16 0.20x, 40x40x64 0.37x, 48x48x16 0.22x, 48x48x64 0.41x, 56x56x16 0.24x, 56x56x64 0.45x, 64x64x16 0.24x, 64x64x64 0.49x, 128x64x16 0.26x, 128x64x64 0.58x, 256x64x16 0.29x, 256x64x64 0.83x, 512x64x16 0.47x, 512x64x64 1.01x, 1024x64x16 0.79x, 1024x64x64 1.25x, 2048x64x16 1.01x, 2048x64x64 1.33x, 80x80x16 0.30x, 80x80x64 0.63x, 96x96x16 0.39x, 96x96x64 0.83x, 96x96x256 1.05x, 96x96x1024 1.57x, 96x96x4096 1.69x, 128x128x16 0.73x, 128x128x64 1.11x, 128x128x256 1.74x, 128x128x1024 1.97x, 128x128x4096 1.99x, 256x128x16 0.72x, 256x128x64 1.20x, 256x128x256 1.76x, 256x128x1024 2.10x, 256x128x4096 2.12x, 512x128x16 0.99x, 512x128x64 1.37x, 512x128x256 1.99x, 512x128x1024 2.10x, 512x128x4096 2.04x, 1024x128x16 1.11x, 1024x128x64 1.52x, 1024x128x256 1.93x, 1024x128x1024 2.04x, 1024x128x4096 1.54x, 2048x128x16 1.38x, 2048x128x64 1.55x, 2048x128x256 1.72x, 2048x128x1024 1.71x, 192x192x16 0.73x, 192x192x64 0.95x, 192x192x256 1.45x, 192x192x1024 1.45x, 256x256x16 0.86x, 256x256x64 1.24x, 256x256x256 1.55x, 256x256x1024 1.49x, 256x256x4096 1.66x, 512x256x16 0.87x, 512x256x64 1.32x, 512x256x256 1.52x, 512x256x1024 1.51x, 1024x256x16 0.95x, 1024x256x64 1.33x, 1024x256x256 1.55x, 1024x256x1024 1.48x, 2048x256x16 1.08x, 2048x256x64 1.26x, 2048x256x256 1.29x, 384x384x16 0.89x, 384x384x64 1.10x, 384x384x256 1.25x, 384x384x1024 1.22x, 512x512x16 1.01x, 512x512x64 1.34x, 512x512x256 1.14x, 768x768x16 1.49x, 768x768x64 1.66x, 1024x1024x16 2.71x, 1024x1024x64 3.05x

Singular values alone (93 points): k 96-1024, from batch 64 (in effect: never): 1.0289 geometric-mean regret, worst 4.17x; without it 1.3226, worst 5.66x. Held out: the window fitted on half the points, k 96-1024, from batch 64, scores 1.0543 on the other half, against 1.3080 without it.

bidiag_batch over the CPU, M x N x batch: 32x32x16 0.20x, 32x32x64 0.37x, 64x32x16 0.23x, 64x32x64 0.31x, 128x32x16 0.26x, 128x32x64 0.32x, 256x32x16 0.31x, 256x32x64 0.47x, 512x32x16 0.38x, 512x32x64 0.76x, 1024x32x16 0.51x, 1024x32x64 0.87x, 40x40x16 0.28x, 40x40x64 0.35x, 48x48x16 0.26x, 48x48x64 0.44x, 56x56x16 0.23x, 56x56x64 0.33x, 64x64x16 0.21x, 64x64x64 0.35x, 128x64x16 0.24x, 128x64x64 0.47x, 256x64x16 0.28x, 256x64x64 0.63x, 512x64x16 0.40x, 512x64x64 1.01x, 1024x64x16 0.62x, 1024x64x64 1.13x, 2048x64x16 0.98x, 2048x64x64 1.29x, 80x80x16 0.34x, 80x80x64 0.77x, 96x96x16 0.39x, 96x96x64 1.01x, 96x96x256 1.53x, 96x96x1024 1.83x, 96x96x4096 1.88x, 128x128x16 0.64x, 128x128x64 1.64x, 128x128x256 2.42x, 128x128x1024 2.56x, 128x128x4096 2.57x, 256x128x16 0.68x, 256x128x64 1.40x, 256x128x256 2.12x, 256x128x1024 2.38x, 256x128x4096 2.36x, 512x128x16 0.81x, 512x128x64 1.58x, 512x128x256 2.26x, 512x128x1024 2.44x, 512x128x4096 2.47x, 1024x128x16 0.92x, 1024x128x64 1.45x, 1024x128x256 1.93x, 1024x128x1024 2.03x, 1024x128x4096 1.90x, 2048x128x16 1.05x, 2048x128x64 1.21x, 2048x128x256 1.37x, 2048x128x1024 1.34x, 192x192x16 0.66x, 192x192x64 1.02x, 192x192x256 1.21x, 192x192x1024 1.29x, 192x192x4096 1.22x, 256x256x16 0.83x, 256x256x64 1.25x, 256x256x256 1.44x, 256x256x1024 1.50x, 256x256x4096 1.63x, 512x256x16 0.92x, 512x256x64 1.29x, 512x256x256 1.49x, 512x256x1024 1.56x, 1024x256x16 0.94x, 1024x256x64 1.20x, 1024x256x256 1.36x, 1024x256x1024 1.35x, 2048x256x16 1.04x, 2048x256x64 1.04x, 2048x256x256 1.07x, 384x384x16 1.02x, 384x384x64 1.27x, 384x384x256 1.69x, 384x384x1024 1.64x, 512x512x16 1.27x, 512x512x64 1.71x, 512x512x256 2.03x, 768x768x16 1.63x, 768x768x64 2.64x, 1024x1024x16 4.17x, 1024x1024x64 5.66x

Noise floor

Pass-to-pass ratio, 1160 measurements: median 1.019, p90 1.072, max 2.25.

runtime n median p90 max
<1 ms 241 1.025 1.241 2.25
1-3 ms 170 1.011 1.053 1.98
3-10 ms 239 1.018 1.063 1.39
10-30 ms 161 1.018 1.058 1.22
30-100 ms 180 1.021 1.053 1.18
>100 ms 169 1.022 1.064 1.23