Choose a Contraction Path Finder

Goal

Configure how the tensor network contraction order is determined. The contraction path finder strongly affects performance and peak memory of tensor-network-based estimators and samplers.

Overview

Both the tensor network estimator and the tensor network sampler expose a choose_contraction_path_finder() method. The available path finders are:

  • .sequential() (default): tries a fast greedy heuristic first, then falls through to the comprehensive multi-strategy finder if the greedy path exceeds resource thresholds.

  • .random_greedy_128(): randomized greedy algorithm with 128 trials. A quick heuristic.

  • .multi_strategy(): runs multiple strategies and returns the best path.

  • .none(): Choose no contraction path finder. This will leave finding the contraction path up to the contraction calculator.

If choose_contraction_path_finder() is not called, the default sequential() path finder is used.

Sequential Path Finder (default)

The sequential path finder tries path finders in order (cheapest first) and returns the first path that satisfies both a FLOPs and a memory threshold. By default it uses:

  • Tier 1 (greedy): fast heuristic, accepted for small problems.

  • Tier 2 (multi-strategy): comprehensive search across multiple strategies, always accepted as the final fallback.

This code example is for estimator - but it is the same for sampler.

import qrunch as qc

# Use default sequential (greedy -> multi-strategy)
estimator = (
      qc.estimator_creator()
      .tensor_network()
      .choose_contraction_path_finder()
      .sequential()
      .create()
)

Greedy algorithm with 128 trials

Randomized greedy algorithm with 128 trials. A quick heuristic. This code example is for estimator - but it is the same for sampler.

import qrunch as qc

# Use default sequential (greedy -> multi-strategy)
estimator = (
      qc.estimator_creator()
      .tensor_network()
      .choose_contraction_path_finder()
      .random_greedy_128()
      .create()
)

Multi-Strategy Path Finder

The .multi_strategy() path finder runs multiple strategies and returns the best path (lowest FLOPs) that fits within the memory budget. Falls back to slicing/memory-limited strategies if no path fits.

It does not include a fast greedy heuristic — use sequential() if you want greedy as a fast first tier before the multi-strategy search. This code example is for estimator - but it is the same for sampler.

import qrunch as qc

estimator = (
      qc.estimator_creator()
      .tensor_network()
      .choose_contraction_path_finder()
      .multi_strategy(max_memory_fraction=0.8)
      .create()
)

See Also