qilisdk.utils.openqasm.openqasm3
Classes
Internal class for parsing OpenQASM 3.0. |
Functions
|
Convert an OpenQASM 3.0 string representation of a quantum circuit into a Circuit object. |
|
Convert a Circuit object to its OpenQASM 3.0 string representation. |
|
Read an OpenQASM 3.0 file and create a corresponding Circuit instance. |
|
Save the OpenQASM 3.0 representation of a circuit to a file. |
Module Contents
- class OpenQasmParser[font]
Internal class for parsing OpenQASM 3.0.
- Use the external methods instead:
from qilisdk.utils.openqasm import to_qasm3_file
from qilisdk.utils.openqasm import from_qasm3_file
from qilisdk.utils.openqasm import to_qasm3
from qilisdk.utils.openqasm import from_qasm3
Understanding the following table: - ✅: The feature is fully supported - 🟡: The feature is partially supported, see the note for explanation - ❌: The feature is not supported at all
Feature Table OpenQASM 3 Feature QiliSDK Notes comments ✅ QASM vstring ✅ include ✅ unicode names ✅ qubit ✅ bit 🟡 1 bool 🟡 1 int 🟡 1 uint 🟡 1 float 🟡 1 angle 🟡 1 complex 🟡 1 const ✅ pi/π/tau/τ/euler/ℇ ✅ Aliasing: let ✅ register concatenation ❌ casting expr.Cast ✅ duration 🟡 1 durationof ❌ ns/μs/us/ms/s/dt ✅ stretch expr.Stretch 🟡 1 delay ❌ barrier ❌ box ❌ Built-in U ✅ gate 🟡 1 gphase ❌ ctrl @ ✅ negctrl @ 🟡 1 inv @ ✅ pow(k) @ 🟡 1, 2 reset ❌ measure 🟡 3 bit operations 🟡 1 boolean operations 🟡 1 arithmetic expressions 🟡 1 comparisons 🟡 1 if 🟡 1 else 🟡 1 else if 🟡 1 for loops 🟡 1 switch 🟡 1 while loops 🟡 1 continue 🟡 1 break 🟡 1 extern ❌ def subroutines 🟡 1 return 🟡 1 input 🟡 1 output ❌
Reading these operations is fully supported, but the expressions will not be stored within the circuit object, and thus will not written back out if you convert back to OpenQASM. For example, if you declare «int x = 5;», the variable «x» will be evaluated and used during the rest of the parsing, but in the circuit object itself «x» will not appear, and thus converting back to OpenQASM will not include the declaration of «x».
pow(k) is only supported in QiliSDK when k is an integer, and is done by doing repeated gate applications.
Mid-circuit measurements are not supported in QiliSDK.
- reg_name_to_start_end[font]
- var_list[font]
- custom_gate_definitions[font]
- subroutine_definitions[font]
- gates_to_add = [][font]
- nqubits = 0[font]
- from_qasm3(qasm3: str, directory: str = '') qilisdk.digital.Circuit[font]
- static to_qasm3(circuit: qilisdk.digital.Circuit) str[font]
- from_qasm3(qasm3: str, directory: str = '') qilisdk.digital.Circuit[font]
Convert an OpenQASM 3.0 string representation of a quantum circuit into a Circuit object.
- Paràmetres:
- Retorna:
The reconstructed Circuit object.
- Tipus de retorn:
- Llença:
ValueError – If the QASM string contains unsupported statements, gates, or expressions.
- to_qasm3(circuit: qilisdk.digital.Circuit) str[font]
Convert a Circuit object to its OpenQASM 3.0 string representation.
- Paràmetres:
circuit – The Circuit object to convert.
- Retorna:
The OpenQASM 3.0 representation of the circuit.
- Tipus de retorn:
str
- from_qasm3_file(filename: str) qilisdk.digital.Circuit[font]
Read an OpenQASM 3.0 file and create a corresponding Circuit instance.