quimb.tensor.tnag.compress ========================== .. py:module:: quimb.tensor.tnag.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 Attributes ---------- .. autoapisummary:: quimb.tensor.tnag.compress._TNAG_COMPRESS_METHODS Functions --------- .. autoapisummary:: quimb.tensor.tnag.compress.tensor_network_ag_compress_projector quimb.tensor.tnag.compress.tensor_network_ag_compress_local_early quimb.tensor.tnag.compress.tensor_network_ag_compress_local_late quimb.tensor.tnag.compress.tensor_network_ag_compress_superorthogonal quimb.tensor.tnag.compress.tensor_network_ag_compress_l2bp quimb.tensor.tnag.compress.tensor_network_ag_compress Module Contents --------------- .. py:function:: tensor_network_ag_compress_projector(tn: quimb.tensor.tensor_core.TensorNetwork, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, canonize_opts=None, power=1.0, smudge=0.0, lazy=False, equalize_norms=False, optimize='auto-hq', contract_opts=None, reduce_opts=None, compress_opts=None, gauge_power=1.0, gauge_smudge=0.0, inplace=False, **kwargs) 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: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, optional :param canonize: How to pseudo canonicalize the initial tensor network. ``True`` gauges the whole network with simple update. ``'layered'`` gauges each tensor layer separately. ``'bp'`` uses dense 2-norm belief propagation messages as the projector environments. :type canonize: bool or {'layered', 'bp'}, optional :param canonize_opts: Options for the canonicalization method you select. If ``canonize='bp'``, this function supplies them to :func:`~quimb.tensor.belief_propagation.d2bp.converge_d2bp`. :type canonize_opts: dict, optional :param power: Condition the messages with this power during BP iteration, if ``canonize='bp'``. :type power: float, optional :param smudge: Add this relative value to the message spectra during BP iteration, if ``canonize='bp'``. :type smudge: float, optional :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 contract_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.to_dense` when contracting the projectors. Values set here take precedence over any defaults. :type contract_opts: dict, optional :param reduce_opts: Supplied to :func:`squared_op_to_reduced_factor` when computing the projectors. Values set here take precedence over any defaults. :type reduce_opts: dict, optional :param compress_opts: Supplied to :meth:`~quimb.tensor.tensor_core.TensorNetwork.insert_compressor_between_regions_` when inserting projectors. Values set here take precedence over any defaults. :type compress_opts: dict, optional :param gauge_power: Condition the gauge or message environments with this power when this function constructs the projectors. :type gauge_power: float, optional :param gauge_smudge: Add this relative value to the gauge or message environments when this function constructs the projectors. :type gauge_smudge: float, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param kwargs: Extra keyword arguments are combined into `compress_opts`, though existing items in `compress_opts` take precedence over `kwargs`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_local_early(tn: quimb.tensor.tensor_core.TensorNetwork, 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, compress_opts=None, inplace=False, **kwargs) 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: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, 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 compress_opts: Supplied to :func:`~quimb.tensor.TensorNetwork.compress_between` when compressing between sites. Values set here take precedence over any defaults. :type compress_opts: dict, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param kwargs: Extra keyword arguments are combined into `compress_opts`, though existing items in `compress_opts` take precedence over `kwargs`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_local_late(tn: quimb.tensor.tensor_core.TensorNetwork, 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, compress_opts=None, inplace=False, **kwargs) 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: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, 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 compress_opts: Supplied to :func:`~quimb.tensor.TensorNetwork.compress_all` when compressing between sites. Values set here take precedence over any defaults. :type compress_opts: dict, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param kwargs: Extra keyword arguments are combined into `compress_opts`, though existing items in `compress_opts` take precedence over `kwargs`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_superorthogonal(tn: quimb.tensor.tensor_core.TensorNetwork, max_bond=None, cutoff=1e-10, site_tags=None, canonize=True, optimize='auto-hq', equalize_norms=False, compress_opts=None, inplace=False, **kwargs) 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: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, 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 compress_opts: Supplied to :func:`~quimb.tensor.TensorNetwork.compress_all_simple` when compressing between sites. Values set here take precedence over any defaults. :type compress_opts: dict, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param kwargs: Extra keyword arguments are combined into `compress_opts`, though existing items in `compress_opts` take precedence over `kwargs`. :rtype: TensorNetwork .. py:function:: tensor_network_ag_compress_l2bp(tn: quimb.tensor.tensor_core.TensorNetwork, 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, compress_opts=None, inplace=False, **kwargs) 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: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, 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 compress_opts: Supplied to :func:`~quimb.tensor.belief_propagation.l2bp.compress_l2bp`. Values set here take precedence over any defaults. :type compress_opts: dict, optional :param inplace: Whether to perform the compression inplace. :type inplace: bool, optional :param \*\*kwargs: Extra keyword arguments are combined into `compress_opts`, though existing items in `compress_opts` take precedence over `kwargs`. :rtype: TensorNetwork .. py:data:: _TNAG_COMPRESS_METHODS .. py:function:: tensor_network_ag_compress(tn: quimb.tensor.tensor_core.TensorNetwork, max_bond, cutoff=1e-10, method='local-early', site_tags=None, canonize=True, optimize='auto-hq', equalize_norms=False, inplace=False, sweep_reverse=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. A callable is passed the same arguments as a built-in arbitrary-geometry method. The named options are: - 'local-early': explicitly contract each site and interleave with immediate compression, see :func:`~quimb.tensor.tnag.compress.tensor_network_ag_compress_local_early`. - 'local-late': explicitly contract all sites and then compress, see :func:`~quimb.tensor.tnag.compress.tensor_network_ag_compress_local_late`. - 'projector': use locally computed projectors, see :func:`~quimb.tensor.tnag.compress.tensor_network_ag_compress_projector`. - 'superorthogonal': use the 'superorthogonal' gauge, see :func:`~quimb.tensor.tnag.compress.tensor_network_ag_compress_superorthogonal`. - 'l2bp': use lazy 2-norm belief propagation, see :func:`~quimb.tensor.tnag.compress.tensor_network_ag_compress_l2bp`. :type method: str or callable, optional :param site_tags: Tags that identify sites. Defaults to ``tn.site_tags``. Each item can group tags as described by :func:`~quimb.tensor.parse_site_tag_groups`. The output has one tensor per item. :type site_tags: sequence of str or tag groups, optional :param canonize: Whether to perform canonicalization, pseudo or otherwise depending on the method, before compressing. The ``'projector'`` method also accepts ``'layered'``, which gauges each layer with simple update, and ``'bp'``, which uses dense 2-norm belief propagation environments. :type canonize: bool or str, 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 sweep_reverse: Ignored, since there is no sweep direction. Accepted to match the 1D methods, with a warning if ``True``. :type sweep_reverse: bool, optional :param kwargs: Supplied to the chosen compression method.