Skip to content

Commit 642431b

Browse files
committed
Continue
1 parent 5e230bf commit 642431b

File tree

8 files changed

+243
-13
lines changed

8 files changed

+243
-13
lines changed

qiskit_ibm_runtime/fake_provider/backends/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,4 @@
7474
from .valencia import FakeValenciaV2
7575
from .vigo import FakeVigoV2
7676
from .washington import FakeWashingtonV2
77-
from .yorktown import FakeYorktownV2
78-
79-
from .midcircuit import FakeMidcircuit
77+
from .yorktown import FakeYorktownV2

qiskit_ibm_runtime/utils/backend_converter.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,11 @@
3737

3838
from qiskit_ibm_runtime.models import BackendConfiguration, BackendProperties
3939
from qiskit_ibm_runtime.models.exceptions import BackendPropertyError
40-
from qiskit_ibm_runtime.circuit import MidCircuitMeasure
4140
from qiskit_ibm_runtime.utils.utils import is_fractional_gate
4241

4342

4443
logger = logging.getLogger(__name__)
4544

46-
# Supported additional instructions (non-standard in qiskit but implemented in qiskit-ibm-runtime).
47-
# These are grouped by categories (measure, reset...).
48-
# If a corresponding gate constructor doesn't exist in qiskit-ibm-runtime,
49-
# the category isn't supported.
50-
ADDITIONAL_INSTR_MAPPING = {"measure": MidCircuitMeasure}
51-
5245

5346
def convert_to_target( # type: ignore[no-untyped-def]
5447
configuration: BackendConfiguration,
@@ -180,9 +173,9 @@ def convert_to_target( # type: ignore[no-untyped-def]
180173
name = signature.get("name")
181174
num_qubits = signature.get("num_qubits")
182175
num_clbits = signature.get("num_clbits")
183-
num_params = signature.get("num_params")
176+
param_names = signature.get("parameters")
184177
# Add generic parameter name
185-
params = [Parameter("x_" + str(i)) for i in range(num_params)]
178+
params = [Parameter(name) for name in param_names]
186179

187180
instruction = Instruction(
188181
name=name, num_qubits=num_qubits, num_clbits=num_clbits, params=params
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This code is part of Qiskit.
2+
#
3+
# (C) Copyright IBM 2019, 2023.
4+
#
5+
# This code is licensed under the Apache License, Version 2.0. You may
6+
# obtain a copy of this license in the LICENSE.txt file in the root directory
7+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Any modifications or derivative works of this code must retain this
10+
# copyright notice, and modified files need to carry a notice indicating
11+
# that they have been altered from the originals.
12+
13+
"""Fake backends for testing"""
14+
15+
16+
from .midcircuit import FakeMidcircuit
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This code is part of Qiskit.
2+
#
3+
# (C) Copyright IBM 2019, 2023.
4+
#
5+
# This code is licensed under the Apache License, Version 2.0. You may
6+
# obtain a copy of this license in the LICENSE.txt file in the root directory
7+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Any modifications or derivative works of this code must retain this
10+
# copyright notice, and modified files need to carry a notice indicating
11+
# that they have been altered from the originals.
12+
13+
"""Mock melbourne backend"""
14+
15+
from .fake_midcircuit import FakeMidcircuit
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{"backend_name": "ibm_midcircuit",
2+
"backend_version": "0.0.0",
3+
"n_qubits": 5,
4+
"basis_gates": ["id", "rz", "sx", "x", "cx"],
5+
"gates": [
6+
{"name": "id", "parameters": [], "qasm_def": "gate id q { U(0, 0, 0) q; }", "coupling_map": [[0], [1], [2], [3], [4]]},
7+
{"name": "rz", "parameters": ["theta"], "qasm_def": "gate rz(theta) q { U(0, 0, theta) q; }", "coupling_map": [[0], [1], [2], [3], [4]]},
8+
{"name": "sx", "parameters": [], "qasm_def": "gate sx q { U(pi/2, 3*pi/2, pi/2) q; }", "coupling_map": [[0], [1], [2], [3], [4]]},
9+
{"name": "x", "parameters": [], "qasm_def": "gate x q { U(pi, 0, pi) q; }", "coupling_map": [[0], [1], [2], [3], [4]]},
10+
{"name": "cx", "parameters": [], "qasm_def": "gate cx q0, q1 { CX q0, q1; }", "coupling_map": [[0, 1], [1, 0], [1, 2], [1, 3], [2, 1], [3, 1], [3, 4], [4, 3]]}
11+
],
12+
"local": false,
13+
"simulator": false,
14+
"conditional": false,
15+
"open_pulse": false,
16+
"memory": true,
17+
"max_shots": 8192,
18+
"coupling_map": [[0, 1], [1, 0], [1, 2], [1, 3], [2, 1], [3, 1], [3, 4], [4, 3]],
19+
"dynamic_reprate_enabled": true,
20+
"supported_instructions": ["delay","reset", "measure", "id", "rz", "sx", "x", "cx", "measure_2", "reset_2", "reset_3", "alternative_rx"],
21+
"instruction_signatures": [
22+
{
23+
"name": "measure_2",
24+
"num_qubits": 1,
25+
"num_clbits": 1,
26+
"parameters": [],
27+
"return_type" : "Bool"
28+
},
29+
{
30+
"name": "reset_2",
31+
"num_qubits": 1,
32+
"num_clbits": 1,
33+
"parameters": [],
34+
"return_type" : "Bool"
35+
},
36+
{
37+
"name": "reset_3",
38+
"num_qubits": 1,
39+
"num_clbits": 0,
40+
"parameters": [],
41+
"return_type" : "None"
42+
},
43+
{
44+
"name": "alternative_rx",
45+
"num_qubits": 1,
46+
"num_clbits": 0,
47+
"parameters": ["theta"],
48+
"return_type" : "None"
49+
}
50+
],
51+
"rep_delay_range": [0.0, 500.0],
52+
"default_rep_delay": 250.0,
53+
"max_experiments": 75,
54+
"sample_name": "Giraffe",
55+
"n_registers": 1,
56+
"credits_required": true,
57+
"online_date": "2019-07-03T04:00:00+00:00",
58+
"description": "5 qubit device for FakeMidcircuit",
59+
"dt": 0.2222222222222222,
60+
"dtm": 0.2222222222222222,
61+
"allow_q_object": true,
62+
"meas_map": [[0, 1, 2, 3, 4]],
63+
"multi_meas_enabled": false,
64+
"quantum_volume": 16,
65+
"url": "None",
66+
"allow_object_storage": true}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This code is part of Qiskit.
2+
#
3+
# (C) Copyright IBM 2019, 2023.
4+
#
5+
# This code is licensed under the Apache License, Version 2.0. You may
6+
# obtain a copy of this license in the LICENSE.txt file in the root directory
7+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Any modifications or derivative works of this code must retain this
10+
# copyright notice, and modified files need to carry a notice indicating
11+
# that they have been altered from the originals.
12+
13+
"""
14+
Fake Midcircuit device (5 qubit).
15+
"""
16+
17+
import os
18+
from qiskit_ibm_runtime.fake_provider import fake_backend
19+
20+
21+
class FakeMidcircuit(fake_backend.FakeBackendV2):
22+
"""A fake 5 qubit backend.
23+
24+
.. code-block:: text
25+
26+
0 ↔ 1 ↔ 3 ↔ 4
27+
28+
2
29+
"""
30+
31+
dirname = os.path.dirname(__file__) # type: ignore
32+
conf_filename = "conf_midcircuit.json" # type: ignore
33+
props_filename = "props_midcircuit.json" # type: ignore
34+
backend_name = "fake_midcircuit" # type: ignore

0 commit comments

Comments
 (0)