Repository navigation
Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
81ffe33 to
cdd38cc
Compare
cdd38cc to
2a851fb
Compare
| _svd_rank_bound(::TruncationStrategy, c, n) = nothing | ||
| function _svd_rank_bound(strategy::TruncationByOrder, c, n) | ||
| _keeps_largest(strategy) || return nothing | ||
| # values in block `c` are weighted by `dim(c)` | ||
| return min(n, floor(Int, strategy.howmany / dim(c))) | ||
| end | ||
| function _svd_rank_bound(strategy::TruncationSpace, c, n) | ||
| _keeps_largest(strategy) || return nothing | ||
| return min(n, dim(strategy.space, c)) | ||
| end | ||
| function _svd_rank_bound(strategy::TruncationIntersection, c, n) | ||
| bounds = map(s -> _svd_rank_bound(s, c, n), strategy.components) | ||
| all(isnothing, bounds) && return nothing | ||
| return minimum(b for b in bounds if !isnothing(b)) | ||
| end | ||
| function _svd_rank_bound(strategy::TruncationUnion, c, n) | ||
| bounds = map(s -> _svd_rank_bound(s, c, n), strategy.components) | ||
| any(isnothing, bounds) && return nothing | ||
| return maximum(bounds) | ||
| end |
There was a problem hiding this comment.
Given that we use n as a maximum value for those truncation strategies that do provide an explicit bound, is there a problem also using n if there is no explicit bound?
| function MAK.svd_trunc!(t::AdjointTensorMap, F, alg::RandomizedSVDAlgorithm) | ||
| U, S, Vᴴ, ϵ = svd_trunc!(adjoint(t), reverse(adjoint.(F)), _adjoint(alg)) | ||
| return Vᴴ', S, U', ϵ | ||
| end |
There was a problem hiding this comment.
Is this definition specific to RandomizedSVDAlgorithm? It seems like this should work for any alg. Also, does svd_trunc_no_error! have or need a similar definition, for users that call that method directly?
There was a problem hiding this comment.
The general method seems in place (as expected), so why do they not capture this? Is this an ambiguity issue again? But why?
(No general method for svd_trunc_no_error! is in place, don't know if it is useful to add this.)
There was a problem hiding this comment.
Indeed it's an ambiguity error (also for initialize_output). Sorry for the horribly long dump here:
MethodError: svd_trunc!(::TensorKit.AdjointTensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 2, 2, TensorKit.TensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 2, 2, CUDACore.CuArray{Float64, 1, CUDACore.DeviceMemory}}}, ::Tuple{TensorKit.AdjointTensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 2, 1, TensorKit.TensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 1, 2, CUDACore.CuArray{Float64, 1, CUDACore.DeviceMemory}}}, TensorKit.DiagonalTensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, CUDACore.CuArray{Float64, 1, CUDACore.DeviceMemory}}, TensorKit.AdjointTensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 1, 2, TensorKit.TensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, TensorKit.SortedVectorDict{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.FermionParity, TensorKitSectors.SU2Irrep, TensorKitSectors.U1Irrep}}, Int64}}, 2, 1, CUDACore.CuArray{Float64, 1, CUDACore.DeviceMemory}}}}, ::MatrixAlgebraKit.TruncatedAlgorithm{MatrixAlgebraKit.CUSOLVER_Randomized{@NamedTuple{}}, MatrixAlgebraKit.TruncationByOrder{typeof(abs)}}) is ambiguous.
Candidates:
svd_trunc!(t::TensorKit.AdjointTensorMap, F, alg::MatrixAlgebraKit.TruncatedAlgorithm)
@ TensorKit.Factorizations ~/.julia/dev/TensorKit/src/factorizations/adjoint.jl:127
svd_trunc!(t::TensorKit.AbstractTensorMap, USVᴴ, alg::MatrixAlgebraKit.TruncatedAlgorithm{<:MatrixAlgebraKit.CUSOLVER_Randomized})
@ TensorKit.Factorizations ~/.julia/dev/TensorKit/src/factorizations/randomized.jl:101
I'll see if I can't get the one in adjoint.jl to play fair
There was a problem hiding this comment.
Maybe then AdjointTensorMap should not be handled via a separate method definition, but via a simple branch inside the algorithms, i.e. svd_trunc!(t::AbstractTensorMap, USVᴴ, alg) should start with
if t isa AdjointTensorMap
svd_trunc(t', reverse(map(adjoint, USVᴴ)), _adjoint(alg))
return ...
end
...I think we've come across such issues before, where we had to do the method specialization in stages.
Not sure about keeping the
CUSOLVER_Randomizedname, we might want to patch something in MAK for that...