// // GPUBootstrapTests.swift // Metrika // // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Copyright © 2026 Simon-Pierre Boucher. All rights reserved. // import Foundation import Testing import ZQGPU import ZQParser import ZQPlanner import ZQStats /// GPU bootstrap cross-checks (CLAUDE.md §9): same seed ⇒ identical /// resample indices across backends; estimates within the documented /// float32 tolerance. @Suite("GPU bootstrap", .enabled(if: ZQGPUBootstrap.isAvailable)) struct GPUBootstrapTests { @Test("MLX Philox indices are bit-identical to the CPU reference") func philoxParity() { let seed: UInt64 = 42 let n = 137 let generator = Philox4x32(seed: seed) for replicate in [0, 1, 7, 1000] { let cpu = ZQResampling.pairsBootstrapIndices( replicate: replicate, sampleSize: n, generator: generator ) let gpu = ZQGPUBootstrap.gpuIndices(replicate: replicate, sampleSize: n, seed: seed) #expect(cpu == gpu, "replicate \(replicate)") } } @Test("GPU coefficient draws match CPU within float32 tolerance") func drawParity() throws { // Small synthetic problem, well conditioned. let n = 200 let generator = Philox4x32(seed: 7) let x = (0..