Source-linked AI summary

Compiler Optimization for Quantum Computing Using Reinforcement Learning

Nils Quetschlich, Lukas Burgholzer, Robert Wille

arXiv:2212.04508v2quant-phcs.ETcs.LG

TL;DR

Quantum compilers lack consolidated pass choices and flexibility to combine methods across tools, despite compilation being essential for executing quantum circuits. This paper models compilation as an MDP and uses reinforcement learning to combine passes from different SDKs. The resulting framework outperforms individual Qiskit and TKET compilers in expected fidelity in 73% of cases.

  • Problem

    Quantum compilers lack consolidated best pass combinations, interoperability, adaptability, and flexibility in optimization goals.

    Source: §I · p. 1
  • Method

    The framework models quantum compilation as an MDP with distinct state constraints and a unified action interface, then applies reinforcement learning to combine passes from different tools.

    Source: §I · pp. 1–2, A. Modeling as a Markov Decision Process · p. 4
  • Results

    73% of cases showed better expected fidelity than the Qiskit/TKET compiler flows for a framework using passes from both tools.

    Source: B. Results · p. 5
  • Takeaways & Limitations

    The framework supports mixing passes from different SDKs and tools in one compilation flow.

    Source: A. Modeling as a Markov Decision Process · p. 4

Abstract

from arXiv · show

Any quantum computing application, once encoded as a quantum circuit, must be compiled before being executable on a quantum computer. Similar to classical compilation, quantum compilation is a sequential process with many compilation steps and numerous possible optimization passes. Despite the similarities, the development of compilers for quantum computing is still in its infancy -- lacking mutual consolidation on the best sequence of passes, compatibility, adaptability, and flexibility. In this work, we take advantage of decades of classical compiler optimization and propose a reinforcement learning framework for developing optimized quantum circuit compilation flows. Through distinct constraints and a unifying interface, the framework supports the combination of techniques from different compilers and optimization tools in a single compilation flow. Experimental evaluations show that the proposed framework -- set up with a selection of compilation passes from IBM's Qiskit and Quantinuum's TKET -- significantly outperforms both individual compilers in 73% of cases regarding the expected fidelity. The framework is available on GitHub (https://github.com/cda-tum/MQTPredictor) as part of the Munich Quantum Toolkit (MQT).

I. INTRODUCTION

Quantum compilers remain early in development, with unresolved choices about pass sequences, compatibility, adaptation, and optimization goals. The paper applies reinforcement learning to combine compilation passes from different tools, reporting better expected fidelity than individual Qiskit and TKET flows in 73% of cases.

I. INTRODUCTION

  • Quantum compilers are still early in development, with no consolidated best pass combinations, limited interoperability, slow uptake of research, and little flexibility in optimization goals.The authors note that techniques from classical compilers cannot be transferred straightforwardly because quantum and classical computation differ.Source: §I · p. 1
  • The framework models compilation as a Markov Decision Process and uses reinforcement learning to learn an ordering of compilation passes and optimizations.The approach adapts classical compiler-optimization research to quantum compilation.Source: §I · p. 1
  • Distinct state constraints and a unified interface make the framework platform agnostic and extendable with methods from different SDKs and tools.The paper presents this as a way to build optimized flows that can incorporate new methods as the field develops.Source: §I · p. 2
  • 73% of cases showed better expected fidelity than the individual Qiskit and TKET flows when the framework combined passes from both tools.The evaluation also reports improvements in critical depth and its combination with expected fidelity.Source: §I · p. 2

II. BACKGROUND: QUANTUM CIRCUIT COMPILATION

Quantum compilation transforms a circuit into a form executable on a particular device. The process includes optimizations, synthesis into native gates, and mapping to the device’s qubit connectivity.

II. BACKGROUND: QUANTUM CIRCUIT COMPILATION

  • Quantum programs are sequences of operations on qubits, and executing them on a QPU requires compilation.Device-independent optimizations can simplify circuits, for example by cancelling consecutive X gates.Source: §II · p. 2
  • Synthesis expresses non-native gates using a device’s native gate set, which can create further optimization opportunities.The example decomposes a Hadamard gate into native gates and then cancels an Rz gate pair.Source: §II · p. 2
  • Mapping assigns logical qubits to physical qubits and routes interactions to satisfy device connectivity.When connectivity prevents direct execution, routing may insert SWAP gates; some resulting overhead can be reduced by cancelling CNOT gates.Source: §II · p. 2
  • The paper proposes a framework to address the growing complexity of available synthesis, mapping, and optimization passes.The cited figure is identified as compilation of a quantum circuit to a targeted device.Source: Figure 1 · p. 2, §II · p. 3

III. PROPOSED FRAMEWORK

The proposed approach adapts classical compiler optimization to quantum circuits by modeling compilation and applying reinforcement learning. It aims to learn compilation-pass sequences that suit the initial circuit.

III. PROPOSED FRAMEWORK

  • The approach builds on decades of classical compiler optimization research to address quantum compilation.The paper frames quantum compilation as a setting where the available passes and their order must be selected.Source: §III · p. 3
  • The framework programmatically models quantum circuit compilation before applying reinforcement learning.Source: §III · p. 3
  • Reinforcement learning is used to learn a sequence of compilation passes based on characteristics of the initial circuit.The goal is an optimized compiler for quantum circuits.Source: §III · p. 3

A. Modeling as a Markov Decision Process

The framework represents quantum compilation as states and actions in a Markov Decision Process. State constraints and a shared action interface support combining passes from different SDKs and tools.

A. Modeling as a Markov Decision Process

  • Compilation is modeled as an MDP whose states represent circuit progress and whose actions apply transformations toward an executable circuit.The process begins with the initial circuit and proceeds through compilation steps.Source: A. Modeling as a Markov Decision Process · p. 3
  • Device-independent optimizations can be applied before selecting a quantum platform, which fixes the target native gate set.Examples include gate fusion, cancellation, commutation, and high-level synthesis.Source: A. Modeling as a Markov Decision Process · p. 3
  • Selecting a device fixes its qubit count and topology, after which compilation must meet native-gate and connectivity constraints.Synthesis addresses native gates, while mapping addresses device topology.Source: A. Modeling as a Markov Decision Process · p. 3
  • Each state has efficiently checkable constraints, and actions share a circuit input/output interface across SDKs and tools.Source: A. Modeling as a Markov Decision Process · p. 3
  • The shared interface allows compiler passes from different SDKs and tools to be combined in one optimized compiler.The authors also say this can help mitigate vendor lock-in and ease integration of new methods.Source: A. Modeling as a Markov Decision Process · p. 4

B. Compiler Optimization Using Reinforcement Learning

The framework treats compilation as an MDP and uses reinforcement learning to learn which compilation pass to apply from observations of the current circuit. Its reward can target circuit quality, allowing the trained policy to serve as an optimized compiler.

  • Reinforcement learning improves a policy that selects compilation passes from observations of the current circuit state to maximize expected cumulative reward.The environment specifies the MDP's states and actions, observations, and reward function; training data is not required.Source: B. Compiler Optimization Using… · p. 4
  • Circuit features provide observations, while a sparse reward scores final circuits by a chosen metric such as gate count, depth, or expected fidelity.The target metric can be selected for a dedicated use case.Source: B. Compiler Optimization Using… · p. 4
  • After training, the learned action policy can be used as an optimized compiler for quantum circuits.Source: B. Compiler Optimization Using… · p. 4

C. Related Work

Prior quantum-compilation machine-learning work has addressed specific actions or predicted options at a high abstraction level within one SDK. This framework instead offers fine-grained steps for combining methods from multiple SDKs under a customizable optimization objective.

  • Prior quantum-compilation machine-learning work includes layout and routing, fidelity prediction, compilation-flow selection, and learning gate-transformation strategies.The cited approaches vary from individual action optimization to predicting combinations of devices and compilation flows.Source: C. Related Work · p. 4
  • Earlier approaches either optimize a specific action type or predict options at a high abstraction level within one quantum SDK.Source: C. Related Work · p. 4
  • The proposed framework uses fine-grained steps to combine methods from multiple SDKs into a compilation flow with a customizable optimization objective.Source: C. Related Work · p. 4

IV. FEASIBILITY STUDY

The feasibility study describes the framework's implementation and evaluates its optimized compiler against Qiskit and TKET. Development and results are publicly available as part of MQT.

  • The study evaluates the resulting optimized compiler against state-of-the-art compilation flows in IBM’s Qiskit and Quantinuum’s TKET.Source: §IV · p. 4
  • The feasibility study first describes a particular framework instantiation and then evaluates its performance against the two compilers.Source: §IV · p. 4
  • The developments and results are publicly available on GitHub as part of the Munich Quantum Toolkit.Source: §IV · p. 4

A. Instantiation

The framework instantiates compiler optimization as a Gym environment with actions drawn from Qiskit and TKET. It guides learning with circuit features and offers reward functions for fidelity, critical depth, or their combination.

  • The action space covers platform and device selection, synthesis, mapping, and optimization, with methods integrated from Qiskit and TKET.The implementation uses Qiskit 0.39.2 and TKET 1.8.1; selected mapping and optimization methods include passes from both toolkits.Source: A. Instantiation · p. 4
  • The selected device set includes superconducting and trapped-ion platforms, including IBM, Rigetti, IonQ, and OQC devices.The listed devices range from 8 to 127 qubits.Source: A. Instantiation · p. 4
  • The learning agent observes seven circuit features: qubit count, circuit depth, and five composite features.The composite features are program communication, critical-depth, entanglement-ratio, parallelism, and liveness.Source: A. Instantiation · p. 5
  • The framework uses expected fidelity and 1 − critical depth as reward functions, averages them for a combination reward in [0,1], and uses Proximal Policy Optimization (PPO) for reinforcement learning.Source: A. Instantiation · p. 5

B. Results

The framework generally outperforms Qiskit and TKET across three objectives, and models trained for a particular objective achieve the highest reward for that objective.

B. Results

  • 73%/80%, 84%/86%, and 75%/78.5% of cases outperform Qiskit/TKET for expected fidelity, critical depth, and their combination, respectively.Fig. 3a–c show the distributions of reward differences; positive values indicate improvement.Source: B. Results · p. 5
  • Fig. 3d and 3e compare average reward differences per benchmark algorithm, subsuming instances with varying qubit counts.Source: B. Results · p. 5
  • For all three quality metrics, the model trained for that purpose produces the compiled circuits with the highest rewards.Table I compares average rewards for each metric across all three trained models.Source: B. Results · p. 5, Table I · p. 5

V. CONCLUSIONS

The conclusion presents a reinforcement-learning framework for quantum circuit compilation, using classical compiler optimization ideas to address increasingly complex flows. Evaluations report advantages over Qiskit and TKET across three objectives and support automatically creating flows for customizable objectives.

V. CONCLUSIONS

  • In 73%, 84%, and 75% of cases, trained models outperform Qiskit/TKET regarding expected fidelity, critical depth, and their combination, respectively.Average absolute improvements are 4.9%/10.7%, 22.6%/22.8%, and 5.5%/8.5% for those objectives, respectively.Source: §V · p. 5
  • The framework models compilation as a Markov Decision Process with distinct state constraints and a unified interface for actions from multiple SDKs and toolkits.Source: §V · p. 5
  • The authors make the framework publicly available as open-source and hope it will support further exploration of quantum compiler optimization.Source: §V · p. 5
Loading 2212.04508v2…