Skip to content

Commit 2d8e3b6

Browse files
committed
✨ enable OpenQASM 3.0 support for QMAP
1 parent 584979e commit 2d8e3b6

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

mqt-qmap/input/data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"qc": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[3];\ncreg c[3];\nh q[0];\ncx q[0],q[1];\ncx q[0],q[2];\nmeasure q -> c;\n",
2+
"qc": "OPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[3] q;\nbit[3] c;\nh q[0];\ncx q[0],q[1];\ncx q[0],q[2];\nc = measure q;\n",
33
"arch_num_qubits": 5,
44
"arch_coupling_map": "{(0, 1), (1, 0), (1, 2), (2, 1), (1, 3), (3, 1), (3, 4), (4, 3)}"
55
}

mqt-qmap/openapi-spec.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ components:
1111
properties:
1212
qc:
1313
type: string
14-
description: The input quantum circuit given as an OpenQASM 2 string
14+
description: The input quantum circuit given as an OpenQASM 2/3 string
1515
example: |
16-
OPENQASM 2.0;
17-
include "qelib1.inc";
18-
qreg q[3];
19-
creg c[3];
16+
OPENQASM 3.0;
17+
include "stdgates.inc";
18+
qubit[3] q;
19+
bit[3] c;
2020
h q[0];
2121
cx q[0],q[1];
2222
cx q[0],q[2];
23-
measure q -> c;
23+
c = measure q;
2424
arch_num_qubits:
2525
type: integer
2626
description: The number of qubits of the architecture
@@ -48,21 +48,21 @@ components:
4848
properties:
4949
qc_mapped:
5050
type: string
51-
description: The mapped quantum circuit given as an OpenQASM 2 string. Note that the resulting file also contains metadata about the input and output permutations as a comment.
51+
description: The mapped quantum circuit given as an OpenQASM 3 string. Note that the resulting file also contains metadata about the input and output permutations as a comment.
5252
example: |
5353
// i 1 2 0 3 4
5454
// o 1 2 0
55-
OPENQASM 2.0;
56-
include \"qelib1.inc\";
57-
qreg q[5];
58-
creg c[3];
55+
OPENQASM 3.0;
56+
include \"stdgates.inc\";
57+
qubit[5] q;
58+
bit[3] c;
5959
h q[1];
6060
cx q[1], q[2];
6161
cx q[1], q[0];
6262
barrier q;
63-
measure q[0] -> c[2];
64-
measure q[1] -> c[0];
65-
measure q[2] -> c[1];
63+
c[2] = measure q[0];
64+
c[0] = measure q[1];
65+
c[1] = measure q[2];
6666
metadata:
6767
type: object
6868
description: Additional information about the execution
@@ -105,7 +105,7 @@ components:
105105
"cnots": 2,
106106
"gates": 3,
107107
"name": "circuit-152_mapped",
108-
"qasm": "// i 1 2 0 3 4\n// o 1 2 0\nOPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[5];\ncreg c[3];\nh q[1];\ncx q[1], q[2];\ncx q[1], q[0];\nbarrier q;\nmeasure q[0] -> c[2];\nmeasure q[1] -> c[0];\nmeasure q[2] -> c[1];\n",
108+
"qasm": "// i 1 2 0 3 4\n// o 1 2 0\nOPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[5] q;\nbit[3] c;\nh q[1];\ncx q[1], q[2];\ncx q[1], q[0];\nbarrier q;\nc[2] = measure q[0];\nc[0] = measure q[1];\nc[1] = measure q[2];\n",
109109
"qubits": 5,
110110
"single_qubit_gates": 1
111111
},

mqt-qmap/src/program.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from loguru import logger
1010
from mqt.qmap import Architecture, compile
11-
from qiskit.qasm2 import loads
11+
from qiskit.qasm3 import loads
1212

1313
from .libs.return_objects import ErrorResponse, ResultResponse
1414

@@ -23,8 +23,8 @@ def run(data: dict[str, Any] | None = None, params: dict[str, Any] | None = None
2323
Returns:
2424
response: Response as arbitrary json-serializable dict or an error to be passed back to the client.
2525
"""
26-
qc_qasm2: str | None = data.get("qc")
27-
if qc_qasm2 is None:
26+
qc_qasm: str | None = data.get("qc")
27+
if qc_qasm is None:
2828
return ErrorResponse(code="400", detail="No input circuit provided.")
2929

3030
arch_num_qubits: int | None = data.get("arch_num_qubits")
@@ -41,7 +41,7 @@ def run(data: dict[str, Any] | None = None, params: dict[str, Any] | None = None
4141
# Configuration options for the mapper
4242
method = params.get("method", "heuristic")
4343

44-
qc = loads(qc_qasm2)
44+
qc = loads(qc_qasm)
4545

4646
logger.info("Starting execution...")
4747
start_time = time.time()

0 commit comments

Comments
 (0)