Conversation
Floor the reference magnitude at SAFMIN when forming the NRM2 test ratio. Subnormal results incur absolute rounding error of order SAFMIN*ULP, which a purely relative tolerance can reject. Apply the comparison to all four precisions and tighten the zero-reference case. Add a fixed subnormal value and an unrandomized tail alongside every existing randomized case. The value has to sit in a narrow window: deep enough that one subnormal ulp is a relative error above THRESH*N*ULP, and shallow enough that the reference and NRM2 still round differently. The chosen values fail the old comparison with test ratios of 3.2E+02 to 2.7E+03 against THRESH = 10, in all four precisions and both index APIs. A named parameter selects the unrandomized case so that it does not follow the end of the value list. Each norm test now runs 1946 checks instead of 1610. No production BLAS or LAPACK routine changes. Validated on all eight Level 1 executables in Release static, Release shared with OpenMP and -fcheck=all, -O3 -march=native, and -O0 -g -fcheck=all; 200 repetitions per precision; 8E+07 focused subnormal draws whose largest test ratio is 0.385; and mutations that confirm flushed subnormal norms and 1% perturbed normal norms still fail.
rmlarsen
force-pushed
the
blas-nrm2-subnormal-tests
branch
from
September 16, 2026 06:38
172c6c4 to
0b0f51b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1423 +/- ##
=======================================
Coverage 69.36% 69.36%
=======================================
Files 6122 6122
Lines 486711 486723 +12
Branches 23268 23268
=======================================
+ Hits 337584 337600 +16
+ Misses 148689 148685 -4
Partials 438 438
Continue to review full report in Codecov by Harness.
|
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.
Stop the NRM2 tests from rejecting correctly rounded subnormal results: floor the reference magnitude at
SAFMINin the error denominator, which takes a false-failure rate of 6.1e-5 per draw to zero over 2e7 draws, and add deterministic subnormal cases so the regression no longer rides on a lucky random draw.The tests measure only relative error, so a subnormal result whose absolute error is one subnormal ulp is rejected outright. In #1382 an ARM64 OpenMP shared build reported ten DNRM2 failures at N=3 and INCX=0 while the tested BLAS sources were unchanged from master.
That count is the signature of the mechanism rather than a coincidence: at INCX=0 every IV row shares
X(1), so a single unlucky draw of the random tail produces exactly ten reported failures. Sampling the same configuration on x86-64 —x = 2*SAFMIN*wwithwuniform on (-1,1), compared against the referenceDNRM2— over 2e7 draws givesSNRM != ZNRMTHRESH = 10So this is neither ARM-specific nor flush-to-zero; it is a rare lottery any platform can lose. It does gate CI: #1371's
LAPACK_Test_Summaryparses the.outfiles, and #1382's own rerun failed it withfailing to pass the threshold: 10.Fix. Use
max(reference, SAFMIN)in the error denominator for all four real and complex norm tests. This is bit-identical to the current comparison for every normal result and supplies an absolute tolerance of orderSAFMIN*ULPnear underflow. It also replaces the overly permissive zero-reference branch:ZNRM == 0happens only when the whole vector is exactly zero, in which case theSNRM == ZNRMfast path already claims it, so that branch was reachable only from a broken implementation. NaN and infinity checks remain in place.Coverage. Add a fixed subnormal value and an unrandomized tail alongside every existing randomized case. The value has to sit in a narrow window: deep enough that one subnormal ulp is a relative error above
THRESH*N*ULP, and shallow enough thatSQRT(N)*xandNRM2(N,x,0)still round differently. Of2*SAFMIN/kfor k = 2, ..., 200000, only 13 values in double and 9 in single satisfy both, so the constants are commented rather than left bare, and a named parameter selects the unrandomized case instead of keying it to the end of the value list. The new cases fail the old comparison with test ratios of 3.2E+02 to 2.7E+03 in all four precisions and both index widths; each norm test now runs 1946 checks instead of 1610. No production BLAS or LAPACK routine changes.Validation on a 13th Gen Intel(R) Core(TM) i7-13700HX (x86-64, WSL2) with GNU Fortran 13.3.0:
-fopenmp -frecursive -fcheck=all,-O3 -march=native, and-O0 -g -fcheck=all, using both the default and_64APIs. Output summaries were checked for numerical failures, since executable exit status alone does not detect them;LAPACK_Test_Summaryis what turns them into a CI failure.git diff --checkpasses. Added fixed-form source lines fit within 72 columns.Under a flush-to-zero build the new value itself flushes, so the deterministic case degenerates into the existing zero case and tests nothing rather than failing;
-ffast-mathshows only the pre-existing flush-to-zero failures, at twice the count because the new row duplicates the zero row.ARM64/GNU 15.2 and other compiler configurations remain for upstream CI.
Related: #1382
Checklist