RL-Guided Contraction of Symbolic Tensor Networks for Quantum Circuit Equivalence

Suhaib Al-Rousan, Christian Schilling, Max Tschaikowski, Kim Guldstrand LarsenNeurIPS 2026

TL;DR

When a quantum compiler optimizes a circuit, how do we verify it didn't accidentally break the math without running out of memory? This paper trains a reinforcement learning (RL) agent to navigate Tensor Decision Diagrams—compact, symbolic graphs representing quantum circuits—finding smart merge sequences that dodge catastrophic memory blow-ups. By learning to preserve symbolic symmetries rather than just counting raw arithmetic operations, the agent verifies circuits dramatically faster and leaner than existing heuristics, all on a standard consumer laptop.

What Problem Does This Paper Address?

Checking if an optimized quantum circuit $C'$ does the exact same thing as the original circuit $C$ is conceptually simple: run $C$ forward, run $C'$ backward, and check if they cancel out into an identity matrix. The catch? That matrix grows as $2^n \times 2^n$ with the number of qubits $n$, quickly exceeding the memory of any classical computer.

To dodge this exponential wall, researchers represent circuits as Tensor Networks (TNs)—graphs where quantum gates are nodes and wires are edges—and iteratively merge ("contract") pairs of connected nodes until one remains. To squeeze memory down even further, Tensor Decision Diagrams (TDDs) replace dense arrays with compressed, canonical directed acyclic graphs that share repeating substructures—much like merging identical branches in a decision tree.

Figure 3: A TDDN representation of the TN in Figure 1(b), and the TDD resulting from contraction.

However, the order in which you contract nodes makes or breaks the computation (finding the optimal order is NP-hard). Standard TN planners estimate costs using static math like floating-point operations (FLOPs). On TDDs, those planners fail spectacularly: a merge that looks arithmetically cheap on paper can shatter the diagram's internal symmetries, destroying subgraph sharing and triggering a sudden "node explosion" in memory. Static TDD heuristics exist, too, but they tend to be short-sighted.

Methods

The authors cast TDD contraction planning as a sequential decision-making game solved via Proximal Policy Optimization (PPO)—a standard, stable RL algorithm tailored here with three novel design choices:

  • Symbolic-Aware State & Reward: At each step, the agent observes the evolving TDD network, picking an edge to contract. Instead of static tensor dimensions, the state encodes dynamic symbolic metrics: current log-scaled TDD node counts ("memory load"), merge history, bond strengths, and global graph progress. The reward function explicitly punishes memory spikes using $- \lambda (\log_{10}|\text{TDD}|)^{1.5}$.
  • Hybrid GNN Policy: Because the state is a dynamic graph, the actor-critic agent uses a custom three-stage Graph Neural Network encoder—combining edge-aware message passing (GINE), neighbor attention (GAT), and sparse edge-conditioned Transformer layers—to score candidate edges.
  • Three-Phase Curriculum: Because one bad move early in training causes massive memory and runtime stalls, the agent starts on tiny graphs and synthetic random circuits, gradually graduating to larger, complex networks.
Figure 4: RL framework for TDDN contraction. The environment maintains the TDDN graph, which the agent processes through a graph encoder before actor and critic heads select a contraction edge.

Datasets

The authors source five circuit families (5 to 23 qubits) from the standard MQT Bench suite:

  • Training & Validation (70/30 split): Deutsch–Jozsa (DJ), GHZ, W-State, and Quantum Neural Networks (QNN). Training phases are augmented with synthetic random circuits matched by graph size.
  • Zero-Shot Unseen Family: Bernstein–Vazirani (BV) is completely held out during training to test topological generalization.
  • New Non-Equivalent Benchmark: To ensure the agent didn't just learn a "shortcut to the identity matrix," the authors introduce 304 non-equivalent test pairs created via compiler-style gate mutations and mismatched DJ parities.

Key Insights and Ideas

  • Graph complexity matters more than qubit count: A circuit with fewer qubits but dense entanglement can yield a much gnarlier TDD graph than a 45-qubit circuit with sparse gates. Normalizing features by graph scale rather than raw qubit count allows the policy to generalize zero-shot to much wider circuits.
  • True lookahead emerges: Local TDD heuristics greedily delay pain, often walking straight into late-stage memory traps on entangled circuits (W-State, QNN). The RL agent learns to occasionally swallow a slightly larger intermediate diagram early on to preserve global symmetries later.
  • Training only on equivalent pairs doesn't blind the verifier: Even though the agent never saw a buggy circuit during training, its learned structural intuition transfers cleanly to non-equivalent circuits without producing a single false verdict.

Key Results

Tested on an Apple M3 MacBook Air (16 GB RAM) against four state-of-the-art Cotengra TN optimizers (Greedy, Random Greedy, Betweenness, KaHyPar) and the TDD-specific Counting heuristic:

  • Smaller Memory Footprint: On the held-out evaluation set, the RL policy cuts mean peak TDD node count by 2.51× vs. Counting, 5.34× vs. Greedy, and 6.50× vs. KaHyPar.
  • Massive Speedups: By amortizing search into fast GNN inference (~0.047s total average runtime), it achieves end-to-end speedups of 63.7× over KaHyPar and 12.3× over Greedy.
  • High-Qubit Scaling: Using a hybrid wrapper (Counting shrinks large graphs until they fit the GNN's input window, then RL takes over), the method verifies a 50-qubit W-State circuit in 8.4 seconds (peaking at 15,289 nodes), whereas every baseline times out past 120 seconds.
Figure 5: Aggregated performance comparison (averaged) on the evaluation set.

Limitations and Future Work

  • Fixed Observation Window: Input padding caps the GNN at a fixed graph capacity ($N_{\max}=87$ nodes, $M_{\max}=151$ edges), requiring a heuristic hand-off on massive initial graphs.
  • Offline Training Cost: Computing exact symbolic rewards requires executing real TDD contractions during training (~4 hours on consumer CPU hardware).
  • Structured Circuits Only: Because TDDs thrive on regularity, the policy specializes in structured algorithmic circuits and struggles on unstructured, random circuits.

Future directions include integrating the planner directly into quantum compiler pipelines, making the curriculum aware of physical hardware topologies, and tackling highly entangled or unstructured circuits.

Summary updated

Abstract

Verifying that two quantum circuits are equivalent is a critical challenge in compiler validation. A common approach is to transform the circuits into a tensor network and then iteratively contract tensors in the network. The order in which contractions are applied has a crucial influence on the complexity, as tensor size may grow exponentially in the number of qubits. This motivated research into heuristic policies to find good contraction orders, including recent work based on reinforcement learning (RL). Orthogonally, to mitigate the complexity of an explicit tensor representation, tensor decision diagrams (TDDs) have been proposed as a compact symbolic representation. However, also the TDD performance is sensitive to the contraction order, and policies designed for tensor networks do not perform well in case of a TDD representation. In this paper, we propose an RL framework to obtain a graph-neural-network policy that navigates the trade-off between arithmetic complexity and TDD size. Experimental results demonstrate that a policy learned with our framework is effective at taming the symbolic representation size.
BibTeX
@inproceedings{alrousan2026rl,
  author = {Suhaib Al-Rousan and Christian Schilling and Max Tschaikowski and Kim Guldstrand Larsen},
  title = {{RL-Guided Contraction of Symbolic Tensor Networks for Quantum Circuit Equivalence}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=cQ7bzhrYxe},
}
Figure