-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add importer for OpenQASM 3 This adds an interface for importing OpenQASM 3 into Qiskit Terra. Right now, this is provided only as an optional dependency (the `qasm3-import` optional), using the package `qiskit_qasm3_import`, which in turn depends on the ANTLR runtime `antlr4-python3-runtime`. The importer code may in the future be vendored into Terra, and will likely be replaced completely by a more efficient importer in the future, once a more concrete strategy has been decided for handling of classical components in quantum programs. * Expand capabilities section of release note * Expand OQ3 import documentation * Relax exact pin in optional requirement * Remove superfluous word * Update link to Qiskit org Co-authored-by: Matthew Treinish <[email protected]>
- Loading branch information
1 parent
179c29c
commit b2311c4
Showing
7 changed files
with
306 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
features: | ||
- | | ||
Support for importing OpenQASM 3 programs into Qiskit has been added. This can most easily be | ||
accessed using the functions :func:`.qasm3.loads` and :func:`.qasm3.load`, to load a program | ||
directly from a string and indirectly from a filename, respectively. For example, one can now | ||
do:: | ||
from qiskit import qasm3 | ||
circuit = qasm3.loads(""" | ||
OPENQASM 3.0; | ||
include "stdgates.inc"; | ||
qubit q; | ||
qubit[5] qr; | ||
bit c; | ||
bit[5] cr; | ||
h q; | ||
c = measure q; | ||
if (c) { | ||
h qr[0]; | ||
cx qr[0], qr[1]; | ||
cx qr[0], qr[2]; | ||
cx qr[0], qr[3]; | ||
cx qr[0], qr[4]; | ||
} else { | ||
h qr[4]; | ||
cx qr[4], qr[3]; | ||
cx qr[4], qr[2]; | ||
cx qr[4], qr[1]; | ||
cx qr[4], qr[0]; | ||
} | ||
cr = measure qr; | ||
""") | ||
This will load the program into a :class:`.QuantumCircuit` instance in the variable ``circuit``. | ||
Not all OpenQASM 3 features are supported at first, because Qiskit does not yet have a way to | ||
represent advanced classical data processing. The capabilities of the importer will increase | ||
along with the capabilities of the rest of Qiskit. The initial feature set of the importer is | ||
approximately the same set of features that would be output by the exporter (:func:`.qasm3.dump` | ||
and :func:`.qasm3.dumps`). | ||
Note that Qiskit's support of OpenQASM 3 is not meant to provide a totally lossless | ||
representation of :class:`.QuantumCircuit`\ s. For that, consider using :mod:`qiskit.qpy`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.