Skip to content

Commit

Permalink
more 1d and arbgeom compression functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Apr 4, 2024
1 parent 2bddfe7 commit e2908fb
Show file tree
Hide file tree
Showing 6 changed files with 962 additions and 105 deletions.
28 changes: 27 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ Release notes for `quimb`.
(whats-new-1-7-4)=
## v1.7.4 (unreleased)

**Breaking Changes**

- all singular value renormalization is turned off by default
- [`TensorNetwork.compress_all`](quimb.tensor.TensorNetwork.compress_all)
now defaults to using some local gauging


**Enhancements:**

- add `quimb.tensor.tensor_1d_compress` with functions for compressing generic
- add `quimb.tensor.tensor_1d_compress.py` with functions for compressing generic
1D tensor networks (with arbitrary local structure) using various methods.
The methods are:

Expand All @@ -20,6 +27,24 @@ Release notes for `quimb`.
- ... and some more niche methods for debugging and testing.

And can be accessed via the unified function [`tensor_network_1d_compress`](quimb.tensor.tensor_1d_compress.tensor_network_1d_compress).
Boundary contraction in 2D can now utilize any of these methods.
- add `quimb.tensor.tensor_arbgeom_compress.py` with functions for compressing
arbitrary geometry tensor networks using various methods. The methods are:

- The **'local-early'** method:
[`tensor_network_ag_compress_local_early`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_early)
- The **'local-late'** method:
[`tensor_network_ag_compress_local_late`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_late)
- The **'projector'** method:
[`tensor_network_ag_compress_projector`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_projector)
- The **'superorthogonal'** method:
[`tensor_network_ag_compress_superorthogonal`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_superorthogonal)
- The **'l2bp'** method:
[`tensor_network_ag_compress_l2bp`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_l2bp)

And can be accessed via the unified function
[`tensor_network_ag_compress`](quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress).
1D compression can also fall back to these methods.
- support PBC in
[`tn2d.contract_hotrg`](quimb.tensor.tensor_2d.TensorNetwork2D.contract_hotrg),
[`tn2d.contract_ctmrg`](quimb.tensor.tensor_2d.TensorNetwork2D.contract_ctmrg),
Expand All @@ -34,6 +59,7 @@ Release notes for `quimb`.
and
[`TN3D_rand_hidden_loop`](quimb.tensor.tensor_builder.TN3D_rand_hidden_loop),
with ``cyclic`` kwarg.
- support PBC in the various base PEPS and PEPO construction methods.
- add [`tensor_network_apply_op_op`](quimb.tensor.tensor_arbgeom.tensor_network_apply_op_op)
for applying 'operator' TNs to 'operator' TNs.
- tweak [`tensor_network_apply_op_vec`](quimb.tensor.tensor_arbgeom.tensor_network_apply_op_vec)
Expand Down
55 changes: 42 additions & 13 deletions quimb/tensor/tensor_1d_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
- [x] the autofit method (via non-1d specific ALS or autodiff)
"""

import collections
import itertools
import warnings

from .tensor_arbgeom import tensor_network_apply_op_vec
from .tensor_arbgeom_compress import tensor_network_ag_compress
from .tensor_builder import TN1D_matching
from .tensor_core import (
TensorNetwork,
Expand Down Expand Up @@ -1371,19 +1373,46 @@ def tensor_network_1d_compress(
"""
compress_opts = compress_opts or {}

return _TN1D_COMPRESS_METHODS[method](
tn,
max_bond=max_bond,
cutoff=cutoff,
site_tags=site_tags,
canonize=canonize,
permute_arrays=permute_arrays,
optimize=optimize,
sweep_reverse=sweep_reverse,
inplace=inplace,
**compress_opts,
**kwargs,
)
try:
return _TN1D_COMPRESS_METHODS[method](
tn,
max_bond=max_bond,
cutoff=cutoff,
site_tags=site_tags,
canonize=canonize,
permute_arrays=permute_arrays,
optimize=optimize,
sweep_reverse=sweep_reverse,
inplace=inplace,
**compress_opts,
**kwargs,
)
except KeyError:
# try arbitrary geometry methods

if sweep_reverse:
warnings.warn(
"sweep_reverse has no effect for "
"arbitrary geometry (AG) methods."
)

tnc = tensor_network_ag_compress(
tn,
max_bond=max_bond,
cutoff=cutoff,
method=method,
site_tags=site_tags,
canonize=canonize,
optimize=optimize,
inplace=inplace,
**compress_opts,
**kwargs,
)

if permute_arrays:
possibly_permute_(tnc, permute_arrays)

return tnc


# --------------- MPO-MPS gating using 1D compression methods --------------- #
Expand Down
Loading

0 comments on commit e2908fb

Please sign in to comment.