GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BLAS: Account for subnormal rounding in NRM2 tests by rmlarsen · Pull Request #1423 · Reference-LAPACK/lapack

Conversation

@rmlarsen

@rmlarsen rmlarsen commented Sep 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Stop the NRM2 tests from rejecting correctly rounded subnormal results: floor the reference magnitude at SAFMIN in 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*w with w uniform on (-1,1), compared against the reference DNRM2 — over 2e7 draws gives

SNRM != ZNRM 32% of draws, an ordinary one-subnormal-ulp disagreement
rejected by the current comparison 1229, i.e. 6.1e-5 per draw
rejected by the comparison in this PR 0, largest ratio 0.385 against THRESH = 10

So 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_Summary parses the .out files, and #1382's own rerun failed it with failing 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 order SAFMIN*ULP near underflow. It also replaces the overly permissive zero-reference branch: ZNRM == 0 happens only when the whole vector is exactly zero, in which case the SNRM == ZNRM fast 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 that SQRT(N)*x and NRM2(N,x,0) still round differently. Of 2*SAFMIN/k for 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 2.4E+02 to 2.7E+03 in all four precisions and both index widths; the complex norm tests now run 2714 checks instead of 2314, and the real ones 2715 instead of 2315. No production BLAS or LAPACK routine changes.

Validation on an AMD Ryzen Threadripper PRO 7965WX 24-Cores (x86-64, Linux) with GNU Fortran 15.2.0:

  • All eight Level 1 BLAS executables pass, 2715 norm checks each in the real and 2714 in the complex ones, in Release static, Release shared with -fopenmp -frecursive -fcheck=all, -O3 -march=native, and -O0 -g -fcheck=all, using both the default and _64 APIs. Output summaries were checked for numerical failures, since executable exit status alone does not detect them; LAPACK_Test_Summary is what turns them into a CI failure.
  • 200 repetitions of each executable in the Release static build and 20 in each of the other three, with zero failures. Separately, 8e7 focused subnormal draws across the four routines, on a 13th Gen Intel(R) Core(TM) i7-13700HX with GNU Fortran 13.3.0, give a largest test ratio of 0.385.
  • Mutation checks: reverting the comparison to the relative-only form fails 16, 16, 16 and 22 checks in S, D, C and Z, all of them in the fixed subnormal case; flushing nonzero subnormal norms to zero fails 118 to 150; perturbing normal norms by 1% fails about 1870 per precision.
  • git diff --check passes. 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-math shows 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

  • The documentation has been updated. (Test comments describe the subnormal cases, the window the fixed value has to sit in, and the error scale; public behavior is unchanged.)
  • If the PR solves a specific issue, it is set to be closed on merge. (No tracking issue; related CI failure is in PR Report a NaN or an infinity in the input of xGELSD, xGESDD, xGEEV, xLALSD and xBDSDC through INFO instead of stopping in XERBLA #1382.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rmlarsen
rmlarsen force-pushed the blas-nrm2-subnormal-tests branch from 172c6c4 to 0b0f51b Compare September 16, 2026 06:38
@codecov

codecov Bot commented Sep 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.66%. Comparing base (fab6f2c) to head (dbdfdfa).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1423   +/-   ##
=======================================
  Coverage   70.65%   70.66%           
=======================================
  Files        6243     6243           
  Lines      501410   501422   +12     
  Branches    23516    23516           
=======================================
+ Hits       354296   354312   +16     
+ Misses     146251   146247    -4     
  Partials      863      863           
Components Coverage Δ
BLAS 99.73% <ø> (ø)
CBLAS 96.95% <ø> (ø)
LAPACK 83.77% <ø> (ø)
LAPACKE 4.18% <ø> (ø)
TMGLIB 55.69% <ø> (ø)
BLAS testing 88.82% <100.00%> (+0.02%) ⬆️
CBLAS testing 89.65% <ø> (ø)
LAPACK testing 82.41% <ø> (ø)
LAPACKE testing ∅ <ø> (∅)
Files with missing lines Coverage Δ
BLAS/TESTING/cblat1.f 93.08% <100.00%> (+0.26%) ⬆️
BLAS/TESTING/dblat1.f 93.58% <100.00%> (+0.18%) ⬆️
BLAS/TESTING/sblat1.f 94.43% <100.00%> (+0.18%) ⬆️
BLAS/TESTING/zblat1.f 93.08% <100.00%> (+0.26%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fab6f2c...dbdfdfa. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmlarsen
rmlarsen force-pushed the blas-nrm2-subnormal-tests branch from 0b0f51b to c8c40ed Compare October 28, 2026 20:46
@rmlarsen rmlarsen mentioned this pull request Nov 4, 2026
Report a NaN or an infinity in the input of xGELSD, xGESDD, xGEEV, xLALSD and xBDSDC through INFO instead of stopping in XERBLA #1382
Merged
2 tasks done
@mohawk2

mohawk2 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@rmlarsen None of my business, but this is almost certainly a real improvement and justifies a nudge. It might help to rebase against latest master?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmlarsen
BLAS: Account for subnormal rounding in norm tests
dbdfdfa
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. The complex norm tests now run 2714 checks instead of 2314,
and the real ones 2715 instead of 2315. 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
rmlarsen force-pushed the blas-nrm2-subnormal-tests branch from c8c40ed to dbdfdfa Compare November 24, 2026 15:50
@rmlarsen

rmlarsen commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@mohawk2 Thanks. Rebased onto current master (dbdfdfa); there were no conflicts.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@rmlarsen @mohawk2
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.