Canonicalize NaN output in every value-producing routine (C1)#15
Merged
Conversation
SoftFloat is deterministic but propagates a (quieted) NaN payload, so a
non-canonical NaN input produced a non-canonical NaN output -- and only 5
of 40 routines (the asum family + qaxpy) canonicalized. Identical-
magnitude results could therefore be unequal nouns depending on the input
NaN payload.
Apply nan_unify_{h,s,d,q} to the output of every value-producing routine:
dot, nrm2, scal, copy, swap, axpy, gemv (per written element / scalar
result) and gemm (per written C element), across all four precisions.
iamax is excluded (it returns an index, not a float). Copy and swap
canonicalize the NaNs they move, per the "all NaNs equal" contract.
New test_nan.c feeds a non-canonical NaN through each operation and
asserts the canonical pattern out (SINGNAN/DOUBNAN/HALFNAN), covering
every op in single precision plus d/h axpy spot-checks (q axpy already
covered by test_qaxpy_nan_unify).
161/161 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
SoftFloat is deterministic but propagates the (quieted) NaN payload — so a non-canonical NaN input produced a non-canonical NaN output, and only 5 of 40 routines (the
asumfamily +qaxpy) canonicalized. Identical-magnitude results could be unequal nouns depending on the input NaN payload — which matters for Hoon equality. Per the decision to canonicalize everything:nan_unify_{h,s,d,q}to the output of every value-producing routine:dot,nrm2,scal,copy,swap,axpy,gemv(per written element / scalar result) andgemm(per writtenCelement), all four precisions.iamaxexcluded (returns an index).copy/swapcanonicalize the NaNs they move.test_nan.cfeeds a non-canonical NaN (…0001) through each op and asserts the canonical pattern out — every op in single precision +d/haxpy spot-checks (qaxpy already covered).161/161 pass. Generalizes the
qaxpyfix (B2/#12) to the whole library.🤖 Generated with Claude Code