Skip to content

docs: float32 precision limits (#70 investigation) - #71

Merged
neuromechanist merged 1 commit into
mainfrom
70-stabilize-float32-amicatorchng-for-the-gpu-fast-path
Jul 8, 2026
Merged

neuromechanist merged 1 commit into
mainfrom
70-stabilize-float32-amicatorchng-for-the-gpu-fast-path

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Investigation outcome for #70 (float32 GPU fast path).

Finding

float32 diverges to NaN on full-size data (30504 samples) across every seed, Newton on and off (iter 9-81). Root cause is precision-driven instability, NOT a divide-by-zero: M-step denominators stay healthy (O(1e3)) until a parameter diverges and the next E-step overflows.

Cheap fix tried and rejected

Computing the responsibility logsumexp/softmax in float64 (density + matmuls left float32) did not stabilize it -- still NaN, all seeds. So the instability is in the density and/or the sufficient-stat accumulation over 30504 samples, not the responsibilities.

Conclusion

A real fix needs mixed precision (float64 density/LL/accumulation, float32 matmuls), but those sensitive parts are runtime-dominant (~50%+), so the net speedup shrinks toward ~1.5-2x -- low payoff for a moderate refactor. Documented float32 as experimental (dtype docstring + .context/issue-63/perf_findings.md); float64-CUDA (4.5x, bit-safe, already shipped in #63) is the production GPU path.

This PR documents the limitation. #70 stays open for the mixed-precision refactor if the payoff is later judged worth it; no code fix here.

Investigated the float32 divergence: it NaNs on full data across every seed with
Newton on AND off (iter 9-81). NOT a divide-by-zero -- M-step denominators are
healthy (O(1e3)) until a diverged parameter overflows the next E-step. The cheap
targeted fix (responsibility logsumexp/softmax in float64) did NOT stabilize it,
so the instability is in the density / 30504-sample stat accumulation. A real fix
needs mixed precision, but the sensitive parts dominate runtime so the payoff
shrinks to ~1.5-2x -- low for the effort. Documented float32 as experimental in
the dtype docstring + perf_findings.md; float64-CUDA (4.5x, bit-safe) is the
production GPU path. Mixed precision left open in #70.
@neuromechanist neuromechanist linked an issue Jul 8, 2026 that may be closed by this pull request
@neuromechanist
neuromechanist merged commit 9354a65 into main Jul 8, 2026
7 checks passed
@neuromechanist
neuromechanist deleted the 70-stabilize-float32-amicatorchng-for-the-gpu-fast-path branch July 8, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stabilize float32 AMICATorchNG for the GPU fast path

1 participant