Skip to content

Reduce occurrences of intrinsic stdlib_matmul test failures#1110

Merged
perazz merged 3 commits intofortran-lang:masterfrom
loiseaujc:fix_intrinsic_matmul_error
Jan 30, 2026
Merged

Reduce occurrences of intrinsic stdlib_matmul test failures#1110
perazz merged 3 commits intofortran-lang:masterfrom
loiseaujc:fix_intrinsic_matmul_error

Conversation

@loiseaujc
Copy link
Contributor

Following the discussion in #1086 about the intrinsic test failure, this PR implements the following changes to the test_matmul (intrinsic module) :

  • All matrices used in the test have now been normalized to have unit-norm (1-norm).
  • The error check has been replaced from element-wise checks to 1-norm norm of the difference.

As far as I can recall, the error estimates are basically correct, although sharper ones could be used but I haven't been able to find my old lecture notes yet about matrix-matrix multiplications and floating point error analysis. In the mean time, this should (hopefully) reduce the number of times the CI fails on these tests. Something similar could be done with the pseudoinverse tests which do fail quite regularly (the single precision mostly I believe).

ping: @perazz, @jvdp1, @jalvesz

@loiseaujc loiseaujc marked this pull request as ready for review January 30, 2026 09:08
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.55%. Comparing base (0ede301) to head (c50bf31).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1110   +/-   ##
=======================================
  Coverage   68.55%   68.55%           
=======================================
  Files         396      396           
  Lines       12746    12746           
  Branches     1376     1376           
=======================================
  Hits         8738     8738           
  Misses       4008     4008           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, we're switching from a max absolute value to an average column absolute value, looks perfectly reasonable to me. LGTM @loiseaujc

Copy link
Contributor

@jalvesz jalvesz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should indeed be more robust, LGTM @loiseaujc

@loiseaujc
Copy link
Contributor Author

From what I understand, we're switching from a max absolute value to an average column absolute value, looks perfectly reasonable to me. LGTM @loiseaujc

Indeed. Basically, for the product of two matrices, it is relatively to show that

$$ \vert\vert AB - \mathrm{fl}(AB) \vert\vert_1 \leq n \cdot \varepsilon \cdot \vert\vert A \vert\vert_1 \cdot \vert\vert B \vert\vert_1 $$

where $\varepsilon$ is the floating-point unit and $\mathrm{fl}( \cdot )$ denotes the actual floating-point operation. The maximum of the absolute value of the difference is not a matrix norm, and I can't say anything about how it should behave in general.

@perazz perazz merged commit 5a4b3bf into fortran-lang:master Jan 30, 2026
92 of 93 checks passed
@loiseaujc
Copy link
Contributor Author

Awesome. Next PR coming will try to fix the pseudoinverse one.

@loiseaujc loiseaujc deleted the fix_intrinsic_matmul_error branch January 30, 2026 13:55
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.

3 participants