qiskit/releasenotes/notes/1.0/qasm3-importer-0ba0691bcdeb...

32 lines
1.6 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
features_qasm:
- |
The :mod:`qiskit.qasm3` package now contains a built-in, Rust-based parser for reading OpenQASM
3 programs into :class:`.QuantumCircuit`\ s, found at :func:`qiskit.qasm3.load_experimental` and
:func:`~.qasm3.loads_experimental`. These are typically several times faster than the existing,
pure Python :func:`~.qasm3.load` and :func:`~.qasm3.loads` functions, which additionally require
``qiskit-qasm3-import`` to be installed.
For example, we can create a 20,000-instruction entangling :class:`.QuantumCircuit`::
import numpy as np
import qiskit.qasm3
from qiskit.circuit.library import RealAmplitudes
qc = RealAmplitudes(100, reps=100, flatten=True)
qc = qc.assign_parameters(np.random.rand(qc.num_parameters))
oq3 = qiskit.qasm3.dumps(qc)
The old :func:`.qasm3.loads` took about 7.3s to load the resulting OpenQASM 3 program, whereas
:func:`.qasm3.loads_experimental` took under 300ms on a consumer Macbook Pro (i7, 2020)a speedup
of 25x!
The supported feature set of the experimental parser is very limited in this preview version,
but this will expand as both the Qiskit side and `the native Rust-based parser
<https://github.com/Qiskit/openqasm3_parser>`__ improve.
One of our main goals with this new parser, alongside the huge speed improvements, is to provide
top-quality error diagnostics. As with other parts of the parser, these are a work in progress,
but you'll start to see much higher quality error messages displayed when parsing invalid
OpenQASM 3 programs with the experimental parser.