Skip to content
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

Feature/sweep bounds #26

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

pulkin
Copy link
Contributor

@pulkin pulkin commented Jun 20, 2019

A possibility to limit bounds of sweeps in DMRG1,2. Not tested for loop networks.

@codecov
Copy link

codecov bot commented Jun 20, 2019

Codecov Report

❗ No coverage uploaded for pull request base (develop@f22ea7c). Click here to learn what that means.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop      #26   +/-   ##
==========================================
  Coverage           ?   87.96%           
==========================================
  Files              ?       31           
  Lines              ?     7720           
  Branches           ?        0           
==========================================
  Hits               ?     6791           
  Misses             ?      929           
  Partials           ?        0
Impacted Files Coverage Δ
quimb/tensor/tensor_1d.py 93.08% <100%> (ø)
quimb/tensor/tensor_dmrg.py 91.15% <89.28%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f22ea7c...9d27ee7. Read the comment docs.

Copy link
Owner

@jcmgray jcmgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @pulkin, looks useful!

Aside from the minor comments above, a few more general points:

  • The bounds specification might be made a bit clearer. Currently it says inclusive sites at one point but exclusive elsewhere. My preference would be if bounds=(s, e) meant optimize all sites in range(s, e) -- so not dependent on bsz and thus the same arg could be used for both DMRG1 and DMRG2.
  • Could you lint the code for PEP8 (>80 lines and spaces around operators etc.)

@@ -866,24 +866,39 @@ def sweep(self, direction, canonize=True, verbosity=0, **update_opts):
Sweep from left to right (->) or right to left (<-) respectively.
canonize : bool, optional
Canonize the state first, not needed if doing alternate sweeps.
bounds : tuple, optional
A 2-tuple with cites (from and to, not included) to perform the sweep
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor spelling: 'cites' -> 'sites'

p0 = MPS_rand_state(5, 1)
p0[0].data[:] = down().T

dmrg = DMRG2(H_mpo, p0=p0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to parametrize over DMRG1 and DMRG2.

bounds = bounds_ext

if (direction == "right" and bounds[0] >= bounds[1]) or (direction == "left" and bounds[0] <= bounds[1]):
raise ValueError(f"Invalid bounds for direction={direction} (wrong order): {bounds}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although f-strings are really nice, it would be good to stick to .format syntax for the moment, since notionally quimb should still support python 3.5.

@pulkin
Copy link
Contributor Author

pulkin commented Jun 20, 2019

Just to clarify: given bounds=(s, e), what do you expect in the case sweep_sequence='LR' and sweep_sequence='RL'? Which bound is included at which stage?

@jcmgray
Copy link
Owner

jcmgray commented Jun 21, 2019

So, my feeling is that the sweep should just be:

range(s, e - bsz + 1)  # for direction 'R', or
reversed(range(s, e - bsz + 1))  # for direction 'L'

So if you wanted to keep a single site held, in either DMRG1 or DMRG2 it would be

dmrg.solve(bounds=(0, mysite))
dmrg.solve(bounds=(mysite + 1, n))
...

What do you think?

@jcmgray
Copy link
Owner

jcmgray commented Jun 21, 2019

So there are some subtle complexities that require a bit more work here.

  1. The test should use a fixed site state that is not the lowest energy state - otherwise it's not testing anything. If you try this you'll see that the limited sweeping is not being restricted correctly at the moment.
  2. The addition of sites to expand_bond_dimension will currently only increase the index size of one tensor across some bonds, resulting in an invalid tensor network. This probably needs a separate test.

It might be easier for me to address these just as I know the code better, but also happy for you to try! Let me know, I'd need commit permission on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants