diff --git a/qiskit/providers/fake_provider/fake_backend.py b/qiskit/providers/fake_provider/fake_backend.py index 5bae916970f0..b5ac0bbb8b95 100644 --- a/qiskit/providers/fake_provider/fake_backend.py +++ b/qiskit/providers/fake_provider/fake_backend.py @@ -20,10 +20,10 @@ import json import os -from typing import List +from typing import List, Iterable from qiskit import circuit -from qiskit.providers.models import BackendProperties +from qiskit.providers.models import BackendProperties, PulseBackendConfiguration from qiskit.providers import BackendV2, BackendV1 from qiskit import pulse from qiskit.exceptions import QiskitError @@ -72,6 +72,8 @@ class FakeBackendV2(BackendV2): def __init__(self): """FakeBackendV2 initializer.""" self._conf_dict = self._get_conf_dict_from_json() + if self._conf_dict["open_pulse"]: + self._pulse_conf = PulseBackendConfiguration.from_dict(self._conf_dict) self._props_dict = None self._defs_dict = None super().__init__( @@ -337,6 +339,41 @@ def _get_noise_model_from_backend_v2( return noise_model + def control_channel(self, qubits: Iterable[int]): + """Return the secondary drive channel for the given qubit + + This is typically utilized for controlling multiqubit interactions. + This channel is derived from other channels. + + This is required to be implemented if the backend supports Pulse + scheduling. + + Args: + qubits: Tuple or list of qubits of the form + ``(control_qubit, target_qubit)``. + + Returns: + List[ControlChannel]: The Qubit measurement acquisition line. + + """ + return self._pulse_conf.control_channels[qubits] + + @property + def control_channels(self): + """Return the full dictionary of control channels + + This is typically utilized for controlling multiqubit interactions. + This channel is derived from other channels. + + This is required to be implemented if the backend supports Pulse + scheduling. + + Returns: + Dict[Tuple[int], ControlChannel]: The contro channels dictionary + + """ + return self._pulse_conf.control_channels + class FakeBackend(BackendV1): """This is a dummy backend just for testing purposes.""" diff --git a/qiskit/providers/models/backendconfiguration.py b/qiskit/providers/models/backendconfiguration.py index 899fe6dc0f48..c796a24ff924 100644 --- a/qiskit/providers/models/backendconfiguration.py +++ b/qiskit/providers/models/backendconfiguration.py @@ -689,7 +689,7 @@ def from_dict(cls, data): in_data = copy.copy(data) gates = [GateConfig.from_dict(x) for x in in_data.pop("gates")] in_data["gates"] = gates - input_uchannels = in_data.pop("u_channel_lo") + input_uchannels = in_data.pop("u_channel_lo", []) u_channels = [] for channel in input_uchannels: u_channels.append([UchannelLO.from_dict(x) for x in channel])