Trajectree 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trajectree/__init__.py +0 -3
- trajectree/fock_optics/devices.py +1 -1
- trajectree/fock_optics/light_sources.py +2 -2
- trajectree/fock_optics/measurement.py +9 -9
- trajectree/fock_optics/outputs.py +10 -6
- trajectree/fock_optics/utils.py +9 -6
- trajectree/sequence/swap.py +5 -4
- trajectree/trajectory.py +5 -4
- {trajectree-0.0.1.dist-info → trajectree-0.0.3.dist-info}/METADATA +2 -3
- trajectree-0.0.3.dist-info/RECORD +16 -0
- trajectree/quimb/docs/_pygments/_pygments_dark.py +0 -118
- trajectree/quimb/docs/_pygments/_pygments_light.py +0 -118
- trajectree/quimb/docs/conf.py +0 -158
- trajectree/quimb/docs/examples/ex_mpi_expm_evo.py +0 -62
- trajectree/quimb/quimb/__init__.py +0 -507
- trajectree/quimb/quimb/calc.py +0 -1491
- trajectree/quimb/quimb/core.py +0 -2279
- trajectree/quimb/quimb/evo.py +0 -712
- trajectree/quimb/quimb/experimental/__init__.py +0 -0
- trajectree/quimb/quimb/experimental/autojittn.py +0 -129
- trajectree/quimb/quimb/experimental/belief_propagation/__init__.py +0 -109
- trajectree/quimb/quimb/experimental/belief_propagation/bp_common.py +0 -397
- trajectree/quimb/quimb/experimental/belief_propagation/d1bp.py +0 -316
- trajectree/quimb/quimb/experimental/belief_propagation/d2bp.py +0 -653
- trajectree/quimb/quimb/experimental/belief_propagation/hd1bp.py +0 -571
- trajectree/quimb/quimb/experimental/belief_propagation/hv1bp.py +0 -775
- trajectree/quimb/quimb/experimental/belief_propagation/l1bp.py +0 -316
- trajectree/quimb/quimb/experimental/belief_propagation/l2bp.py +0 -537
- trajectree/quimb/quimb/experimental/belief_propagation/regions.py +0 -194
- trajectree/quimb/quimb/experimental/cluster_update.py +0 -286
- trajectree/quimb/quimb/experimental/merabuilder.py +0 -865
- trajectree/quimb/quimb/experimental/operatorbuilder/__init__.py +0 -15
- trajectree/quimb/quimb/experimental/operatorbuilder/operatorbuilder.py +0 -1631
- trajectree/quimb/quimb/experimental/schematic.py +0 -7
- trajectree/quimb/quimb/experimental/tn_marginals.py +0 -130
- trajectree/quimb/quimb/experimental/tnvmc.py +0 -1483
- trajectree/quimb/quimb/gates.py +0 -36
- trajectree/quimb/quimb/gen/__init__.py +0 -2
- trajectree/quimb/quimb/gen/operators.py +0 -1167
- trajectree/quimb/quimb/gen/rand.py +0 -713
- trajectree/quimb/quimb/gen/states.py +0 -479
- trajectree/quimb/quimb/linalg/__init__.py +0 -6
- trajectree/quimb/quimb/linalg/approx_spectral.py +0 -1109
- trajectree/quimb/quimb/linalg/autoblock.py +0 -258
- trajectree/quimb/quimb/linalg/base_linalg.py +0 -719
- trajectree/quimb/quimb/linalg/mpi_launcher.py +0 -397
- trajectree/quimb/quimb/linalg/numpy_linalg.py +0 -244
- trajectree/quimb/quimb/linalg/rand_linalg.py +0 -514
- trajectree/quimb/quimb/linalg/scipy_linalg.py +0 -293
- trajectree/quimb/quimb/linalg/slepc_linalg.py +0 -892
- trajectree/quimb/quimb/schematic.py +0 -1518
- trajectree/quimb/quimb/tensor/__init__.py +0 -401
- trajectree/quimb/quimb/tensor/array_ops.py +0 -610
- trajectree/quimb/quimb/tensor/circuit.py +0 -4824
- trajectree/quimb/quimb/tensor/circuit_gen.py +0 -411
- trajectree/quimb/quimb/tensor/contraction.py +0 -336
- trajectree/quimb/quimb/tensor/decomp.py +0 -1255
- trajectree/quimb/quimb/tensor/drawing.py +0 -1646
- trajectree/quimb/quimb/tensor/fitting.py +0 -385
- trajectree/quimb/quimb/tensor/geometry.py +0 -583
- trajectree/quimb/quimb/tensor/interface.py +0 -114
- trajectree/quimb/quimb/tensor/networking.py +0 -1058
- trajectree/quimb/quimb/tensor/optimize.py +0 -1818
- trajectree/quimb/quimb/tensor/tensor_1d.py +0 -4778
- trajectree/quimb/quimb/tensor/tensor_1d_compress.py +0 -1854
- trajectree/quimb/quimb/tensor/tensor_1d_tebd.py +0 -662
- trajectree/quimb/quimb/tensor/tensor_2d.py +0 -5954
- trajectree/quimb/quimb/tensor/tensor_2d_compress.py +0 -96
- trajectree/quimb/quimb/tensor/tensor_2d_tebd.py +0 -1230
- trajectree/quimb/quimb/tensor/tensor_3d.py +0 -2869
- trajectree/quimb/quimb/tensor/tensor_3d_tebd.py +0 -46
- trajectree/quimb/quimb/tensor/tensor_approx_spectral.py +0 -60
- trajectree/quimb/quimb/tensor/tensor_arbgeom.py +0 -3237
- trajectree/quimb/quimb/tensor/tensor_arbgeom_compress.py +0 -565
- trajectree/quimb/quimb/tensor/tensor_arbgeom_tebd.py +0 -1138
- trajectree/quimb/quimb/tensor/tensor_builder.py +0 -5411
- trajectree/quimb/quimb/tensor/tensor_core.py +0 -11179
- trajectree/quimb/quimb/tensor/tensor_dmrg.py +0 -1472
- trajectree/quimb/quimb/tensor/tensor_mera.py +0 -204
- trajectree/quimb/quimb/utils.py +0 -892
- trajectree/quimb/tests/__init__.py +0 -0
- trajectree/quimb/tests/test_accel.py +0 -501
- trajectree/quimb/tests/test_calc.py +0 -788
- trajectree/quimb/tests/test_core.py +0 -847
- trajectree/quimb/tests/test_evo.py +0 -565
- trajectree/quimb/tests/test_gen/__init__.py +0 -0
- trajectree/quimb/tests/test_gen/test_operators.py +0 -361
- trajectree/quimb/tests/test_gen/test_rand.py +0 -296
- trajectree/quimb/tests/test_gen/test_states.py +0 -261
- trajectree/quimb/tests/test_linalg/__init__.py +0 -0
- trajectree/quimb/tests/test_linalg/test_approx_spectral.py +0 -368
- trajectree/quimb/tests/test_linalg/test_base_linalg.py +0 -351
- trajectree/quimb/tests/test_linalg/test_mpi_linalg.py +0 -127
- trajectree/quimb/tests/test_linalg/test_numpy_linalg.py +0 -84
- trajectree/quimb/tests/test_linalg/test_rand_linalg.py +0 -134
- trajectree/quimb/tests/test_linalg/test_slepc_linalg.py +0 -283
- trajectree/quimb/tests/test_tensor/__init__.py +0 -0
- trajectree/quimb/tests/test_tensor/test_belief_propagation/__init__.py +0 -0
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_d1bp.py +0 -39
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_d2bp.py +0 -67
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_hd1bp.py +0 -64
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_hv1bp.py +0 -51
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_l1bp.py +0 -142
- trajectree/quimb/tests/test_tensor/test_belief_propagation/test_l2bp.py +0 -101
- trajectree/quimb/tests/test_tensor/test_circuit.py +0 -816
- trajectree/quimb/tests/test_tensor/test_contract.py +0 -67
- trajectree/quimb/tests/test_tensor/test_decomp.py +0 -40
- trajectree/quimb/tests/test_tensor/test_mera.py +0 -52
- trajectree/quimb/tests/test_tensor/test_optimizers.py +0 -488
- trajectree/quimb/tests/test_tensor/test_tensor_1d.py +0 -1171
- trajectree/quimb/tests/test_tensor/test_tensor_2d.py +0 -606
- trajectree/quimb/tests/test_tensor/test_tensor_2d_tebd.py +0 -144
- trajectree/quimb/tests/test_tensor/test_tensor_3d.py +0 -123
- trajectree/quimb/tests/test_tensor/test_tensor_arbgeom.py +0 -226
- trajectree/quimb/tests/test_tensor/test_tensor_builder.py +0 -441
- trajectree/quimb/tests/test_tensor/test_tensor_core.py +0 -2066
- trajectree/quimb/tests/test_tensor/test_tensor_dmrg.py +0 -388
- trajectree/quimb/tests/test_tensor/test_tensor_spectral_approx.py +0 -63
- trajectree/quimb/tests/test_tensor/test_tensor_tebd.py +0 -270
- trajectree/quimb/tests/test_utils.py +0 -85
- trajectree-0.0.1.dist-info/RECORD +0 -126
- {trajectree-0.0.1.dist-info → trajectree-0.0.3.dist-info}/WHEEL +0 -0
- {trajectree-0.0.1.dist-info → trajectree-0.0.3.dist-info}/licenses/LICENSE +0 -0
- {trajectree-0.0.1.dist-info → trajectree-0.0.3.dist-info}/top_level.txt +0 -0
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
"""Generic methods for compressing arbitrary geometry tensor networks, where
|
|
2
|
-
the tensor network can locally have arbitrary structure and outer indices.
|
|
3
|
-
|
|
4
|
-
- [x] projector
|
|
5
|
-
- [x] l2bp
|
|
6
|
-
- [x] local early
|
|
7
|
-
- [x] local late
|
|
8
|
-
- [x] superorthogonal
|
|
9
|
-
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from ..utils import ensure_dict
|
|
13
|
-
from .tensor_arbgeom import create_lazy_edge_map
|
|
14
|
-
from .tensor_core import choose_local_compress_gauge_settings
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def tensor_network_ag_compress_projector(
|
|
18
|
-
tn,
|
|
19
|
-
max_bond=None,
|
|
20
|
-
cutoff=1e-10,
|
|
21
|
-
site_tags=None,
|
|
22
|
-
canonize=True,
|
|
23
|
-
canonize_opts=None,
|
|
24
|
-
lazy=False,
|
|
25
|
-
optimize="auto-hq",
|
|
26
|
-
equalize_norms=False,
|
|
27
|
-
inplace=False,
|
|
28
|
-
**compress_opts,
|
|
29
|
-
):
|
|
30
|
-
"""Compress an arbtrary geometry tensor network, with potentially multiple
|
|
31
|
-
tensors per site, using locally computed projectors.
|
|
32
|
-
|
|
33
|
-
Very loosely, this is like a generalization HOTRG.
|
|
34
|
-
|
|
35
|
-
Parameters
|
|
36
|
-
----------
|
|
37
|
-
tn : TensorNetwork
|
|
38
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
39
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
40
|
-
max_bond : int
|
|
41
|
-
The maximum bond dimension to compress to.
|
|
42
|
-
cutoff : float, optional
|
|
43
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
44
|
-
site_tags : sequence of str, optional
|
|
45
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
46
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
47
|
-
tensor per site.
|
|
48
|
-
canonize : bool, optional
|
|
49
|
-
Whether to pseudo canonicalize the initial tensor network.
|
|
50
|
-
canonize_opts
|
|
51
|
-
Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.gauge_all`.
|
|
52
|
-
lazy : bool, optional
|
|
53
|
-
Whether to leave the computed projectors uncontracted, default: False.
|
|
54
|
-
optimize : str, optional
|
|
55
|
-
The contraction path optimizer to use.
|
|
56
|
-
equalize_norms : bool or float, optional
|
|
57
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
58
|
-
explicit value is give, then the norms will be set to that value, and
|
|
59
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
60
|
-
inplace : bool, optional
|
|
61
|
-
Whether to perform the compression inplace.
|
|
62
|
-
compress_opts
|
|
63
|
-
Supplied to :func:`~quimb.tensor.tensor_split`.
|
|
64
|
-
|
|
65
|
-
Returns
|
|
66
|
-
-------
|
|
67
|
-
TensorNetwork
|
|
68
|
-
"""
|
|
69
|
-
tn = tn if inplace else tn.copy()
|
|
70
|
-
|
|
71
|
-
if site_tags is None:
|
|
72
|
-
site_tags = tn.site_tags
|
|
73
|
-
|
|
74
|
-
edges, _ = create_lazy_edge_map(tn, site_tags)
|
|
75
|
-
|
|
76
|
-
if canonize:
|
|
77
|
-
# optionally precondition the uncontracted network
|
|
78
|
-
canonize_opts = ensure_dict(canonize_opts)
|
|
79
|
-
tn.gauge_all_(
|
|
80
|
-
equalize_norms=equalize_norms,
|
|
81
|
-
**canonize_opts
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
# then compute projectors using local information
|
|
85
|
-
tn_calc = tn.copy()
|
|
86
|
-
for taga, tagb in edges:
|
|
87
|
-
tn_calc.insert_compressor_between_regions_(
|
|
88
|
-
[taga],
|
|
89
|
-
[tagb],
|
|
90
|
-
max_bond=max_bond,
|
|
91
|
-
cutoff=cutoff,
|
|
92
|
-
insert_into=tn,
|
|
93
|
-
new_ltags=[taga],
|
|
94
|
-
new_rtags=[tagb],
|
|
95
|
-
optimize=optimize,
|
|
96
|
-
**compress_opts,
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
if not lazy:
|
|
100
|
-
# then contract each site with all surrounding projectors
|
|
101
|
-
for st in site_tags:
|
|
102
|
-
tn.contract_(st, optimize=optimize)
|
|
103
|
-
|
|
104
|
-
# XXX: do better than simply waiting til the end to equalize norms
|
|
105
|
-
if equalize_norms is True:
|
|
106
|
-
tn.equalize_norms_()
|
|
107
|
-
elif equalize_norms:
|
|
108
|
-
tn.equalize_norms_(value=equalize_norms)
|
|
109
|
-
|
|
110
|
-
return tn
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def tensor_network_ag_compress_local_early(
|
|
114
|
-
tn,
|
|
115
|
-
max_bond=None,
|
|
116
|
-
cutoff=1e-10,
|
|
117
|
-
site_tags=None,
|
|
118
|
-
canonize=True,
|
|
119
|
-
tree_gauge_distance=None,
|
|
120
|
-
canonize_distance=None,
|
|
121
|
-
canonize_after_distance=None,
|
|
122
|
-
mode="auto",
|
|
123
|
-
optimize="auto-hq",
|
|
124
|
-
equalize_norms=False,
|
|
125
|
-
inplace=False,
|
|
126
|
-
**compress_opts,
|
|
127
|
-
):
|
|
128
|
-
"""Compress an arbtrary geometry tensor network, with potentially multiple
|
|
129
|
-
tensors per site, using explicit contraction followed by immediate
|
|
130
|
-
('early') compression. In other words, contractions are interleaved with
|
|
131
|
-
compressions.
|
|
132
|
-
|
|
133
|
-
Very loosely, this is like a generalization of the 'zip-up' algorithm in
|
|
134
|
-
1D, but for arbitrary geometry.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
Parameters
|
|
138
|
-
----------
|
|
139
|
-
tn : TensorNetwork
|
|
140
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
141
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
142
|
-
max_bond : int
|
|
143
|
-
The maximum bond dimension to compress to.
|
|
144
|
-
cutoff : float, optional
|
|
145
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
146
|
-
site_tags : sequence of str, optional
|
|
147
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
148
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
149
|
-
tensor per site.
|
|
150
|
-
canonize : bool, optional
|
|
151
|
-
Whether to locally gauge before each compression, defaults to True.
|
|
152
|
-
tree_gauge_distance : int, optional
|
|
153
|
-
The distance to locally gauge to before each compression. Defaults to
|
|
154
|
-
3.
|
|
155
|
-
canonize_distance : int, optional
|
|
156
|
-
The distance to canonize to before each compression, by default this
|
|
157
|
-
is set by ``tree_gauge_distance``.
|
|
158
|
-
canonize_after_distance : int, optional
|
|
159
|
-
The distance to canonize to after each compression, by default this
|
|
160
|
-
is set by ``tree_gauge_distance``, depending on ``mode``.
|
|
161
|
-
mode : {'auto', 'basic', 'virtual-tree', ...}, optional
|
|
162
|
-
The mode to use for the local gauging. If 'auto' will default to
|
|
163
|
-
virtual tree gauging, or basic if `tree_gauge_distance` is 0.
|
|
164
|
-
optimize : str, optional
|
|
165
|
-
The contraction path optimizer to use.
|
|
166
|
-
equalize_norms : bool or float, optional
|
|
167
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
168
|
-
explicit value is give, then the norms will be set to that value, and
|
|
169
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
170
|
-
inplace : bool, optional
|
|
171
|
-
Whether to perform the compression inplace.
|
|
172
|
-
compress_opts
|
|
173
|
-
Supplied to
|
|
174
|
-
:meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_between`.
|
|
175
|
-
|
|
176
|
-
Returns
|
|
177
|
-
-------
|
|
178
|
-
TensorNetwork
|
|
179
|
-
"""
|
|
180
|
-
tnc = tn if inplace else tn.copy()
|
|
181
|
-
|
|
182
|
-
if site_tags is None:
|
|
183
|
-
site_tags = tnc.site_tags
|
|
184
|
-
|
|
185
|
-
_, neighbors = create_lazy_edge_map(tnc, site_tags)
|
|
186
|
-
|
|
187
|
-
canonize_distance, canonize_after_distance, mode = (
|
|
188
|
-
choose_local_compress_gauge_settings(
|
|
189
|
-
canonize,
|
|
190
|
-
tree_gauge_distance,
|
|
191
|
-
canonize_distance,
|
|
192
|
-
canonize_after_distance,
|
|
193
|
-
mode,
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
st0 = next(iter(site_tags))
|
|
198
|
-
seen = {st0}
|
|
199
|
-
queue = [st0]
|
|
200
|
-
|
|
201
|
-
while queue:
|
|
202
|
-
# process sites in a breadth-first manner
|
|
203
|
-
taga = queue.pop(0)
|
|
204
|
-
|
|
205
|
-
for tagb in neighbors[taga]:
|
|
206
|
-
if tagb not in seen:
|
|
207
|
-
queue.append(tagb)
|
|
208
|
-
seen.add(tagb)
|
|
209
|
-
|
|
210
|
-
# contract this site
|
|
211
|
-
tnc.contract_(taga, optimize=optimize)
|
|
212
|
-
|
|
213
|
-
# then immediately compress around it
|
|
214
|
-
(tida,) = tnc._get_tids_from_tags(taga)
|
|
215
|
-
for tidb in tnc._get_neighbor_tids(tida):
|
|
216
|
-
tnc._compress_between_tids(
|
|
217
|
-
tida,
|
|
218
|
-
tidb,
|
|
219
|
-
max_bond=max_bond,
|
|
220
|
-
cutoff=cutoff,
|
|
221
|
-
canonize_distance=canonize_distance,
|
|
222
|
-
canonize_after_distance=canonize_after_distance,
|
|
223
|
-
mode=mode,
|
|
224
|
-
**compress_opts,
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
if equalize_norms is True:
|
|
228
|
-
tnc.equalize_norms_()
|
|
229
|
-
elif equalize_norms:
|
|
230
|
-
tnc.equalize_norms_(value=equalize_norms)
|
|
231
|
-
|
|
232
|
-
return tnc
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def tensor_network_ag_compress_local_late(
|
|
236
|
-
tn,
|
|
237
|
-
max_bond=None,
|
|
238
|
-
cutoff=1e-10,
|
|
239
|
-
site_tags=None,
|
|
240
|
-
canonize=True,
|
|
241
|
-
tree_gauge_distance=None,
|
|
242
|
-
canonize_distance=None,
|
|
243
|
-
canonize_after_distance=None,
|
|
244
|
-
mode="auto",
|
|
245
|
-
optimize="auto-hq",
|
|
246
|
-
equalize_norms=False,
|
|
247
|
-
inplace=False,
|
|
248
|
-
**compress_opts,
|
|
249
|
-
):
|
|
250
|
-
"""Compress an arbtrary geometry tensor network, with potentially multiple
|
|
251
|
-
tensors per site, by explicitly contracting all sites first and then
|
|
252
|
-
('late') locally compressing. In other words, all contractions happen, then
|
|
253
|
-
all compressions happen.
|
|
254
|
-
|
|
255
|
-
Very loosely, this is like a generalization of the 'direct' algorithm in
|
|
256
|
-
1D, but for arbitrary geometry.
|
|
257
|
-
|
|
258
|
-
Parameters
|
|
259
|
-
----------
|
|
260
|
-
tn : TensorNetwork
|
|
261
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
262
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
263
|
-
max_bond : int
|
|
264
|
-
The maximum bond dimension to compress to.
|
|
265
|
-
cutoff : float, optional
|
|
266
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
267
|
-
site_tags : sequence of str, optional
|
|
268
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
269
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
270
|
-
tensor per site.
|
|
271
|
-
canonize : bool, optional
|
|
272
|
-
Whether to locally gauge before each compression, defaults to True.
|
|
273
|
-
tree_gauge_distance : int, optional
|
|
274
|
-
The distance to locally gauge to before each compression. Defaults to
|
|
275
|
-
3.
|
|
276
|
-
canonize_distance : int, optional
|
|
277
|
-
The distance to canonize to before each compression, by default this
|
|
278
|
-
is set by ``tree_gauge_distance``.
|
|
279
|
-
canonize_after_distance : int, optional
|
|
280
|
-
The distance to canonize to after each compression, by default this
|
|
281
|
-
is set by ``tree_gauge_distance``, depending on ``mode``.
|
|
282
|
-
mode : {'auto', 'basic', 'virtual-tree', ...}, optional
|
|
283
|
-
The mode to use for the local gauging. If 'auto' will default to
|
|
284
|
-
virtual tree gauging, or basic if `tree_gauge_distance` is 0.
|
|
285
|
-
optimize : str, optional
|
|
286
|
-
The contraction path optimizer to use.
|
|
287
|
-
equalize_norms : bool or float, optional
|
|
288
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
289
|
-
explicit value is give, then the norms will be set to that value, and
|
|
290
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
291
|
-
inplace : bool, optional
|
|
292
|
-
Whether to perform the compression inplace.
|
|
293
|
-
compress_opts
|
|
294
|
-
Supplied to
|
|
295
|
-
:meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_between`.
|
|
296
|
-
|
|
297
|
-
Returns
|
|
298
|
-
-------
|
|
299
|
-
TensorNetwork
|
|
300
|
-
"""
|
|
301
|
-
tnc = tn if inplace else tn.copy()
|
|
302
|
-
|
|
303
|
-
if site_tags is None:
|
|
304
|
-
site_tags = tnc.site_tags
|
|
305
|
-
|
|
306
|
-
for st in site_tags:
|
|
307
|
-
tnc.contract_(st, optimize=optimize)
|
|
308
|
-
|
|
309
|
-
tnc.compress_all_(
|
|
310
|
-
max_bond=max_bond,
|
|
311
|
-
cutoff=cutoff,
|
|
312
|
-
canonize=canonize,
|
|
313
|
-
tree_gauge_distance=tree_gauge_distance,
|
|
314
|
-
canonize_distance=canonize_distance,
|
|
315
|
-
canonize_after_distance=canonize_after_distance,
|
|
316
|
-
mode=mode,
|
|
317
|
-
**compress_opts,
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
if equalize_norms is True:
|
|
321
|
-
tnc.equalize_norms_()
|
|
322
|
-
elif equalize_norms:
|
|
323
|
-
tnc.equalize_norms_(value=equalize_norms)
|
|
324
|
-
|
|
325
|
-
return tnc
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
def tensor_network_ag_compress_superorthogonal(
|
|
329
|
-
tn,
|
|
330
|
-
max_bond=None,
|
|
331
|
-
cutoff=1e-10,
|
|
332
|
-
site_tags=None,
|
|
333
|
-
canonize=True,
|
|
334
|
-
optimize="auto-hq",
|
|
335
|
-
equalize_norms=False,
|
|
336
|
-
inplace=False,
|
|
337
|
-
**compress_opts,
|
|
338
|
-
):
|
|
339
|
-
"""Compress an arbtrary geometry tensor network, with potentially multiple
|
|
340
|
-
tensors per site, using the 'superorthogonal' / 'Vidal' / quasi-canonical
|
|
341
|
-
/ 'simple update' gauge for compression. This is the same gauge as used in
|
|
342
|
-
L2BP, but the intermediate tensor network is explicitly constructed.
|
|
343
|
-
|
|
344
|
-
Parameters
|
|
345
|
-
----------
|
|
346
|
-
tn : TensorNetwork
|
|
347
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
348
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
349
|
-
max_bond : int
|
|
350
|
-
The maximum bond dimension to compress to.
|
|
351
|
-
cutoff : float, optional
|
|
352
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
353
|
-
site_tags : sequence of str, optional
|
|
354
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
355
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
356
|
-
tensor per site.
|
|
357
|
-
canonize : bool, optional
|
|
358
|
-
Whether to locally gauge before each compression, defaults to True.
|
|
359
|
-
optimize : str, optional
|
|
360
|
-
The contraction path optimizer to use.
|
|
361
|
-
equalize_norms : bool or float, optional
|
|
362
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
363
|
-
explicit value is give, then the norms will be set to that value, and
|
|
364
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
365
|
-
inplace : bool, optional
|
|
366
|
-
Whether to perform the compression inplace.
|
|
367
|
-
compress_opts
|
|
368
|
-
Supplied to
|
|
369
|
-
:meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_all_simple`.
|
|
370
|
-
|
|
371
|
-
Returns
|
|
372
|
-
-------
|
|
373
|
-
TensorNetwork
|
|
374
|
-
"""
|
|
375
|
-
tnc = tn if inplace else tn.copy()
|
|
376
|
-
|
|
377
|
-
if site_tags is None:
|
|
378
|
-
site_tags = tnc.site_tags
|
|
379
|
-
|
|
380
|
-
for st in site_tags:
|
|
381
|
-
tnc.contract_(st, optimize=optimize)
|
|
382
|
-
|
|
383
|
-
tnc.fuse_multibonds_()
|
|
384
|
-
|
|
385
|
-
if not canonize:
|
|
386
|
-
# turn off gauging effect
|
|
387
|
-
compress_opts.setdefault("max_iterations", 1)
|
|
388
|
-
compress_opts.setdefault("tol", 0.0)
|
|
389
|
-
else:
|
|
390
|
-
compress_opts.setdefault("max_iterations", 1000)
|
|
391
|
-
compress_opts.setdefault("tol", 5e-6)
|
|
392
|
-
|
|
393
|
-
tnc.compress_all_simple_(
|
|
394
|
-
max_bond=max_bond,
|
|
395
|
-
cutoff=cutoff,
|
|
396
|
-
**compress_opts,
|
|
397
|
-
)
|
|
398
|
-
|
|
399
|
-
if equalize_norms is True:
|
|
400
|
-
tnc.equalize_norms_()
|
|
401
|
-
elif equalize_norms:
|
|
402
|
-
tnc.equalize_norms_(value=equalize_norms)
|
|
403
|
-
|
|
404
|
-
return tnc
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
def tensor_network_ag_compress_l2bp(
|
|
408
|
-
tn,
|
|
409
|
-
max_bond=None,
|
|
410
|
-
cutoff=1e-10,
|
|
411
|
-
site_tags=None,
|
|
412
|
-
canonize=True,
|
|
413
|
-
damping=0.0,
|
|
414
|
-
local_convergence=True,
|
|
415
|
-
update="sequential",
|
|
416
|
-
optimize="auto-hq",
|
|
417
|
-
equalize_norms=False,
|
|
418
|
-
inplace=False,
|
|
419
|
-
**compress_opts,
|
|
420
|
-
):
|
|
421
|
-
"""Compress an arbitrary geometry tensor network, with potentially multiple
|
|
422
|
-
tensors per site, using lazy 2-norm belief propagation.
|
|
423
|
-
|
|
424
|
-
Parameters
|
|
425
|
-
----------
|
|
426
|
-
tn : TensorNetwork
|
|
427
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
428
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
429
|
-
max_bond : int
|
|
430
|
-
The maximum bond dimension to compress to.
|
|
431
|
-
cutoff : float, optional
|
|
432
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
433
|
-
site_tags : sequence of str, optional
|
|
434
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
435
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
436
|
-
tensor per site.
|
|
437
|
-
canonize : bool, optional
|
|
438
|
-
Whether to locally gauge before each compression, defaults to True.
|
|
439
|
-
damping : float, optional
|
|
440
|
-
How much to dampen message updates, to help convergence, defaults to 0.
|
|
441
|
-
local_convergence : bool, optional
|
|
442
|
-
Whether to use local convergence criteria, defaults to True.
|
|
443
|
-
update : {'parallel', 'sequential'}, optional
|
|
444
|
-
Whether to update all messages in parallel or sequentially, defaults to
|
|
445
|
-
'parallel'.
|
|
446
|
-
optimize : str, optional
|
|
447
|
-
The contraction path optimizer to use.
|
|
448
|
-
equalize_norms : bool or float, optional
|
|
449
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
450
|
-
explicit value is give, then the norms will be set to that value, and
|
|
451
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
452
|
-
inplace : bool, optional
|
|
453
|
-
Whether to perform the compression inplace.
|
|
454
|
-
compress_opts
|
|
455
|
-
Supplied to
|
|
456
|
-
:func:`~quimb.experimental.belief_propagation.l2bp.compress_l2bp`.
|
|
457
|
-
|
|
458
|
-
Returns
|
|
459
|
-
-------
|
|
460
|
-
TensorNetwork
|
|
461
|
-
"""
|
|
462
|
-
from quimb.experimental.belief_propagation.l2bp import compress_l2bp
|
|
463
|
-
|
|
464
|
-
if not canonize:
|
|
465
|
-
compress_opts.setdefault("max_iterations", 1)
|
|
466
|
-
|
|
467
|
-
tnc = compress_l2bp(
|
|
468
|
-
tn,
|
|
469
|
-
max_bond=max_bond,
|
|
470
|
-
cutoff=cutoff,
|
|
471
|
-
site_tags=site_tags,
|
|
472
|
-
damping=damping,
|
|
473
|
-
local_convergence=local_convergence,
|
|
474
|
-
update=update,
|
|
475
|
-
optimize=optimize,
|
|
476
|
-
inplace=inplace,
|
|
477
|
-
**compress_opts,
|
|
478
|
-
)
|
|
479
|
-
|
|
480
|
-
if equalize_norms is True:
|
|
481
|
-
tnc.equalize_norms_()
|
|
482
|
-
elif equalize_norms:
|
|
483
|
-
tnc.equalize_norms_(value=equalize_norms)
|
|
484
|
-
|
|
485
|
-
return tnc
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
_TNAG_COMPRESS_METHODS = {
|
|
489
|
-
"local-early": tensor_network_ag_compress_local_early,
|
|
490
|
-
"local-late": tensor_network_ag_compress_local_late,
|
|
491
|
-
"projector": tensor_network_ag_compress_projector,
|
|
492
|
-
"su": tensor_network_ag_compress_superorthogonal,
|
|
493
|
-
"superorthogonal": tensor_network_ag_compress_superorthogonal,
|
|
494
|
-
"l2bp": tensor_network_ag_compress_l2bp,
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
def tensor_network_ag_compress(
|
|
499
|
-
tn,
|
|
500
|
-
max_bond,
|
|
501
|
-
cutoff=1e-10,
|
|
502
|
-
method="local-early",
|
|
503
|
-
site_tags=None,
|
|
504
|
-
canonize=True,
|
|
505
|
-
optimize="auto-hq",
|
|
506
|
-
equalize_norms=False,
|
|
507
|
-
inplace=False,
|
|
508
|
-
**kwargs,
|
|
509
|
-
):
|
|
510
|
-
"""Compress an arbitrary geometry tensor network, with potentially multiple
|
|
511
|
-
tensors per site.
|
|
512
|
-
|
|
513
|
-
Parameters
|
|
514
|
-
----------
|
|
515
|
-
tn : TensorNetwork
|
|
516
|
-
The tensor network to compress. Every tensor should have exactly one of
|
|
517
|
-
the site tags. Each site can have multiple tensors and output indices.
|
|
518
|
-
max_bond : int
|
|
519
|
-
The maximum bond dimension to compress to.
|
|
520
|
-
cutoff : float, optional
|
|
521
|
-
A dynamic threshold for discarding singular values when compressing.
|
|
522
|
-
method : {'local-early', 'local-late', 'projector', 'superorthogonal', 'l2bp'}, optional
|
|
523
|
-
The compression method to use:
|
|
524
|
-
|
|
525
|
-
- 'local-early': explicitly contract each site and interleave with
|
|
526
|
-
immediate compression, see
|
|
527
|
-
:func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_early`.
|
|
528
|
-
- 'local-late': explicitly contract all sites and then compress, see
|
|
529
|
-
:func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_late`.
|
|
530
|
-
- 'projector': use locally computed projectors, see
|
|
531
|
-
:func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_projector`.
|
|
532
|
-
- 'superorthogonal': use the 'superorthogonal' gauge, see
|
|
533
|
-
:func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_superorthogonal`.
|
|
534
|
-
- 'l2bp': use lazy 2-norm belief propagation, see
|
|
535
|
-
:func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_l2bp`.
|
|
536
|
-
|
|
537
|
-
site_tags : sequence of str, optional
|
|
538
|
-
The tags to use to group the tensors from ``tn``. If not
|
|
539
|
-
given, uses ``tn.site_tags``. The tensor network built will have one
|
|
540
|
-
tensor per site.
|
|
541
|
-
canonize : bool, optional
|
|
542
|
-
Whether to perform canonicalization, pseudo or otherwise depending on
|
|
543
|
-
the method, before compressing.
|
|
544
|
-
optimize : str, optional
|
|
545
|
-
The contraction path optimizer to use.
|
|
546
|
-
equalize_norms : bool or float, optional
|
|
547
|
-
Whether to equalize the norms of the tensors after compression. If an
|
|
548
|
-
explicit value is give, then the norms will be set to that value, and
|
|
549
|
-
the overall scaling factor will be accumulated into `.exponent`.
|
|
550
|
-
inplace : bool, optional
|
|
551
|
-
Whether to perform the compression inplace.
|
|
552
|
-
kwargs
|
|
553
|
-
Supplied to the chosen compression method.
|
|
554
|
-
"""
|
|
555
|
-
return _TNAG_COMPRESS_METHODS[method](
|
|
556
|
-
tn,
|
|
557
|
-
max_bond=max_bond,
|
|
558
|
-
cutoff=cutoff,
|
|
559
|
-
site_tags=site_tags,
|
|
560
|
-
canonize=canonize,
|
|
561
|
-
optimize=optimize,
|
|
562
|
-
equalize_norms=equalize_norms,
|
|
563
|
-
inplace=inplace,
|
|
564
|
-
**kwargs,
|
|
565
|
-
)
|