Skip to content

Abelian symmetric SVD #33

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

Merged
merged 8 commits into from
May 23, 2025
Merged

Abelian symmetric SVD #33

merged 8 commits into from
May 23, 2025

Conversation

mtfishman
Copy link
Member

@mtfishman mtfishman commented May 14, 2025

This PR preserves sector information when taking the SVD of an abelian GradedMatrix.

It makes use of the block sparse matrix SVD functionality added in ITensor/BlockSparseArrays.jl#111 and ITensor/BlockSparseArrays.jl#113, and depends on the additional customization points that are being added in ITensor/BlockSparseArrays.jl#114 (which isn't merged/registered yet, so tests are failing in this PR).

Closes #29.

@lkdvos @ogauthe

Note that non-abelian symmetries aren't accounted for here. We will have to change parts of the design to account for the kronecker product structure of the blocks which is being worked out by @ogauthe, I'm considering this to be a starting point and that can be considered in future PRs.

To do:

  • Add tests.

@mtfishman
Copy link
Member Author

Also note that I've added a function called flux for getting the symmetry sector of a GradedArray, related to the discussion in #28. That helps with logic for determining the internal axes of the SVD (the ones attached to S) in the case of equivariant tensors.

@mtfishman
Copy link
Member Author

@ogauthe I noticed that similar(::GradedUnitRange) was broken, the latest commit fixes that.

Copy link
Contributor

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

Definitely looks like a very little amount of extra code is needed here to make everything work, which is very nice!

Co-authored-by: Lukas Devos <[email protected]>
)
U = similar(A, axes(A, 1), dual(u_axis))
T = real(eltype(A))
S = BlockSparseMatrix{T,Diagonal{T,Vector{T}}}(undef, (u_axis, dual(v_axis)))
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed that this is not very general (for example it would be bad on GPU), probably it should be factored out into a similar_diagonal_blocks function or something like that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, this is more or less why I had an original function _similar_S there to specialize on, since I don't think we really have the infrastructure right now to make that work.
The only thing I can come up with is trying to get type inference to tell us what the output type of initialize_output would be on the blocktypes of the input, but that also seems somewhat brittle.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would be nice to come up with a good code pattern for this. I think promote_op on initialize_output of the input blocktypes could be a good general fallback definition, and then we could use similar(a, BlockType(...)) once we define that.

Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 96.42857% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.23%. Comparing base (4779a52) to head (a1e9381).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/gradedarray.jl 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
+ Coverage   94.09%   94.23%   +0.14%     
==========================================
  Files          19       20       +1     
  Lines         711      763      +52     
==========================================
+ Hits          669      719      +50     
- Misses         42       44       +2     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@mtfishman mtfishman marked this pull request as ready for review May 23, 2025 13:22
@mtfishman mtfishman changed the title [WIP] Abelian symmetric SVD Abelian symmetric SVD May 23, 2025
@mtfishman mtfishman closed this May 23, 2025
@mtfishman mtfishman reopened this May 23, 2025
@mtfishman mtfishman merged commit 4f322a8 into main May 23, 2025
19 of 32 checks passed
@mtfishman mtfishman deleted the svd branch May 23, 2025 13:44
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.

[BUG] TensorAlgebra.svd drops sectors
2 participants