tensornetwork.contractors.bucket

tensornetwork.contractors.bucket(nodes: Iterable[tensornetwork.network_components.AbstractNode], contraction_order: Sequence[tensornetwork.network_components.CopyNode]) → Iterable[tensornetwork.network_components.AbstractNode]

Contract given nodes exploiting copy tensors.

This is based on the Bucket-Elimination-based algorithm described in arXiv:quant-ph/1712.05384, but avoids explicit construction of the graphical model. Instead, it achieves the efficient contraction of sparse tensors by representing them as subnetworks consisting of lower rank tensors and copy tensors. This function assumes that sparse tensors have already been decomposed this way by the caller.

This contractor is efficient on networks with many copy tensors. Time and memory requirements are highly sensitive to the requested contraction order.

Note that the returned tensor network may not be fully contracted if the input network doesn’t have enough copy nodes. In this case, the client should use a different contractor to complete the contraction.

Parameters:
  • nodes – A collection of connected nodes.
  • contraction_order – Order in which copy tensors are contracted.
Returns:

A new iterable of nodes after contracting copy tensors.