Skip to content

Commit

Permalink
from qiskit.providers.fake_provider import FakeOpenPulse2Q
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Aug 7, 2024
1 parent 5f96997 commit 0236284
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 383 deletions.
7 changes: 4 additions & 3 deletions qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping, GlobalPhaseGate
from qiskit.providers import Provider
from qiskit.providers.backend import BackendV2
from qiskit.providers.models import BackendConfiguration
from qiskit.providers.options import Options
from qiskit.qobj import QasmQobj, QasmQobjConfig, QasmQobjExperiment
from qiskit.result import Result
Expand Down Expand Up @@ -212,11 +211,11 @@ def _build_basic_target(self) -> Target:
)
return target

def configuration(self) -> BackendConfiguration:
def configuration(self):
"""Return the simulator backend configuration.
Returns:
The configuration for the backend.
BackendConfiguration: The configuration for the backend.
"""
# Note: this is a custom attribute of the BasicSimulator class and
# not part of the BackendV2 interface. It has only been added for
Expand Down Expand Up @@ -244,6 +243,8 @@ def configuration(self) -> BackendConfiguration:
category=DeprecationWarning,
message=r".+qiskit\.providers\.models\.backendconfiguration\..+",
)
from qiskit.providers.models import BackendConfiguration

self._configuration = BackendConfiguration(
backend_name=self.name,
backend_version=self.backend_version,
Expand Down
133 changes: 72 additions & 61 deletions qiskit/providers/fake_provider/fake_1q.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
Fake 1Q device (1 qubit).
"""
import datetime

from qiskit.providers.models.backendproperties import BackendProperties, Gate, Nduv
import warnings

from .fake_backend import FakeBackend

Expand All @@ -29,63 +28,75 @@ def __init__(self):
"""
mock_time = datetime.datetime.now()
dt = 1.3333
configuration = BackendProperties(
backend_name="fake_1q",
backend_version="0.0.0",
num_qubits=1,
basis_gates=["u1", "u2", "u3", "cx"],
simulator=False,
local=True,
conditional=False,
memory=False,
max_shots=1024,
qubits=[
[
Nduv(date=mock_time, name="T1", unit="µs", value=71.9500421005539),
Nduv(date=mock_time, name="frequency", unit="MHz", value=4919.96800692),
]
],
gates=[
Gate(
gate="u1",
name="u1_0",
qubits=[0],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=0.0),
],
),
Gate(
gate="u3",
name="u3_0",
qubits=[0],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=2 * dt),
],
),
Gate(
gate="u3",
name="u3_1",
qubits=[1],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=4 * dt),
],
),
Gate(
gate="cx",
name="cx0_1",
qubits=[0, 1],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=22 * dt),
],
),
],
coupling_map=None,
n_registers=1,
last_update_date=mock_time,
general=[],
)

with warnings.catch_warnings():
# BackendV1 is deprecated along qiskit.providers.models
# They both need to be removed at the same time
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r"qiskit\.providers\.models.+",
module="qiskit",
)
from qiskit.providers.models.backendproperties import BackendProperties, Gate, Nduv

configuration = BackendProperties(
backend_name="fake_1q",
backend_version="0.0.0",
num_qubits=1,
basis_gates=["u1", "u2", "u3", "cx"],
simulator=False,
local=True,
conditional=False,
memory=False,
max_shots=1024,
qubits=[
[
Nduv(date=mock_time, name="T1", unit="µs", value=71.9500421005539),
Nduv(date=mock_time, name="frequency", unit="MHz", value=4919.96800692),
]
],
gates=[
Gate(
gate="u1",
name="u1_0",
qubits=[0],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=0.0),
],
),
Gate(
gate="u3",
name="u3_0",
qubits=[0],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=2 * dt),
],
),
Gate(
gate="u3",
name="u3_1",
qubits=[1],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=4 * dt),
],
),
Gate(
gate="cx",
name="cx0_1",
qubits=[0, 1],
parameters=[
Nduv(date=mock_time, name="gate_error", unit="", value=1.0),
Nduv(date=mock_time, name="gate_length", unit="ns", value=22 * dt),
],
),
],
coupling_map=None,
n_registers=1,
last_update_date=mock_time,
general=[],
)
super().__init__(configuration)
13 changes: 11 additions & 2 deletions qiskit/providers/fake_provider/fake_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import warnings

from qiskit import circuit
from qiskit.providers.models import BackendProperties
from qiskit.providers import BackendV1
from qiskit import pulse
from qiskit.exceptions import QiskitError
Expand Down Expand Up @@ -122,8 +121,18 @@ def properties(self):
],
"general": [],
}
with warnings.catch_warnings():
# BackendV1 is deprecated along qiskit.providers.models.BackendProperties
# They both need to be removed at the same time
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r"qiskit\.providers\.models.+",
module="qiskit",
)
from qiskit.providers.models import BackendProperties

return BackendProperties.from_dict(properties)
return BackendProperties.from_dict(properties)

@classmethod
def _default_options(cls):
Expand Down
Loading

0 comments on commit 0236284

Please sign in to comment.