QASM Import¶
quanta.export.qasm_import ¶
quanta.export.qasm_import -- QASM 2.0/3.0 to Quanta DAG import pipeline.
Parses OpenQASM files and converts them to Quanta's internal DAG representation. Essential for QASMBench integration and Benchpress.
Supports
- QASM 2.0 (qelib1.inc gates) and QASM 3.0 (stdgates.inc)
- Standard gates: h, x, y, z, s, t, cx, cz, swap, ccx, rx, ry, rz
- Qubit/bit register declarations
- Parametric gates with float params
- Measurement statements
Example
from quanta.export.qasm_import import from_qasm dag = from_qasm(''' ... OPENQASM 2.0; ... include "qelib1.inc"; ... qreg q[2]; ... creg c[2]; ... h q[0]; ... cx q[0],q[1]; ... measure q -> c; ... ''') print(dag.gate_count()) 2
from_qasm ¶
Parses QASM 2.0/3.0 string and returns a Quanta DAGCircuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qasm_str
|
str
|
OpenQASM string (2.0 or 3.0). |
required |
Returns:
| Type | Description |
|---|---|
DAGCircuit
|
DAGCircuit ready for simulation or compilation. |
Source code in quanta/export/qasm_import.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |