-
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
Replace Gram-Schmidt method by QR for random Chain initialization #175
Conversation
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.
Can't you reuse the map(1:n) do i
block but just changing the line A = gramschmidt!(rand(rng, T, χl, χr * p))
for A, _ = qr!(rand(rng, T, χl, χr * p))
.
Is there another reason for refactoring to a for
loop?
src/Ansatz/Chain.jl
Outdated
(isodd(n) && i == n ÷ 2 + 1) ? (χl, χl) : (after_mid ? (χr, χl) : (χl, χr)) | ||
end | ||
# Left boundary tensor | ||
F = lq!(rand(rng, T, 1, p * min(χ, p))) |
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.
Why lq!
and not qr!
?
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.
lq!
is useful here since we want the Chain
to be in the right-canonical form. We could do it with qr!
too but it would involve some permutations and reshapes, which is much elegantly solved with lq!
.
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 we changed lq!
for qr!
and we reshaped the physical leg with the left bond, we would get a left-canonical Chain
.
We can, but then we would have to put conditions for the first and last tensor, which seems more ugly. |
In this PR, we replace the former Gram-Schmidt method for random chain initialization by a
QR
method, which applies theqr
decomposition to some random tensors in order to get a randomly normalized right-canonizedMPS
.Additionally, we benchmarked both methods and we conclude that the new method outscales the former in terms of running time, memory required and allocations produced.
Comparison
·
Gram-Schmidt
method:·
QR
method: