Repository navigation
docs: float32 precision limits (#70 investigation) - #71
Merged
neuromechanist merged 1 commit intoJul 8, 2026
Merged
Conversation
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
deleted the
70-stabilize-float32-amicatorchng-for-the-gpu-fast-path
branch
July 8, 2026 02:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/softmaxin 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.