Run your circuits with OpenQASM 3.0 - Amazon Braket

Run your circuits with OpenQASM 3.0

Amazon Braket now supports OpenQASM 3.0 for gate-based quantum devices and simulators. This user guide provides information about the subset of OpenQASM 3.0 supported by Braket. Braket customers now have the choice of submitting Braket circuits with the SDK or by directly providing OpenQASM 3.0 strings to all gate-based devices with the Amazon Braket API and the Amazon Braket Python SDK.

The topics in this guide walk you through various examples of how to complete the following quantum tasks.

This guide also provides an introduction to certain hardware-specific features that can be implemented with OpenQASM 3.0 on Braket and links to further resources.

What is OpenQASM 3.0?

The Open Quantum Assembly Language (OpenQASM) is an intermediate representation for quantum instructions. OpenQASM is an open-source framework and is widely used for the specification of quantum programs for gate-based devices. With OpenQASM, users can program the quantum gates and measurement operations that form the building blocks of quantum computation. The previous version of OpenQASM (2.0) was used by a number of quantum programming libraries to describe simple programs.

The new version of OpenQASM (3.0) extends the previous version to include more features, such as pulse-level control, gate timing, and classical control flow to bridge the gap between end-user interface and hardware description language. Details and specification on the current version 3.0 are available on the GitHub OpenQASM 3.x Live Specification. OpenQASM’s future development is governed by the OpenQASM 3.0 Technical Steering Committee, of which AWS is a member alongside IBM, Microsoft, and the University of Innsbruck.

When to use OpenQASM 3.0

OpenQASM provides an expressive framework to specify quantum programs through low-level controls that are not architecture specific, making it well suited as a representation across multiple gate-based devices. The Braket support for OpenQASM furthers its adoption as a consistent approach to developing gate-based quantum algorithms, reducing the need for users to learn and maintain libraries in multiple frameworks.

If you have existing libraries of programs in OpenQASM 3.0, you can adapt them for use with Braket rather than completely rewriting these circuits. Researchers and developers should also benefit from an increasing number of available third-party libraries with support for algorithm development in OpenQASM.

How OpenQASM 3.0 works

Support for OpenQASM 3.0 from Braket provides feature parity with the current Intermediate Representation. This means that anything you can do today on hardware devices and on-demand simulators with Braket, you can do with OpenQASM using the Braket API. You can run OpenQASM 3.0 programs by directly supplying OpenQASM strings to all gate-based devices in a manner that is similar to how circuits are currently supplied to devices on Braket. Braket users can also integrate third-party libraries that support OpenQASM 3.0. The rest of this guide details how to develop OpenQASM representations for use with Braket.

Prerequisites

To use OpenQASM 3.0 on Amazon Braket, you must have version v1.8.0 of the Amazon Braket Python Schemas and v1.17.0 or higher of the Amazon Braket Python SDK.

If you are a first time user of Amazon Braket, you need to enable Amazon Braket. For instructions, see Enable Amazon Braket.

The Braket console

OpenQASM 3.0 tasks are available and can be managed within the Amazon Braket console. On the console, you have the same experience submitting quantum tasks in OpenQASM 3.0 as you had submitting existing quantum tasks.

More resources

OpenQASM is available in all Amazon Braket Regions.

For an example notebook for getting started with OpenQASM on Amazon Braket, see Braket Tutorials GitHub.