SPB Git

spb/metrika Public

Stata-class statistics, GPU-accelerated by Apple Silicon. Native Swift — no Electron, no Python runtime, no compromises.

Swift 92.4% HTML 3.3% R 3% Shell 1.3%

History of MetrikaKit/Tests/MetrikaKitTests/GPUBootstrapTests.swift · clear filter

  1. feat(gpu): MLX-batched pairs bootstrap with bit-identical Philox streams
    - mlx-swift dependency in ZQGPU (the only module allowed to import MLX)
    - Philox4x32-10 as vectorized MLX uint64 ops with the reference key
      schedule: GPU resample indices are bit-identical to the CPU generator
      (asserted per replicate) — the §5 reproducibility contract
    - batched gather + float32 cross-products on GPU, float64 Cholesky solves
      on CPU (§5 hybrid); chunked to the memory budget
    - conditioning: predictors standardized by fixed full-sample mean/scale
      (exact reparametrization) before forming X'X — raw data with an
      intercept lost 2-3 digits in float32
    - MLX workaround: batched GEMM mis-accumulates small k x k outputs at
      batch >= 2 (~6e-4 rel, stride/fusion-independent); X'X is built one
      column at a time through the exact (count,k,n)@(count,n,1) path, with
      regression tests pinning the behavior
    - planner: gpuAvailable detected from actual metallib presence (SwiftPM
      CLI cannot compile Metal shaders - swift test skips GPU suites, the
      xcodebuild-built app and tests get the GPU); reps >= 500 dispatches
      bootstrap to .gpu
    - engine: backend-aware bootstrap, drops singular resamples, output
      titled 'GPU batched' with gpu scalar
    - 68 tests green under xcodebuild (66 + GPU suites under swift test skip)
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    simon-pierre boucher committed 6 days ago (Aug 5, 2026) · 1 file changed +119