-
Notifications
You must be signed in to change notification settings - Fork 118
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
MPS and MPO interface updates #285
Comments
Some of these have been implemented in #290, at least the breaking changes. The rest would be new features and can be implemented after v0.1. |
@mtfishman ok to remove the 0.1 Milestone tag from this, then, if the rest of these will be post 0.1 changes? |
Yes, all of these are non-breaking. Just removed. |
It would be useful to have a function returning the normalization of an MPS with large function lognormalization(psi::MPS)
blob = dag(psi[1]) * prime(psi[1], "Link")
localZ = real((dag(blob)*blob)[])
logZ = 0.5*log(localZ)
blob /= sqrt(localZ)
for j in 2:length(psi)-1
blob = blob * dag(psi[j]);
blob = blob * prime(psi[j], "Link")
localZ = real((dag(blob)*blob)[])
logZ += 0.5*log(localZ)
blob /= sqrt(localZ)
end
blob = blob * dag(psi[length(psi)]);
blob = blob * prime(psi[length(psi)],"Link")
logZ += log(real(blob[]))
return logZ
end; |
Yes, I really like this idea. I would call it `lognorm`. It might be good
to avoid doing the contraction on the line `localZ = real((dag(blob)*blob)[])`
if possible though, since that's doing extra work. Would it not be enough
to just pull out the norm of `blob` itself at each step?
Thanks for suggesting; we should add this.
…On Thu, 21 May 2020 at 11:12, Giacomo Torlai ***@***.***> wrote:
It would be useful to have a function returning the normalization of an
MPS with large N without a gauge center (e.g. for gradient-based
optimizations of randomly initialized MPS). Depending on the initial MPS
parameters, a direct calculation of the normalization typically becomes
unstable for large N. The following function fixes the problem by
computing the log-normalization:
function lognormalization(psi::MPS)
# Site 1
blob = dag(psi[1]) * prime(psi[1], "Link")
localZ = real((dag(blob)*blob)[])
logZ = 0.5*log(localZ)
blob /= sqrt(localZ)
for j in 2:length(psi)-1
blob = blob * dag(psi[j]);
blob = blob * prime(psi[j], "Link")
localZ = real((dag(blob)*blob)[])
logZ += 0.5*log(localZ)
blob /= sqrt(localZ)
end
blob = blob * dag(psi[length(psi)]);
blob = blob * prime(psi[length(psi)],"Link")
logZ += log(real(blob[]))
return logZend;
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#285 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHJ3RNFD6EKZ2MFEXD4BKDRSVAELANCNFSM4MKAPZOQ>
.
--
-=Miles Stoudenmire=-
miles.stoudenmire@gmail.com
mstoudenmire@flatironinstitute.org
http://itensor.org/miles/
|
Yes, good point, that would be enough. |
I'm working on this right now, by the way. |
Here are some proposals for improving the MPS and MPO algebra interface:
product
that wrapscontract(::MPO, ::MPS)
that attempts to return the output site indices to the original MPS site indices (for example, with a simple call toreplace_siteinds!
). This is calledproduct
since it is very similar to theProjMPO
product
function, and you could imagine this operation being used in a global Krylov method using MPS/MPO.product(A::MPO, B::MPO)
that works likematmul(::ITensor, ::ITensor)
where the two MPOs have the same pairs of site indices, and returns an MPO with the same pairs of site indices as the input. It would do the operationmapprime(prime(A)*B,2,1)
.add(::MPS, ::MPS, ::MPS...)
for summing many MPS, with the fancier algorithm use insum(::Vector{MPS})
.contract(::MPS, ::MPS)
that is likeinner
/dot
but does not dag the first MPS, and doesn't match the site indices by default (a more literal MPS * MPS contraction).mul(::MPO, ::MPS)
/applympo(::MPO, ::MPS)
tocontract(::MPO, ::MPS)
, with an alias*
. We can also providecontract(H::MPS, psi::MPO) = contract(psi, H)
.mul(::MPO, ::MPO)
/multmpo
tocontract(::MPO, ::MPO)
.sum(::MPS, ::MPS)
toadd
/+
.And for other miscellaneous improvements:
reverse_sites!(::Union{MPS,MPO})
to reverse the site ordering of the MPS/MPO (useful for some quantum computing applications, where you might want to reverse the qubit ordering).Vector(::MPS)
andMatrix(::MPO)
conversion which converts an MPS/MPO into the equivalent exponentially large Vector or Matrix (useful for ED comparisons).MPO(sites)
function that fills withEmpty
ITensors.MPO(...)
constructors that accept an element type.*(x::Number, ::AbstractMPS)
, instead of multiplying the middle tensor byx
, instead multiply the tensors between the left and right orthogonality center byx^(1/N)
whereN
is the distance betweenllim
andrlim
.norm
for MPS/MPO.lognorm
andloginner
/logdot
for MPS/MPO (proposed here).MPS(sites)
wherelength(sites) == 1
doesn't work right now.setindex!
that does not change the orthogonality center, for operations that you know will not affect the orthogonality center.The text was updated successfully, but these errors were encountered: