-
Notifications
You must be signed in to change notification settings - Fork 1
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
svd for Tensor including optional truncation + compression method in progress #326
Conversation
josepamigoo
commented
Feb 6, 2025
- Addition of maxdim argumnent in LinearAlgebra.svd in Numerics.jl
- First steps of compression method for MPS (further development needed)
src/Numerics.jl
Outdated
@@ -201,6 +201,12 @@ function LinearAlgebra.svd(tensor::Tensor; left_inds=(), right_inds=(), virtuali | |||
s = Tensor(s, [virtualind]) | |||
Vt = Tensor(reshape(conj(V), right_sizes..., size(V, 2)), [right_inds..., virtualind]) | |||
|
|||
if maxdim !== nothing |
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.
if maxdim !== nothing | |
if isnothing(maxdim) |
src/Numerics.jl
Outdated
U=view(u, virtualind => 1:maxdim) | ||
s=view(s, virtualind => 1:maxdim) | ||
Vt=view(v, virtualind => 1:maxdim) |
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.
just some formatting so that it passes the format check
U=view(u, virtualind => 1:maxdim) | |
s=view(s, virtualind => 1:maxdim) | |
Vt=view(v, virtualind => 1:maxdim) | |
U = view(u, virtualind => 1:maxdim) | |
s = view(s, virtualind => 1:maxdim) | |
Vt = view(v, virtualind => 1:maxdim) |
thanks @josepamigoo! are you planning to continue working on this PR or do you want to get this PR merged soon? the compression part is not yet finished but the SVD think could be merged fast, so depending on what you're planning we can move the changes to MPS.jl to another PR or leave it here |
i think it would be useful to merge the SVD part first and continue working with the changes to MPS.jl in a separate PR |
great, then do you mind removing the changes to MPS.jl from this PR? |
done! |
Forgot to make the suggested changes (and the some typo I didn't notice). Format check still failling though. |
src/MPS.jl
Outdated
@@ -727,4 +727,4 @@ function LinearAlgebra.normalize!(config::Canonical, ψ::AbstractMPO; bond=nothi | |||
end | |||
|
|||
return ψ | |||
end | |||
end |
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.
end | |
end | |
I think that with my last proposal the format check should pass. Remind me next week to teach you how to run the formatter. |
Also, do you mind adding a lil test on "test/unit/Numerics_test.jl"? If you feel lost, we can do it on Monday. |
src/Numerics.jl
Outdated
@@ -201,6 +201,12 @@ function LinearAlgebra.svd(tensor::Tensor; left_inds=(), right_inds=(), virtuali | |||
s = Tensor(s, [virtualind]) | |||
Vt = Tensor(reshape(conj(V), right_sizes..., size(V, 2)), [right_inds..., virtualind]) | |||
|
|||
if isnothing(maxdim) |
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.
if isnothing(maxdim) | |
if !isnothing(maxdim) |
right?
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.
yes, thanks!
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.
ups, that was my fault 😅
I will take a look at it, but it will be helpful to talk about it on Monday yes. |
I uploaded a small test, tell me if you had something similar in mind |
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.
this is great! just what i had in my mind
only one change request (if you are already in the "svd" testset, you don't need to name it again in "svd truncated"; you can just name it "truncated")
test/unit/Numerics_test.jl
Outdated
@test isapprox(contract(contract(U, s; dims=Symbol[]), V), tensor) | ||
end | ||
|
||
@testset "svd truncated" begin |
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.
@testset "svd truncated" begin | |
@testset "truncated" begin |
ah wait, the CI tests say that there is an error in your implementation
|