From the #63 GPU benchmark on an RTX 4090: float32 is 5-8x faster than float64 (CUDA float32 35 ms/it vs CPU float64 281 ms/it) but collapses to NaN on full-size data.
Observed
On the full sample EEG (30504 samples), float32 descends healthily for ~22 iterations (-3.51 -> -3.44) then a mixture component's responsibility mass underflows in float32's ~7-digit range; the exact-EM 0/0 yields non-finite mu/beta/alpha and the degenerate-fit contract (#50) stops with nan_ll (fails loudly, good). float32 DOES converge on smaller slices (4096 samples: -3.234, matching float64). So the math is right; it's precision headroom.
Goal
Make float32 stable on full-size recordings so the GPU fast path (5-8x) is usable in production, keeping float64 as the parity default.
Directions
- float32-specific flooring of mixture responsibilities /
dalpha_n before the exact-EM divisions (the collapse point).
- Mixed precision: preprocessing + the covariance/sphere already run float64; consider keeping the LL accumulation / a few sensitive reductions in float64 while the bulk runs float32.
- Investigate whether a larger
invsigmin/minrho or a responsibility floor tied to torch.finfo(float32).tiny prevents the collapse without hurting float64.
Acceptance
From the #63 GPU benchmark on an RTX 4090: float32 is 5-8x faster than float64 (CUDA float32 35 ms/it vs CPU float64 281 ms/it) but collapses to NaN on full-size data.
Observed
On the full sample EEG (30504 samples), float32 descends healthily for ~22 iterations (-3.51 -> -3.44) then a mixture component's responsibility mass underflows in float32's ~7-digit range; the exact-EM 0/0 yields non-finite mu/beta/alpha and the degenerate-fit contract (#50) stops with
nan_ll(fails loudly, good). float32 DOES converge on smaller slices (4096 samples: -3.234, matching float64). So the math is right; it's precision headroom.Goal
Make float32 stable on full-size recordings so the GPU fast path (5-8x) is usable in production, keeping float64 as the parity default.
Directions
dalpha_nbefore the exact-EM divisions (the collapse point).invsigmin/minrhoor a responsibility floor tied totorch.finfo(float32).tinyprevents the collapse without hurting float64.Acceptance
benchmarks/benchmark_gpu.pyon a CUDA host and record the stable speedup.