:py:mod:`quimb.tensor.tensor_arbgeom_compress` ============================================== .. py:module:: quimb.tensor.tensor_arbgeom_compress .. autoapi-nested-parse:: Generic methods for compressing arbitrary geometry tensor networks, where the tensor network can locally have arbitrary structure and outer indices. - [x] projector - [x] l2bp - [x] local early - [x] local late - [x] superorthogonal Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_projector quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_early quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_late quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_superorthogonal quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_l2bp quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress Attributes ~~~~~~~~~~ .. autoapisummary:: quimb.tensor.tensor_arbgeom_compress._TNAG_COMPRESS_METHODS .. py:function:: tensor_network_ag_compress_projector(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, canonize_opts=None, lazy=False, optimize='auto-hq', equalize_norms=False, inplace=False, **compress_opts) Compress an arbtrary geometry tensor network, with potentially multiple tensors per site, using locally computed projectors. Very loosely, this is like a generalization HOTRG. :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 the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to pseudo canonicalize the initial tensor network. :type canonize: bool, optional :param canonize_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.gauge_all`. :param lazy: Whether to leave the computed projectors uncontracted, default: False. :type lazy: bool, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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 compress_opts: Supplied to :func:`~quimb.tensor.tensor_split`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_local_early(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, tree_gauge_distance=None, canonize_distance=None, canonize_after_distance=None, mode='auto', optimize='auto-hq', equalize_norms=False, inplace=False, **compress_opts) Compress an arbtrary geometry tensor network, with potentially multiple tensors per site, using explicit contraction followed by immediate ('early') compression. In other words, contractions are interleaved with compressions. Very loosely, this is like a generalization of the 'zip-up' algorithm in 1D, but for arbitrary geometry. :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 the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to locally gauge before each compression, defaults to True. :type canonize: bool, optional :param tree_gauge_distance: The distance to locally gauge to before each compression. Defaults to 3. :type tree_gauge_distance: int, optional :param canonize_distance: The distance to canonize to before each compression, by default this is set by ``tree_gauge_distance``. :type canonize_distance: int, optional :param canonize_after_distance: The distance to canonize to after each compression, by default this is set by ``tree_gauge_distance``, depending on ``mode``. :type canonize_after_distance: int, optional :param mode: The mode to use for the local gauging. If 'auto' will default to virtual tree gauging, or basic if `tree_gauge_distance` is 0. :type mode: {'auto', 'basic', 'virtual-tree', ...}, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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 compress_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_between`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_local_late(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, tree_gauge_distance=None, canonize_distance=None, canonize_after_distance=None, mode='auto', optimize='auto-hq', equalize_norms=False, inplace=False, **compress_opts) Compress an arbtrary geometry tensor network, with potentially multiple tensors per site, by explicitly contracting all sites first and then ('late') locally compressing. In other words, all contractions happen, then all compressions happen. Very loosely, this is like a generalization of the 'direct' algorithm in 1D, but for arbitrary geometry. :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 the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to locally gauge before each compression, defaults to True. :type canonize: bool, optional :param tree_gauge_distance: The distance to locally gauge to before each compression. Defaults to 3. :type tree_gauge_distance: int, optional :param canonize_distance: The distance to canonize to before each compression, by default this is set by ``tree_gauge_distance``. :type canonize_distance: int, optional :param canonize_after_distance: The distance to canonize to after each compression, by default this is set by ``tree_gauge_distance``, depending on ``mode``. :type canonize_after_distance: int, optional :param mode: The mode to use for the local gauging. If 'auto' will default to virtual tree gauging, or basic if `tree_gauge_distance` is 0. :type mode: {'auto', 'basic', 'virtual-tree', ...}, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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 compress_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_between`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_superorthogonal(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, optimize='auto-hq', equalize_norms=False, inplace=False, **compress_opts) Compress an arbtrary geometry tensor network, with potentially multiple tensors per site, using the 'superorthogonal' / 'Vidal' / quasi-canonical / 'simple update' gauge for compression. This is the same gauge as used in L2BP, but the intermediate tensor network is explicitly constructed. :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 the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to locally gauge before each compression, defaults to True. :type canonize: bool, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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 compress_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.compress_all_simple`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_l2bp(tn, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, damping=0.0, local_convergence=True, update='sequential', optimize='auto-hq', equalize_norms=False, inplace=False, **compress_opts) Compress an arbitrary geometry tensor network, with potentially multiple tensors per site, using lazy 2-norm belief propagation. :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 the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to locally gauge before each compression, defaults to True. :type canonize: bool, optional :param damping: How much to dampen message updates, to help convergence, defaults to 0. :type damping: float, optional :param local_convergence: Whether to use local convergence criteria, defaults to True. :type local_convergence: bool, optional :param update: Whether to update all messages in parallel or sequentially, defaults to 'parallel'. :type update: {'parallel', 'sequential'}, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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 compress_opts: Supplied to :func:`~quimb.experimental.belief_propagation.l2bp.compress_l2bp`. :rtype: TensorNetwork .. py:data:: _TNAG_COMPRESS_METHODS .. py:function:: tensor_network_ag_compress(tn, max_bond, cutoff=1e-10, method='local-early', site_tags=None, canonize=True, optimize='auto-hq', equalize_norms=False, inplace=False, **kwargs) Compress an arbitrary geometry tensor network, with potentially multiple tensors per site. :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: - 'local-early': explicitly contract each site and interleave with immediate compression, see :func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_early`. - 'local-late': explicitly contract all sites and then compress, see :func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_local_late`. - 'projector': use locally computed projectors, see :func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_projector`. - 'superorthogonal': use the 'superorthogonal' gauge, see :func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_superorthogonal`. - 'l2bp': use lazy 2-norm belief propagation, see :func:`~quimb.tensor.tensor_arbgeom_compress.tensor_network_ag_compress_l2bp`. :type method: {'local-early', 'local-late', 'projector', 'superorthogonal', 'l2bp'}, optional :param site_tags: The tags to use to group the tensors from ``tn``. If not given, uses ``tn.site_tags``. The tensor network built will have one tensor per site. :type site_tags: sequence of str, optional :param canonize: Whether to perform canonicalization, pseudo or otherwise depending on the method, before compressing. :type canonize: bool, optional :param optimize: The contraction path optimizer to use. :type optimize: str, 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.