quimb.tensor.tensor_1d_compress =============================== .. py:module:: quimb.tensor.tensor_1d_compress .. autoapi-nested-parse:: Generic methods for compressing 1D-like tensor networks, where the tensor network can locally have arbitrary structure and outer indices. - [x] the direct method - [x] the density matrix method - [x] the zip-up method - [x] the zip-up first method - [x] the 1-site variational fit method, including sums of tensor networks - [x] the 2-site variational fit method, including sums of tensor networks - [x] the local projector method (CTMRG and HOTRG style) - [x] the autofit method (via non-1d specific ALS or autodiff) Attributes ---------- .. autoapisummary:: quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_fit_zipup quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_fit_projector quimb.tensor.tensor_1d_compress._TN1D_COMPRESS_METHODS Functions --------- .. autoapisummary:: quimb.tensor.tensor_1d_compress.enforce_1d_like quimb.tensor.tensor_1d_compress.possibly_permute_ quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_direct quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_dm quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_zipup quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_zipup_first quimb.tensor.tensor_1d_compress._tn1d_fit_sum_sweep_1site quimb.tensor.tensor_1d_compress._tn1d_fit_sum_sweep_2site quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_fit quimb.tensor.tensor_1d_compress.tensor_network_1d_compress_fit_guess quimb.tensor.tensor_1d_compress.tensor_network_1d_compress quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_lazy quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_direct quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_dm quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_zipup quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_zipup_first quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_fit quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_autofit quimb.tensor.tensor_1d_compress.mps_gate_with_mpo_projector Module Contents --------------- .. py:function:: enforce_1d_like(tn, site_tags=None, fix_bonds=True, inplace=False) Check that ``tn`` is 1D-like with OBC, i.e. 1) that each tensor has exactly one of the given ``site_tags``. If not, raise a ValueError. 2) That there are no hyper indices. And 3) that there are only bonds within sites or between nearest neighbor sites. This issue can be optionally automatically fixed by inserting a string of identity tensors. :param tn: The tensor network to check. :type tn: TensorNetwork :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. :type site_tags: sequence of str, optional :param fix_bonds: Whether to fix the bond structure by inserting identity tensors. :type fix_bonds: bool, optional :param inplace: Whether to perform the fix inplace or not. :type inplace: bool, optional :raises ValueError: If the tensor network is not 1D-like. .. py:function:: possibly_permute_(tn, permute_arrays) .. py:function:: tensor_network_1d_compress_direct(tn, max_bond=None, cutoff=1e-10, site_tags=None, normalize=False, canonize=True, cutoff_mode='rsum2', permute_arrays=True, optimize='auto-hq', sweep_reverse=False, equalize_norms=False, inplace=False, **compress_opts) Compress a 1D-like tensor network using the 'direct' or 'naive' method, that is, explicitly contracting site-wise to form a MPS-like TN, canonicalizing in one direction, then compressing in the other. This has the same scaling as the density matrix (dm) method, but a larger prefactor. It can still be faster for small bond dimensions however, and is potentially higher precision since it works in the space of singular values directly rather than singular values squared. It is not quite optimal in terms of error due to the compounding errors of the SVDs. :param tn: The tensor network to compress. Every tensor should have exactly one of the site tags. Each site can have multiple tensors and output indices. :type tn: TensorNetwork :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in right canonical form. :type normalize: bool, optional :param canonize: Whether to canonicalize the network in one direction before compressing in the other. :type canonize: bool, optional :param cutoff_mode: The mode to use when truncating the singular values of the decomposed tensors. See :func:`~quimb.tensor.tensor_split`. :type cutoff_mode: {"rsum2", "rel", ...}, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param sweep_reverse: Whether to sweep in the reverse direction, resulting in a left canonical form instead of right canonical. :type sweep_reverse: bool, optional :param equalize_norms: Whether to renormalize the tensors during the compression procedure. If ``True`` the gathered exponent will be redistributed equally among the tensors. If a float, all tensors will be renormalized to this value, and the gathered exponent is tracked in ``tn.exponent`` of the returned tensor network. :type equalize_norms: bool, optional :param inplace: Whether to perform the compression inplace or not. :type inplace: bool, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :returns: The compressed tensor network, with canonical center at ``site_tags[0]`` ('right canonical' form) or ``site_tags[-1]`` ('left canonical' form) if ``sweep_reverse``. :rtype: TensorNetwork .. py:function:: tensor_network_1d_compress_dm(tn, max_bond=None, cutoff=1e-10, site_tags=None, normalize=False, cutoff_mode='rsum1', permute_arrays=True, optimize='auto-hq', sweep_reverse=False, canonize=True, equalize_norms=False, inplace=False, **compress_opts) Compress any 1D-like tensor network using the 'density matrix' method (https://tensornetwork.org/mps/algorithms/denmat_mpo_mps/). While this has the same scaling as the direct method, in practice it can often be faster, especially at large bond dimensions. Potentially there are some situations where the direct method is more stable with regard to precision, since the density matrix method works in the 'squared' picture. :param tn: The tensor network to compress. Every tensor should have exactly one of the site tags. Each site can have multiple tensors and output indices. :type tn: TensorNetwork :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: The truncation error to use when compressing the double layer tensor network. :type cutoff: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in right canonical form. :type normalize: bool, optional :param cutoff_mode: The mode to use when truncating the singular values of the decomposed tensors. See :func:`~quimb.tensor.tensor_split`. Note for the density matrix method the default 'rsum1' mode acts like 'rsum2' for the direct method due to truncating in the squared space. :type cutoff_mode: {"rsum1", "rel", ...}, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param sweep_reverse: Whether to sweep in the reverse direction, resulting in a left canonical form instead of right canonical. :type sweep_reverse: bool, optional :param canonize: Dummy argument to match the signature of other compression methods. :type canonize: bool, optional :param equalize_norms: Whether to equalize the norms of the tensors after compression. If an explicit value is give, then the norms will be set to that value, and the overall scaling factor will be accumulated into `.exponent`. :type equalize_norms: bool or float, optional :param inplace: Whether to perform the compression inplace or not. :type inplace: bool, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :returns: The compressed tensor network, with canonical center at ``site_tags[0]`` ('right canonical' form) or ``site_tags[-1]`` ('left canonical' form) if ``sweep_reverse``. :rtype: TensorNetwork .. py:function:: tensor_network_1d_compress_zipup(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, normalize=False, cutoff_mode='rsum2', permute_arrays=True, optimize='auto-hq', sweep_reverse=False, equalize_norms=False, inplace=False, **compress_opts) Compress a 1D-like tensor network using the 'zip-up' algorithm due to 'Minimally Entangled Typical Thermal State Algorithms', E.M. Stoudenmire & Steven R. White (https://arxiv.org/abs/1002.1305). The returned tensor network will have one tensor per site, in the order given by ``site_tags``, with canonical center at ``site_tags[0]`` ('right' canonical form). The zipup algorithm scales better than the direct and density matrix methods when multiple tensors are present at each site (such as MPO-MPS multiplication), but is less accurate due to the compressions taking place in an only pseudo-canonical gauge. It generally also only makes sense in the fixed bond dimension case, as opposed to relying on a specific `cutoff` only. :param tn: The tensor network to compress. Every tensor should have exactly one of the site tags. Each site can have multiple tensors and output indices. :type tn: TensorNetwork :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param canonize: Whether to pseudo canonicalize the initial tensor network. :type canonize: bool, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in right canonical form. :type normalize: bool, optional :param cutoff_mode: The mode to use when truncating the singular values of the decomposed tensors. See :func:`~quimb.tensor.tensor_split`. :type cutoff_mode: {"rsum2", "rel", ...}, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param sweep_reverse: Whether to sweep in the reverse direction, resulting in a left canonical form instead of right canonical. :type sweep_reverse: bool, optional :param equalize_norms: Whether to equalize the norms of the tensors after compression. If an explicit value is give, then the norms will be set to that value, and the overall scaling factor will be accumulated into `.exponent`. :type equalize_norms: bool or float, optional :param inplace: Whether to perform the compression inplace or not. :type inplace: bool, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :returns: The compressed tensor network, with canonical center at ``site_tags[0]`` ('right canonical' form) or ``site_tags[-1]`` ('left canonical' form) if ``sweep_reverse``. :rtype: TensorNetwork .. py:function:: tensor_network_1d_compress_zipup_first(tn, max_bond=None, max_bond_zipup=None, cutoff=1e-10, cutoff_zipup=None, site_tags=None, canonize=True, normalize=False, cutoff_mode='rsum2', permute_arrays=True, optimize='auto-hq', sweep_reverse=False, equalize_norms=False, inplace=False, **compress_opts) Compress this 1D-like tensor network using the 'zip-up first' algorithm, that is, first compressing the tensor network to a larger bond dimension using the 'zip-up' algorithm, then compressing to the desired bond dimension using a direct sweep. Depending on the value of ``max_bond`` and ``max_bond_zipup``, this can be scale better than the direct and density matrix methods, but reach close to the same accuracy. As with the 'zip-up' method, there is no advantage unless there are multiple tensors per site, and it generally only makes sense in the fixed bond dimension case, as opposed to relying on a specific `cutoff` only. :param tn: The tensor network to compress. Every tensor should have exactly one of the site tags. Each site can have multiple tensors and output indices. :type tn: TensorNetwork :param max_bond: The final maximum bond dimension to compress to. :type max_bond: int :param max_bond_zipup: The intermediate maximum bond dimension to compress to using the 'zip-up' algorithm. If not given and `max_bond` is, this is set as twice the target bond dimension, ``2 * max_bond``. :type max_bond_zipup: int, optional :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param cutoff_zipup: A dynamic threshold for discarding singular values when compressing to the intermediate bond dimension using the 'zip-up' algorithm. If not given, this is set to the same as ``cutoff`` if a maximum bond is given, else ``cutoff / 10``. :type cutoff_zipup: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param canonize: Whether to pseudo canonicalize the initial tensor network. :type canonize: bool, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in right canonical form. :type normalize: bool, optional :param cutoff_mode: The mode to use when truncating the singular values of the decomposed tensors. See :func:`~quimb.tensor.tensor_split`. :type cutoff_mode: {"rsum2", "rel", ...}, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param sweep_reverse: Whether to sweep in the reverse direction, resulting in a left canonical form instead of right canonical. :type sweep_reverse: bool, optional :param equalize_norms: Whether to equalize the norms of the tensors after compression. If an explicit value is give, then the norms will be set to that value, and the overall scaling factor will be accumulated into `.exponent`. :type equalize_norms: bool or float, optional :param inplace: Whether to perform the compression inplace or not. :type inplace: bool, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :returns: The compressed tensor network, with canonical center at ``site_tags[0]`` ('right canonical' form) or ``site_tags[-1]`` ('left canonical' form) if ``sweep_reverse``. :rtype: TensorNetwork .. py:function:: _tn1d_fit_sum_sweep_1site(tn_fit: quimb.tensor.tensor_core.TensorNetwork, tn_overlaps, site_tags, max_bond=None, cutoff=0.0, envs=None, prepare=True, reverse=False, compute_tdiff=True, optimize='auto-hq') Core sweep of the 1-site 1D fit algorithm. .. py:function:: _tn1d_fit_sum_sweep_2site(tn_fit, tn_overlaps, site_tags, max_bond=None, cutoff=1e-10, envs=None, prepare=True, reverse=False, optimize='auto-hq', compute_tdiff=True, **compress_opts) Core sweep of the 2-site 1D fit algorithm. .. py:function:: tensor_network_1d_compress_fit(tns, max_bond=None, cutoff=None, tn_fit=None, bsz='auto', initial_bond_dim=8, max_iterations=10, tol=0.0, site_tags=None, cutoff_mode='rsum2', sweep_sequence='RL', normalize=False, permute_arrays=True, optimize='auto-hq', canonize=True, sweep_reverse=False, equalize_norms=False, inplace_fit=False, inplace=False, progbar=False, **compress_opts) Compress any 1D-like (can have multiple tensors per site) tensor network or sum of tensor networks to an exactly 1D (one tensor per site) tensor network of bond dimension `max_bond` using the 1-site or 2-site variational fitting (or 'DMRG-style') method. The tensor network(s) can have arbitrary inner and outer structure. This method has the lowest scaling of the standard 1D compression methods and can also provide the most accurate compression, but the actual speed and accuracy depend on the number of iterations required and initial guess, making it a more 'hands-on' method. It's also the only method to support fitting to a sum of tensor networks directly, rather than having to forming the explicitly summed TN first. :param tns: The tensor network or tensor networks to compress. Each tensor network should have the same outer index structure, and within each tensor network every tensor should have exactly one of the site tags. :type tns: TensorNetwork or Sequence[TensorNetwork] :param max_bond: The maximum bond dimension to compress to. If not given, this is set as the maximum bond dimension of the initial guess tensor network, if any, else infinite for ``bsz=2``. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. This is only relevant for the 2-site sweeping algorithm (``bsz=2``), where it defaults to 1e-10. :type cutoff: float, optional :param tn_fit: An initial guess for the compressed tensor network. It should matching outer indices and site tags with ``tn``. If a `dict`, this is assumed to be options to supply to `tensor_network_1d_compress` to construct the initial guess, inheriting various defaults like `initial_bond_dim`. If a string, e.g. ``"zipup"``, this is shorthand for that compression method with default settings. If not given, a random 1D tensor network will be used. :type tn_fit: TensorNetwork, dict, or str, optional :param bsz: The size of the block to optimize while sweeping. If ``"auto"``, this will be inferred from the value of ``max_bond`` and ``cutoff``. :type bsz: {"auto", 1, 2}, optional :param initial_bond_dim: The initial bond dimension to use when creating the initial guess. This is only relevant if ``tn_fit`` is not given. For each sweep the allowed bond dimension is doubled, up to ``max_bond``. For 1-site this occurs via explicit bond expansion, while for 2-site it occurs during the 2-site tensor decomposition. :type initial_bond_dim: int, optional :param max_iterations: The maximum number of variational sweeps to perform. :type max_iterations: int, optional :param tol: The convergence tolerance, in terms of local tensor distance normalized. If zero, there will be exactly ``max_iterations`` sweeps. :type tol: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param cutoff_mode: The mode to use when truncating the singular values of the decomposed tensors. See :func:`~quimb.tensor.tensor_split`, if using the 2-site sweeping algorithm. :type cutoff_mode: {"rsum2", "rel", ...}, optional :param sweep_sequence: The sequence of sweeps to perform, e.g. ``"LR"`` means first sweep left to right, then right to left. The sequence is cycled. :type sweep_sequence: str, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in left or right canonical form. :type normalize: bool, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param canonize: Dummy argument to match the signature of other compression methods. :type canonize: bool, optional :param sweep_reverse: Whether to sweep in the reverse direction, swapping whether the final tensor network is in right or left canonical form, which also depends on the last sweep direction. :type sweep_reverse: bool, optional :param equalize_norms: Whether to equalize the norms of the tensors after compression. If an explicit value is give, then the norms will be set to that value, and the overall scaling factor will be accumulated into `.exponent`. :type equalize_norms: bool or float, optional :param inplace_fit: Whether to perform the compression inplace on the initial guess tensor network, ``tn_fit``, if supplied. :type inplace_fit: bool, optional :param inplace: Whether to perform the compression inplace on the target tensor network supplied, or ``tns[0]`` if a sequence to sum is supplied. :type inplace: bool, optional :param progbar: Whether to show a progress bar. Note the progress bar shows the maximum change of any single tensor norm, *not* the global change in norm or truncation error. :type progbar: bool, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`, if using the 2-site sweeping algorithm. :returns: The compressed tensor network. Depending on ``sweep_reverse`` and the last sweep direction, the canonical center will be at either L: ``site_tags[0]`` or R: ``site_tags[-1]``, or the opposite if ``sweep_reverse``. :rtype: TensorNetwork .. py:function:: tensor_network_1d_compress_fit_guess(tn, guess, max_bond=None, cutoff=1e-10, cutoff_fit=0.0, bsz=1, max_iterations=8, canonize=True, **kwargs) Compress any 1D-like (can have multiple tensors per site) tensor network to an exactly 1D (one tensor per site) tensor network of bond dimension `max_bond` using by default 1-site variational fitting (or 'DMRG-style') method starting with a non-random guess tensor network, e.g. from the cheap zip-up or projector methods. .. py:data:: tensor_network_1d_compress_fit_zipup .. py:data:: tensor_network_1d_compress_fit_projector .. py:data:: _TN1D_COMPRESS_METHODS .. py:function:: tensor_network_1d_compress(tn, max_bond=None, cutoff=1e-10, method='dm', site_tags=None, canonize=True, permute_arrays=True, optimize='auto-hq', sweep_reverse=False, equalize_norms=False, compress_opts=None, inplace=False, **kwargs) Compress a 1D-like tensor network using the specified method. :param tn: The tensor network to compress. Every tensor should have exactly one of the site tags. Each site can have multiple tensors and output indices. :type tn: TensorNetwork :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param method: The compression method to use. :type method: {"direct", "dm", "zipup", "zipup-first", "fit", "projector", ...} :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param canonize: Whether to perform canonicalization, pseudo or otherwise depending on the method, before compressing. Ignored for ``method='dm'`` and ``method='fit'``. :type canonize: bool, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param sweep_reverse: Whether to sweep in the reverse direction, resulting in a left canonical form instead of right canonical (for the fit method, this also depends on the last sweep direction). :type sweep_reverse: bool, optional :param equalize_norms: Whether to equalize the norms of the tensors after compression. If an explicit value is give, then the norms will be set to that value, and the overall scaling factor will be accumulated into `.exponent`. :type equalize_norms: bool or float, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param kwargs: Supplied to the chosen compression method. :rtype: TensorNetwork .. py:function:: mps_gate_with_mpo_lazy(mps, mpo, inplace=False) Apply an MPO to an MPS lazily, i.e. nothing is contracted, but the new TN object has the same outer indices as the original MPS. .. py:function:: mps_gate_with_mpo_direct(mps, mpo, max_bond=None, cutoff=1e-10, inplace=False, **compress_opts) Apply an MPO to an MPS using the boundary compression method, that is, explicitly contracting site-wise to form a MPS-like TN, canonicalizing in one direction, then compressing in the other. This has the same scaling as the density matrix (dm) method, but a larger prefactor. It can still be faster for small bond dimensions however, and is potentially higher precision since it works in the space of singular values directly rather than singular values squared. It is not quite optimal in terms of error due to the compounding errors of the SVDs. :param mps: The MPS to gate. :type mps: MatrixProductState :param mpo: The MPO to gate with. :type mpo: MatrixProductOperator :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. .. py:function:: mps_gate_with_mpo_dm(mps, mpo, max_bond=None, cutoff=1e-10, inplace=False, **compress_opts) Gate this MPS with an MPO, using the density matrix compression method. :param mps: The MPS to gate. :type mps: MatrixProductState :param mpo: The MPO to gate with. :type mpo: MatrixProductOperator :param max_bond: The maximum bond dimension to keep when compressing the double layer tensor network, if any. :type max_bond: int, optional :param cutoff: The truncation error to use when compressing the double layer tensor network, if any. :type cutoff: float, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. .. py:function:: mps_gate_with_mpo_zipup(mps, mpo, max_bond=None, cutoff=1e-10, canonize=True, optimize='auto-hq', **compress_opts) Apply an MPO to an MPS using the 'zip-up' algorithm due to 'Minimally Entangled Typical Thermal State Algorithms', E.M. Stoudenmire & Steven R. White (https://arxiv.org/abs/1002.1305). :param mps: The MPS to gate. :type mps: MatrixProductState :param mpo: The MPO to gate with. :type mpo: MatrixProductOperator :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :param cutoff: A dynamic threshold for discarding singular values when compressing. :type cutoff: float, optional :param site_tags: The tags to use to group and order the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site, in the order given by ``site_tags``. :type site_tags: sequence of str, optional :param canonize: Whether to pseudo canonicalize the initial tensor network. :type canonize: bool, optional :param normalize: Whether to normalize the final tensor network, making use of the fact that the output tensor network is in right canonical form. :type normalize: bool, optional :param permute_arrays: Whether to permute the array indices of the final tensor network into canonical order. If ``True`` will use the default order, otherwise if a string this specifies a custom order. :type permute_arrays: bool or str, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :returns: The compressed MPS, in right canonical form. :rtype: MatrixProductState .. py:function:: mps_gate_with_mpo_zipup_first(mps, mpo, max_bond=None, max_bond_zipup=None, cutoff=1e-10, cutoff_zipup=None, canonize=True, optimize='auto-hq', **compress_opts) Apply an MPO to an MPS by first using the zip-up method with a larger bond dimension, then doing a regular compression sweep to the target final bond dimension. This avoids forming an intermediate MPS with bond dimension ``mps.max_bond() * mpo.max_bond()``. :param mps: The MPS to gate. :type mps: MatrixProductState :param mpo: The MPO to gate with. :type mpo: MatrixProductOperator :param max_bond: The target final bond dimension. :type max_bond: int :param max_bond_zipup: The maximum bond dimension to use when zip-up compressing the double layer tensor network. If not given, defaults to ``2 * max_bond``. Needs to be smaller than ``mpo.max_bond()`` for any savings. :type max_bond_zipup: int, optional :param cutoff: The truncation error to use when performing the final regular compression sweep. :type cutoff: float, optional :param cutoff_zipup: The truncation error to use when performing the zip-up compression. :type cutoff_zipup: float, optional :param canonize: Whether to pseudo canonicalize the initial tensor network. :type canonize: bool, optional :param optimize: The contraction path optimizer to use. :type optimize: str, optional :param compress_opts: Supplied to :func:`~quimb.tensor.tensor_split` (both the zip-up and final sweep). :returns: The compressed MPS, in right canonical form. :rtype: MatrixProductState .. py:function:: mps_gate_with_mpo_fit(mps, mpo, max_bond, **kwargs) Gate an MPS with an MPO using the variational fitting or DMRG-style method. :param mps: The MPS to gate. :type mps: MatrixProductState :param mpo: The MPO to gate with. :type mpo: MatrixProductOperator :param max_bond: The maximum bond dimension to compress to. :type max_bond: int :returns: The gated MPS. :rtype: MatrixProductState .. py:function:: mps_gate_with_mpo_autofit(self, mpo, max_bond, cutoff=0.0, init_guess=None, **fit_opts) Fit a MPS to a MPO applied to an MPS using geometry generic versions of either ALS or autodiff. This is usually much less efficient that using the 1D specific methods. Some nice alternatives to the default fit_opts: - method="autodiff" - method="als", solver="lstsq" .. py:function:: mps_gate_with_mpo_projector(self, mpo, max_bond, cutoff=1e-10, canonize=True, canonize_opts=None, inplace=False, **compress_opts) Apply an MPO to an MPS using local projectors, in the style of CTMRG or HOTRG, without using information beyond the neighboring 4 tensors.