-
Notifications
You must be signed in to change notification settings - Fork 4
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
[ITensorMPS] [BUG] Default algorithm for adding MPSs leading to large bond dimensions #86
Comments
Thanks for the report @shinaoka, what if you set the cutoff to something bigger than |
Thank you for the quick reply. With 1e-16, I got the correct bond dimension 10. BTW, I am sitting on the 9th floor of Flatiron Institute now. |
Ok, thanks for confirming. As I suspected, I think this is due to floating point roundoff errors, but probably we can hard code an upper bound on the final bond dimensions based on the input bond dimensions, say as the sum of the input bond dimensions on each bond.
Sounds good, how long will you be around for? I'm on parental leave, I'll be back to work officially October 28. |
Thank you for the suggestion. But, we would rather use the I will be at CCQ until the middle of December. |
EDIT (since I misread your question originally): The
Great, I'll see you at CCQ then. |
Thank you for the explanation. Yes, I have an implementation of the variational algorithm for sums of states. I will give a try to densitymatrix + fitting. |
Let me know how it goes, I'll be interested to hear if that works well. |
Sorry, just one more question.
What specifically does “better scaling” refer to? I naively assumed that the computational time of both algorithms scales as |
Yeah, saying it has better scaling may not have been quite precise enough, I think the difference is in the prefactors. But the basic idea is that with the If you are summing many MPS, say |
I observed that "densitymatrix" + "fit" restores the correct bond dimension. using ITensors
using Random
import FastMPOContractions as FMPOC
L = 10
sites = [Index(2, "s=$n") for n in 1:L]
Random.seed!(1234)
A = 0.0 * randomMPS(ComplexF64, sites; linkdims=10)
B = randomMPS(ComplexF64, sites; linkdims=10)
AB = +(A, B; cutoff=1e-25, maxdim=typemax(Int))
@show maxlinkdim(AB)
truncate!(AB)
@show maxlinkdim(AB)
function _fitsum(
input_states::AbstractVector{T},
init::T;
coeffs::AbstractVector{<:Number}=ones(Int, length(input_states)),
kwargs...,
) where {T}
if !(:nsweeps ∈ keys(kwargs))
kwargs = Dict{Symbol,Any}(kwargs)
kwargs[:nsweeps] = 1
end
Ψs = [MPS(collect(x)) for x in input_states]
init_Ψ = MPS(collect(init))
res = FMPOC.fit(Ψs, init_Ψ; coeffs=coeffs, kwargs...)
return T(collect(res))
end
AB_ref = +(A, B; alg="directsum")
truncate!(AB_ref; cutoff=1e-25, maxdim=typemax(Int))
@show maxlinkdim(AB_ref)
AB_fit = _fitsum([A, B], AB; cutoff=1e-25, maxdim=typemax(Int))
@show maxlinkdim(AB_fit)
|
Thanks for confirming that. For now I think the simplest solution which would fix the original problem you brought up is to set a maximum dimension of the output link indices as the sum of the bond dimensions of the input link indices, analogous to what we do in the |
Thank you for your efforts in the development.
Description of bug
Adding an MPS with an MPS representing 0 with the default algorithm leads to a larger bond dimension than that obtained with the directsum algorithm
Minimal code demonstrating the bug or unexpected behavior
Minimal runnable code
Expected output or behavior
Since
A=0
, we should be able to restore the original bond dimension (=10).Actual output or behavior
The bond dimension of the result is much larger than the expected one, even after an explicit truncation.
Output of minimal runnable code
Version information
versioninfo()
:using Pkg; Pkg.status("ITensors")
:The text was updated successfully, but these errors were encountered: