Pattern Atlas

Extended Quantum Computing Patterns

Quantum Circuit Translator

Aliases:

Tags:

© IARIA, 2023

Intent

How can a quantum circuit be executed by different quantum computers with different instruction sets?

Context

Quantum circuits can be implemented in different programming languages and with different quantum gates. However, quantum computers typically only support specific circuit formats and instruction sets, which hinders interoperability and leads to vendor lock-in [Salm et al. 2020]. Thus, executing a quantum circuit on different quantum computers often requires a translation of the quantum circuit.

Forces

There are a multitude of quantum programming languages available for implementing quantum algorithms [Vietz et al. 2021]. A quantum circuit may be implemented in a programming language that is incompatible with the targeted quantum computer. The circuit needs to be re-implemented in a compatible quantum programming language and instruction set. However, a manual re-implementation is error-prone, time-consuming, and requires expertise in quantum computing, and, hence, is not feasible for real-world problem sizes. Therefore, an automatic translation, transforming unsupported gates into gates natively supported by the quantum computer, is required.

Solution

Use a translator to convert the quantum circuit into the target language and transpile the circuit to the target instruction set, i.e., replace unsupported gates with equivalent gates from the target instruction set.

Solution sketch quantum circuit translator

The solution sketch shows the application of a Quantum Circuit Translator that translates a quantum circuit between two programming languages and instruction sets. The SWAP gate connecting the outer qubit wires in the left quantum circuit has been decomposed into three C-NOT gates in the right target quantum circuit.

Result

A Quantum Circuit Translator is able to automatically translate a quantum circuit into a target format, enabling components with different circuit formats and instruction sets to use the same circuit. A Quantum Circuit Translator increases the reusability of Quantum Modules, as it enables their use with different quantum computers. However, the translated circuits do not need to be executed directly, but can instead be used as inputs for a Quantum Module Template. Therefore, a Quantum Circuit Translator enables the composition of quantum algorithms based on modules implemented in different programming languages. Thus, a Quantum Circuit Translator can be used to increase the interoperability of Quantum Modules.

Related Patterns

The Quantum Circuit Translator pattern is related to the Message Translator pattern from the enterprise integration pattern language. With a Canonical Data Model quantum circuits of any language can be translated into any other language using at most two translators for each language. A circuit translator can be used to translate circuits generated by a Quantum Module implemented in one programming language before using them with a Quantum Module Template implemented in a different programming language.

Known Uses

A widely used format for defining quantum circuits is OpenQASM [Cross et al. 2022], an open quantum assembly language. It can be imported and exported by many quantum software development kits (SDKs) such as Amazon Braket, Qiskit and Cirq. For estimating whether a quantum circuit can be executed, the NISQ Analyzer [Salm et al. 2020] needs the transpiled circuit for the respective quantum device. It includes multiple circuit translators. For the Python SDK Pennylane [Bergholm et al. 2018] there is a plugin enabling the support for IBM quantum computers without additional libraries. Explicit translation is supported by pytket Pytket Extensions from and to Cirq. Qconvert can convert from pyQuil or OpenQASM to several other formats by using their web tool.