-
Notifications
You must be signed in to change notification settings - Fork 216
Pivoting QR decomposition #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think this PR is almost ready to be reviewed. I have the specs left to write but this should pretty quick as it mainly is a small modification of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for QR factorization with column pivoting to the linear algebra library. The implementation leverages the LAPACK geqp3 routine and extends the existing qr interface to support pivot tracking.
- Adds pivoting QR factorization via
geqp3LAPACK routine - Extends
qr()andqr_space()interfaces to support column pivoting with pivot output - Includes comprehensive test coverage for tall, wide, and rank-deficient matrices
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/linalg/test_linalg_pivoting_qr.fypp | Comprehensive test suite for pivoting QR factorization across different matrix types and configurations |
| test/linalg/CMakeLists.txt | Adds pivoting QR test to build system |
| src/stdlib_linalg_qr.fypp | Implements pivoting QR factorization routines and workspace calculation |
| src/stdlib_linalg_lapack.fypp | Adds LAPACK geqp3 interface for QR with column pivoting |
| src/stdlib_linalg.fypp | Extends public interface with pivoting QR subroutines |
| src/lapack/stdlib_linalg_lapack_aux.fypp | Adds error handler for geqp3 LAPACK routine |
| example/linalg/example_pivoting_qr_space.f90 | Example demonstrating pivoting QR with pre-allocated storage |
| example/linalg/example_pivoting_qr.f90 | Basic example demonstrating pivoting QR factorization |
| example/linalg/CMakeLists.txt | Adds pivoting QR examples to build system |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1045 +/- ##
=========================================
Coverage ? 68.55%
=========================================
Files ? 396
Lines ? 12746
Branches ? 1376
=========================================
Hits ? 8738
Misses ? 4008
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Modulo the issue with the |
jvdp1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @loiseaujc . Overall LGTM. I just have some minor suggestions.
perazz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this implementation @loiseaujc, great work.
I stand by @jvdp1's comments, and I added a few edits/typos.
Overall, looks good to me with the above.
Co-authored-by: Federico Perini <[email protected]>
Co-authored-by: Federico Perini <[email protected]>
Co-authored-by: Federico Perini <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Federico Perini <[email protected]>
|
Everything seems to be working as expected now. The issue with one of the workspace query. Not exactly sure though what the exact problem was since, before I fixed it, the allocated workspace was larger than needed (if my understanding is correct). In any case, it works. |
|
LGTM @loiseaujc, just: is there a reason for keeping forall? This is a deprecated feature of the language, we should avoid introducing it within new code. |
This is great @loiseaujc - would you mind to squash all commits between 0cfaf2f and aa294c6? So we can see what the global changes are. LGTM otherwise |
|
Sure, I'll wrap and tidy everything up tomorrow. |
|
Alright guys, I can't quite get what is happening with forall(i=1:min(r1,m),j=2:n) r(i,j) = merge(amat(i,j),zero,i<=j)with do concurrent(i=1:min(r1, m), j=2:n)
r(i, j) = merge(amat(i, j), zero, i <= j)
enddothe test fails. Yet, in both cases, the do j = 2, n
do i = 1, min(r1, m)
if (i <= j) then
r(i, j) = amat(i, j)
else
r(i, j) = zero
endif
enddo
enddothe whole thing works again as expected. My understanding is that all of these three loops should be essentially compiled to the exact same set of instructions. Have you ever seen that? Could that be some kind of compiler bug (although really hard to track) or related to a possible memory leak somewhere? In any case, how should we proceed? Do we keep the |
|
I do have had bad surprises with ifort 19.1 and do j = 2, n
do i = 1, min(r1, m)
r(i, j) = merge(amat(i, j), zero, i <= j)
enddo
enddoLooking at it... I do wonder even if it can seem too basic ... could the issue be in the evaluation of |
|
Nice idea but didn't help. We'll stick with the nested loops then. |
I just use GitHub Desktop - you select the range of commits you want to squash -> right click -> squash, it will do the job. For a command-line version, asking an AI would probably be best |
I don't have intel-classic 2021.10 on my computer. Debugging via Github Actions calls (hopefully) Debugging intel classic Debug intel classic Debugging intel Debug intel-classic. Change error metric. Revert "Further simplification of the interface fyyp-template." This reverts commit b7a4475. Revert "Debug ubuntu-22.04/cmake/intel-classic" This reverts commit c2fbf36. Trying to pinpoint which test fails with intel. Pinpoint which exact check is failing. Pinpoint which check is failing. Fix typo Force Q and R to zero instead of ieee_value. Print maximum reconstruction error. Debug prints. Debug prints Debug prints Additional debug prints Deterministic matrix to verify output. Check tau vector. Deterministic vandermonde matrix. Force pivot to zero. Print pivots Fix query workspace ? Fix workspace query ? Restoring checks. Restoring checks. Restoring tests. Clean-up tests. Reactivating tests. Cleaned-up code. Replaced forall with original do concurrent. Restore random matrix for the pivoting qr tests. Revert "Replaced forall with original do concurrent." This reverts commit 9c8473c. Replaced forall with do concurrent. Pinpointing which test fails. Fix typo in print Debug prints Deterministic matrix to have reproducible error. Debug prints. Debug print Trying different loop structure Fixing issue with do concurrent and intel. Try José idea to fix intel do concurrent. Revert "Try José idea to fix intel do concurrent." This reverts commit 55a4b3e. Turn on back the other tests.
|
Alright, I've squashed everything (using Git Kraken). Not entirely sure what the resulting git tree is supposed to look like (first time I used this). |
perazz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot for the edits @loiseaujc
Following #930, this PR extends the
qrinterface to enable the computation of the QR factorization with column pivoting. It is based on thexGEQP3driver fromlapack.Proposed interfaces
call qr(a, q, r, pivots [, overwrite_a, storage, err])where
ais the matrix to be factorized,qthe orthonormal basis forcolspan(a),rthe upper triangular matrix andpivotsan integer array with indices of the pivoted columns.Progress
Ping: @perazz, @jvdp1, @jalvesz