Currently Supported Constructs
Theqbraid_qir.qasm3.qasm3_to_qir() converter supports the following OpenQASM 3 constructs:
1. Register Declarations
OpenQASM declarations of all formsqreg, qubit, bit, and creg are supported.
2. Quantum Measurements
OpenQASM measurements are supported which involve single qubit measurement and full register measurements. Range based measurements are not supported currently.3. Quantum Reset
Resets are supported on declared quantum registers in all forms.4. Quantum Gates
pyqir._nativegates are supported along with support forU3and U2 gates. TheU[x]gates are defined in terms of existingrxandrzgates according to the decomposition present on the Qiskit UGate documentation and PhaseGate documentation.- Full set of the openqasm3 “stdgates.inc” gates are supported. These gates are decomposed with the help of the
pyqir._nativegate set and subsequently converted to QIR.
5. Quantum Barriers
Barriers are supported only if they are placed on ALL the qubits in the circuit. For example:6. Custom Quantum Gates
Gates defined by users are supported as long as they are defined in terms ofpyqir._native gate set. Identifier mapping in gate parameter expressions is not supported at the moment. Example:
7. Simple Branching Statements
Since QIR supports branching on a measurement result, single bit branching statements are supported at the moment. General boolean expressions and support for branching on full registers will be added in future. For example:8. Expressions
- General expression evaluation involving literals and constants is supported.
- Expressions involving constants and variables are fully supported.
- Expressions with arrays are also supported (in global scopes).
9. Variables and Types
- Scalar types
int,uint,float,boolandbitwith arbitrary sizes are supported. arraytype is supported forint,uint,float,boolandbit.complexandangletypes are not supported yet.
10. Loops
Bothfor and while loops are supported at the moment. For example:
11. Aliasing
- Aliasing quantum registers is supported and can be used to refer to the same quantum register with different names.
- Aliases are currently supported in global scope of the qasm3 program, with support for function scopes coming soon.
12. Subroutines
We support QASM3 subroutines in the QIR converterDefinitions
Definitions
Subroutines are supported in QASM3 and can be defined using the
def keyword and are only allowed in the global scope.Calling subroutines
Calling subroutines
Subroutines can be called from within the main program or from other subroutines.
Arguments and Return Types
Arguments and Return Types
-
Quantum arguments of type
qubitare supported in subroutines. - Classical arguments are supported for any scalar type and can return values of any scalar type.
-
All argument validations mentioned in the OpenQASM3 specification are supported.
Future Work
Future Work
- Add
mutableandreadonlyarrays as classical arguments in a subroutines - Support looping statements inside a subroutine - Support switch statements inside a subroutine - Support for aliasing in a subroutine
