-
Notifications
You must be signed in to change notification settings - Fork 124
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
[NDTensors] [ITensors] Implement optional rank reduction for QR/RQ/QL/LQ decompositions #1099
Open
JanReimers
wants to merge
118
commits into
ITensor:main
Choose a base branch
from
JanReimers:QXRankReduction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 99 commits
Commits
Show all changes
118 commits
Select commit
Hold shift + click to select a range
f10e2d3
Refactor: Breakout index fixing in qr() for empty left/right indices
JanReimers cd88e80
qr decomp, switch to using combiners for gathering indices.
JanReimers 9de2ff6
Handle empty index collections on Q or R.
JanReimers dfb66e0
Fix known block sparse failing use case
JanReimers 9752128
Add attribution for Niklas
JanReimers 253b5ec
Add qr test on autoMPO generated block sparse tensors
JanReimers c43814f
Move block sparse QR into NDTensors layer where it belongs.
JanReimers 24c2ff7
Run the formatter
JanReimers 78c556f
Fix qr overload disambiguation problem in julia 1.6
JanReimers 401eef3
Add flux checks for block sparse qr tests
JanReimers c6486eb
Implement RQ decomposition.
JanReimers 6e84eb6
Add rq decomp for block sparse matrices
JanReimers 3424827
Add test for positive=true and rq decomp
JanReimers ecd8931
Implement QL/LQ decompositions
JanReimers b75f40d
Add tests for ComplexF64 and upper /lower checks for R/L
JanReimers 93c391f
Fix flakey fail of NDTensors unit tests
JanReimers fd8546c
Endless struggle to get julia to see symbols I *already* put in expor…
JanReimers 3b4962e
Removed unused version qr()
JanReimers 3464d7f
Implement rank reducing QR/RQ/QL/LQ
JanReimers 2a2391e
Pass through kwargs for LQ/QL functions
JanReimers b9dbda7
Run the formatter
JanReimers 0f8c092
Try and fix lq symbol clash exposed in julia 1.8
JanReimers 53fc8a0
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers d0989cc
Merge from RQQLLQ branch
JanReimers 4b6ed1a
Merge branch 'ITensor:main' into main
JanReimers d14fb6d
Merge branch 'main' into QXRankReduction
JanReimers 990f8ca
Run formatter on Rank Revial code
JanReimers 67d3594
Augment unit tests to check all index directions are QR decomp
JanReimers ba0bfdd
Fix QN direction of qx link for rq decomp.
JanReimers 79adbd0
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers 46b7571
Fix flux tests to reflect new QN dir fix for rq decomp
JanReimers ac1e53c
Merge branch 'ITensor:main' into main
JanReimers 3b49821
Merge branch 'main' into QXRankReduction
JanReimers ce7512c
Fix flux tests to reflect new QN dir fix for rq decomp
JanReimers ad726dc
Remove direction tests
JanReimers 35690ec
Merge branch 'main' into RQQLLQ
mtfishman 82cef17
Merge branch 'ITensor:main' into main
JanReimers d05220d
Improvements based on Matt's code review
JanReimers 06bf618
Merge branch 'main' into QXRankReduction
JanReimers 48c5164
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers ce72646
Merge branch 'ITensor:main' into main
JanReimers 5d7efd3
Merge branch 'main' into QXRankReduction
JanReimers 7059446
Use map for testing zero rows.
JanReimers 405014e
Change from using epsrr to rr_cutoff for zero row threshold.
JanReimers cf7ef37
Merge remote-tracking branch 'origin/main' into BlocksparseQR
JanReimers 2fe0fa3
Merge branch 'BlocksparseQR' into RQQLLQ
JanReimers e937732
Handle changes to similar() function interface.
JanReimers 01d86f4
Add QR/RQ code to ensure all flux is moved onto R
JanReimers 3ac4267
Implement all but one of Matts code review recommendations
JanReimers 0d0d120
Run the formatter
JanReimers 2a93b6e
Remove NDTensors. qualifiers
JanReimers 1e8830d
Put keyword arguments directly in signatures
JanReimers 84a6f20
Fix flux requirements at the NDTensors level.
JanReimers cf722ef
Format
JanReimers 7e39a55
Fix double swap of Q & L in the ql() function
JanReimers eb955be
Use generic function for most of the qr/ql operations.
JanReimers df6c07f
Implement core qx functions accepting both Linds and Rinds
JanReimers 9223523
Format
JanReimers 462ffbf
Stri[ out extra indices in Linds, not in A.
JanReimers 9f80aa2
Move Heisenberg and Hubbards MPO QR tests over legacy area.
JanReimers f931cbe
Format
JanReimers a31fb5c
Strip out extra indices in Linds, not in A.
JanReimers 492443c
Move Heisenberg and Hubbards MPO QR tests over legacy area.
JanReimers 35e560f
Format
JanReimers 9128de9
NDTensors unit, switch rq to ql decomp.
JanReimers 82c18f1
Merge remote-tracking branch 'origin/RQQLLQ' into RQQLLQ
JanReimers 9e86676
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers cb1f0d1
Finish merge and get all decomp unit test working.
JanReimers 32972cc
Use more likely to pass a String rather than a tagset
JanReimers aa29914
Format
JanReimers ca39f9c
Merge remote-tracking branch 'origin/main' into RQQLLQ
JanReimers d4709c4
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers 858e070
Fix bug in ql_positive routine
JanReimers 885dfe9
Remove some debug code.
JanReimers 5ee47bf
Fix: UndefVarError: tensor not defined
JanReimers 420241d
Qualify tensor()
JanReimers 8596e72
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers 5e72caa
Stop using Printf at the NDTensors level.
JanReimers 2b10908
Enhance unit tests for qr/ql decomp
JanReimers 3b5072d
Format
JanReimers 59542df
Don't assume lapack qr/ql returns reals on the R/L diagonals
JanReimers 042578b
Avoid type piracy in unit test code
JanReimers e6ff0e6
Remove unnessecary usage of where {ElT}
JanReimers af73844
Pass tags as a keyward argument. And format.
JanReimers e191c1d
Merge remote-tracking branch 'origin/main' into RQQLLQ
JanReimers 6d3f6b3
Use new randomTensor(ElT,tuple) interface
JanReimers 4a16f3d
Eliminate where{IndsT} for dense qr/ql
JanReimers 11d43a4
Merge remote-tracking branch 'origin/main' into QXRankReduction
JanReimers 49df0be
Merge remote-tracking branch 'origin/RQQLLQ' into QXRankReduction
JanReimers e53c85b
Handle zero pivots gracefully with the new sign(diag) code.
JanReimers 04cccd7
Remove where {T} for low level ql routine.
JanReimers b22f8a3
Format
JanReimers 43d914f
Merge branch 'RQQLLQ' into QXRankReduction
JanReimers 3a8159c
Merge remote-tracking branch 'origin/main' into QXRankReduction
JanReimers 0492071
Clean up and comment code.
JanReimers 62ed9cc
Format and add rr-verbose flag for optional rank reduction output.
JanReimers 0ec04b7
Remove the old test/decomp/jl file
JanReimers 1961520
Set Random seed to keeps tests deterministic.
JanReimers 491b830
Can't use Random on the NDTensors CI machine
JanReimers 9aff488
Merge branch 'main' into QXRankReduction
mtfishman f8976f9
Merge remote-tracking branch 'origin/main' into QXRankReduction
JanReimers fdce8fe
Fix names cutoff and verbose
JanReimers 543d355
Unify positive gauge fix for qr/ql
JanReimers 4d22400
Implement colunm pivoting with row removal
JanReimers 1540aac
Format
JanReimers 0cdc115
Fix some unit test fails.
JanReimers 9da7b54
For column Pivot QR, return column permutation arrays.
JanReimers a954c54
Merge remote-tracking branch 'origin/main' into QXRankReduction
JanReimers be0074d
Support atol/rtol interface for column pivot qr
JanReimers a86f4cf
Support the new NoPivot, ColumnNorm types
JanReimers cde6dad
Support Matts proposed interface
JanReimers c790493
Support ql decomp using the MatrixFactorizations package
JanReimers 9fa3dd3
Try to avoid warnings in julia 1.8.5
JanReimers afe67fd
Format
JanReimers 99abd4d
Try and avoid breaking ITensorGPU
JanReimers 6091157
Try and avoid breaking ITensorGPU
JanReimers e33dd47
Merge remote-tracking branch 'origin/main' into QXRankReduction
JanReimers 6b747dd
Switch from returning permutations to returning Rp.
JanReimers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
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.
I would just name these keyword arguments
cutoff
andverbose
(i.e. drop therr_
).Also,
cutoff
has a particular meaning in the context of SVD, where it is the sum of squares of the singular values.I see here it is used as:
so is checking that the maximum value in the row is less than the cutoff value/tolerance. Is that a standard approach for reducing the rank?
Maybe we can look at https://github.com/JuliaLinearAlgebra/LowRankApprox.jl and see what conventions they use for performing the rank reduction and what they call the keyword arguments (I see
rtol
andatol
being used, which is used elsewhere in Julia say may be good choices).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.
Issue 1) Do we need a distinct name for the rank revailing cutoff? Right now I have to code set up so that the user can just call truncate!(InfiniteMPO) without first calling orthogonalize!(InfiniteMPO). The truncate function checks if the iMPO is already orthogonalized and if not is calls orthogonalize before truncating with svd. So with this setup we need distinct control of Rank Revealing QR cutoff and the svd cutoff. rtol would work for this.
Issue 2) How to decide if a row is effectively zero? Here is what Daniel Parker says:
I looked in his thesis and there is no more info on this topic.
I agree that testing rr_cutoff > sqrt(sum(X[r, 1:Xnc]^2)) is closer to what svd truncation does.
Issue #3: Hornets nest: Conventional rank reducting QR does not do what Daniel did. Conventional methods do column pivoting QR, which is akin to "I am not going to solve A=QR for you, instead I am going solve AP=QR, where P is a column permutation matrix" This puts all near zero rows of R into the lower right corner. It acutally orders the diagonals of R similar singular value ordering. Maybe Parker purposely avoided this because he knew it would jumble up the MPOs and destroy his regular form. Maybe column pivoting QR and doing A = QP^T PRP^T (P^T=transpose(P)) would get us back to where we are now, but I haven't tried it. We could insist the library needs to support conventional rank reducting QR with colunm pivoting, not Daniels version , but I think users want to solve A=QR, not AP=QR, in other words they don't want to be told "Sorry I am not solving your problem, I will only solve my choice of problem". Maybe there is an easy solution and I am just not seeing it.
Perhaps I should email Daniel and get his opinion on max(abs(row)) vs. rms(row), and if column pivoting QR was tested and rejected for some reason.
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.
Within the
qx
functions, there is no fundamental reason why it needs a distinct name fromcutoff
. If we choosecutoff
, we can choose different names in the higher level functions liketruncate!(::MPO)
to distinguish between theqr
truncation tolerence/cutoff and thesvd
truncation/cutoff, for example with a code pattern like:However, I am just considering different options since the
qx
tolerance/cutoff seems to have a different meaning from thesvd
tolerance/cutoff, and it may be nice to keep consistency with packages likeLowRankApprox.jl
(or use that package directly for rank reducing QR).Pivoted QR is a pretty standard technique and I think it is reasonable to support that. For example, Julia has a pivoted QR:
which would give better rank reduction than non-pivoted QR:
I think it would be better to use pivoting, if possible (i.e. it would be better in general, so we should have it anyway), since it is the standard way to do rank reducing QR. We can just document that if you use pivoting and/or rank reduction then
R
is no longer guaranteed to be upper triangular (at the ITensor level, it isn't anyway because of the combiner transformation).I think fundamentally the question is, does the Parker et al. algorithm actually rely on the upper/lower triangular form, or can it be framed more generally that you can do any orthogonal decomposition that does some rank reduction and preserves the proper block structure of the MPO? I have a hard time believing that such a detail as the ordering of the states within the block should matter, since it just corresponds to a simple gauge transformation by a permutation matrix on the links of the MPO. Once you gauge to a center bond/site, the left and right orthogonality centers are combined in order to perform the SVD, which would destroy the upper/lower triangular structure you were trying to preserve anyway.
I believe @LHerviou said he found he could reformulate the algorithm in terms of any orthogonal decomposition of the MPO block, which makes intuitive sense to me based on other tensor network gauging algorithms I know of.
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.
My statement was just:
The QR/QL does not seem important to me. What seems to matter is:
1 b c
A d
1
using the convention of upper triangular iMPOs in their paper.
Depending on left or right sweep, this means, orthogonalizing b or d with respect to 1, and then doing a QR on (b, A) or (A, d).
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.
Done