Constructing Optimal Contraction Trees for Tensor Network Quantum Circuit Simulation

Cameron Ibrahim, Danylo Lykov, Zichang He, Yuri Alexeev, Ilya Safro

TL;DR

This paper introduces a novel approach to quantum circuit simulation by reducing the NP-hard problem of finding optimal tensor contraction orders to a graph linear ordering problem. By combining a multilevel linear ordering heuristic with a new polynomial-time dynamic programming algorithm for tree optimization, the authors achieve simulation costs up to several orders of magnitude lower than current state-of-the-art solvers.

What Problem Does This Paper Address?

Simulating quantum circuits on classical hardware is a massive computational challenge. One popular method represents the circuit as a tensor network, where gates are tensors and shared indices (qubits) are edges. To find the final state, you must "contract" these tensors together.

The catch? The cost of a single contraction is exponential relative to the number of indices involved. The sequence in which you contract tensors—represented as a contraction tree—determines the "congestion" (maximum intermediate tensor size) and the total number of floating-point operations (FLOPs). Finding the absolute best tree is an NP-hard problem. While heuristics exist, even small improvements in the contraction tree can lead to massive speedups in simulation time, making this a high-stakes optimization problem for the quantum computing community.

Methods

The authors propose a two-step strategy that decouples the search for a sequence from the construction of the tree:

  1. Linear Ordering Heuristic: Instead of searching for a tree directly, they search for a linear ordering of tensors. They use a Minimum Linear Arrangement (MLA) objective, which tries to keep tensors that share many indices close to each other in the sequence. To solve this, they utilize a multilevel solver (LinearOrdering.jl) that uses volume-based coarsening to handle large graphs efficiently.
  2. Tree Structure Optimization: This is the paper's core theoretical contribution. Given a fixed linear ordering, the authors provide a novel polynomial-time dynamic programming algorithm to find the optimal binary contraction tree for that specific order.
Fig. 1: An example contraction tree with labeled leaves.

By iterating through different linear orders and applying this optimal tree builder, they can explore the solution space more effectively than methods that try to build the tree greedily or via recursive bisection.

Datasets

The researchers evaluated their method using a collection of randomly generated Quantum Approximate Optimization Algorithm (QAOA) Max Cut circuits.

  • Graph Topology: 32-vertex d-regular graphs (with degrees $d=3, 4, 5$).
  • Circuit Depth: $p$-layers ranging from 2 to 5.
  • Scaling Test: To test scalability, they generated circuits for 32, 64, 96, and 128 qubits.
  • Comparison: They benchmarked against industry-standard solvers: Tamaki-2017, FlowCutter, and Cotengra.

Key Insights and Ideas

  • Decoupling is Key: By separating the "hard" part (finding a good linear sequence) from the "tractable" part (building the best tree for that sequence), they can leverage highly optimized graph ordering libraries.
  • MLA as a Proxy: The Minimum Linear Arrangement objective serves as an excellent heuristic for reducing treewidth and congestion. Tensors that are "close" in the graph should be contracted sooner to prevent the number of open indices from exploding.
  • Dynamic Programming with Pruning: The tree optimization algorithm ($O(|E||V|^2 + d|V|^3)$) uses memoization and pruning (skipping branches that already exceed the current best cost) to remain fast enough for practical use during the search process.

Key Results

The proposed method consistently outperformed existing solvers across multiple metrics:

  • Vertex Congestion: Their approach was strictly better than FlowCutter on 96.4% of test cases and better than Tamaki-2017 on 90% of cases, without ever producing a worse result.
  • Operation Count (FLOPs): When compared to Cotengra, their solver found better solutions for 95% of the circuits when minimizing total operations.
  • Scaling to Large Qubits: The advantage grew significantly with circuit size. For 96 and 128-qubit circuits, the tree structure optimization produced results several orders of magnitude better than Cotengra for the same 10-second search time.
Fig. 2: Vertex Congestion comparison against Tamaki-2017 and FlowCutter. Points above the blue line indicate the new method found a superior (lower cost) value.

Limitations and Future Work

  • Hyperedges: Currently, the model treats tensor networks as standard undirected graphs (where each index connects exactly two tensors). However, some quantum circuits involve "hyperindices" connecting multiple gates. The authors note that extending their tree optimization to hypergraphs is a necessary next step.
  • Parallelization: The current implementation of the tree optimization algorithm is serial. Parallelizing the dynamic programming calls could significantly speed up the search for optimal trees.
  • Refinement Objectives: The current heuristic targets the general MLA objective. The authors suggest that developing refinement strategies that directly target the "width" of the order could yield even better contraction trees.

Summary updated

BibTeX
@inproceedings{ibrahim2022constructing,
  author = {Cameron Ibrahim and Danylo Lykov and Zichang He and Yuri Alexeev and Ilya Safro},
  title = {{Constructing Optimal Contraction Trees for Tensor Network Quantum Circuit Simulation}},
  booktitle = {HPEC},
  year = {2022},
  url = {https://openreview.net/forum?id=D_NDwqHmXdF},
}
Figure