Пример #1
0
    def defaults(self, refresh: bool = False) -> Optional[PulseDefaults]:
        """Return the pulse defaults for the backend.

        The schema for default pulse configuration can be found in
        `Qiskit/ibm-quantum-schemas
        <https://github.com/Qiskit/ibm-quantum-schemas/blob/main/schemas/default_pulse_configuration_schema.json>`_.

        Args:
            refresh: If ``True``, re-query the server for the backend pulse defaults.
                Otherwise, return a cached version.

        Returns:
            The backend pulse defaults or ``None`` if the backend does not support pulse.
        """
        if not self.configuration().open_pulse:
            return None

        if refresh or self._defaults is None:
            api_defaults = self._api_client.backend_pulse_defaults(self.name())
            if api_defaults:
                decode_pulse_defaults(api_defaults)
                self._defaults = PulseDefaults.from_dict(api_defaults)
            else:
                self._defaults = None

        return self._defaults
Пример #2
0
 def defaults(self):
     """Returns a snapshot of device defaults as recorded on 10/21/19.
     """
     dirname = os.path.dirname(__file__)
     filename = "defs_burlington.json"
     with open(os.path.join(dirname, filename), "r") as f_defs:
         defs = json.load(f_defs)
     return PulseDefaults.from_dict(defs)
Пример #3
0
 def defaults(self):
     """Returns a snapshot of device defaults"""
     if not self._defaults:
         dirname = os.path.dirname(__file__)
         filename = "defs_montreal.json"
         with open(os.path.join(dirname, filename), "r") as f_defs:
             defs = json.load(f_defs)
         self._defaults = PulseDefaults.from_dict(defs)
     return self._defaults
Пример #4
0
 def defaults(self):
     """Returns a snapshot of device defaults as recorded on 11/15/19.
     """
     if not self._defaults:
         dirname = os.path.dirname(__file__)
         filename = "defs_almaden.json"
         with open(os.path.join(dirname, filename), "r") as f_defs:
             defs = json.load(f_defs)
         self._defaults = PulseDefaults.from_dict(defs)
     return self._defaults
Пример #5
0
    def defaults(self):
        """Return the pulse defaults for the backend.

        Returns:
            PulseDefaults: the pulse defaults for the backend. IF the backend
            does not support defaults, it returns ``None``.
        """
        backend_defaults = self._api.backend_defaults(self.name())

        if backend_defaults:
            return PulseDefaults.from_dict(backend_defaults)

        return None
Пример #6
0
def defaults_from_server_data(defaults: Dict) -> PulseDefaults:
    """Decode pulse defaults data.

    Args:
        defaults: Raw pulse defaults data.

    Returns:
        A ``PulseDefaults`` instance.
    """
    for item in defaults["pulse_library"]:
        _decode_pulse_library_item(item)

    for cmd in defaults["cmd_def"]:
        if "sequence" in cmd:
            for instr in cmd["sequence"]:
                _decode_pulse_qobj_instr(instr)

    return PulseDefaults.from_dict(defaults)
Пример #7
0
    def defaults(self, refresh: bool = False) -> Optional[PulseDefaults]:
        """Return the pulse defaults for the backend.

        Args:
            refresh: If ``True``, re-query the server for the backend pulse defaults.
                Otherwise, return a cached version.

        Returns:
            The backend pulse defaults or ``None`` if the backend does not support pulse.
        """
        if not self.configuration().open_pulse:
            return None

        if refresh or self._defaults is None:
            api_defaults = self._api.backend_pulse_defaults(self.name())
            if api_defaults:
                self._defaults = PulseDefaults.from_dict(api_defaults)
            else:
                self._defaults = None

        return self._defaults
Пример #8
0
    def defaults(self, refresh: bool = False) -> Optional[PulseDefaults]:
        """Return the pulse defaults for the backend.

        Args:
            refresh: if True, the return is via a QX API call.
                Otherwise, a cached version is returned.

        Returns:
            the pulse defaults for the backend. If the backend does not support
            defaults, it returns ``None``.
        """
        if not self.configuration().open_pulse:
            return None

        if refresh or self._defaults is None:
            api_defaults = self._api.backend_pulse_defaults(self.name())
            if api_defaults:
                self._defaults = PulseDefaults.from_dict(api_defaults)
            else:
                self._defaults = None

        return self._defaults
Пример #9
0
    def __init__(self):
        configuration = PulseBackendConfiguration(
            backend_name='fake_openpulse_2q',
            backend_version='0.0.0',
            n_qubits=2,
            meas_levels=[0, 1, 2],
            basis_gates=['u1', 'u2', 'u3', 'cx', 'id'],
            simulator=False,
            local=True,
            conditional=True,
            open_pulse=True,
            memory=False,
            max_shots=65536,
            gates=[GateConfig(name='TODO', parameters=[], qasm_def='TODO')],
            coupling_map=[[0, 1]],
            n_registers=2,
            n_uchannels=2,
            u_channel_lo=[
                [UchannelLO(q=0, scale=1. + 0.j)],
                [UchannelLO(q=0, scale=-1. + 0.j), UchannelLO(q=1, scale=1. + 0.j)]
            ],
            qubit_lo_range=[[4.5, 5.5], [4.5, 5.5]],
            meas_lo_range=[[6.0, 7.0], [6.0, 7.0]],
            dt=1.3333,
            dtm=10.5,
            rep_times=[100, 250, 500, 1000],
            meas_map=[[0, 1]],
            channel_bandwidth=[
                [-0.2, 0.4], [-0.3, 0.3], [-0.3, 0.3],
                [-0.02, 0.02], [-0.02, 0.02], [-0.02, 0.02]
            ],
            meas_kernels=['kernel1'],
            discriminators=['max_1Q_fidelity'],
            acquisition_latency=[[100, 100], [100, 100]],
            conditional_latency=[
                [100, 1000], [1000, 100], [100, 1000],
                [1000, 100], [100, 1000], [1000, 100]
            ],
            hamiltonian={
                'h_str': ["np.pi*(2*v0-alpha0)*O0", "np.pi*alpha0*O0*O0", "2*np.pi*r*X0||D0",
                          "2*np.pi*r*X0||U1", "2*np.pi*r*X1||U0", "np.pi*(2*v1-alpha1)*O1",
                          "np.pi*alpha1*O1*O1", "2*np.pi*r*X1||D1", "2*np.pi*j*(Sp0*Sm1+Sm0*Sp1)"],
                'description': "A hamiltonian for a mocked 2Q device, with 1Q and 2Q terms.",
                'qub': {'0': 3, '1': 3},
                'vars':  {'v0': 5.00,
                          'v1': 5.1,
                          'j': 0.01,
                          'r': 0.02,
                          'alpha0': -0.33,
                          'alpha1': -0.33}
            },
            channels={
                'acquire0': {
                    'operates': {'qubits': [0]},
                    'purpose': 'acquire',
                    'type': 'acquire'
                },
                'acquire1': {
                    'operates': {'qubits': [1]},
                    'purpose': 'acquire',
                    'type': 'acquire'
                },
                'd0': {
                    'operates': {'qubits': [0]},
                    'purpose': 'drive',
                    'type': 'drive'
                },
                'd1': {
                    'operates': {'qubits': [1]},
                    'purpose': 'drive',
                    'type': 'drive'
                },
                'm0': {
                    'type': 'measure',
                    'purpose': 'measure',
                    'operates': {'qubits': [0]}
                },
                'm1': {
                    'type': 'measure',
                    'purpose': 'measure',
                    'operates': {'qubits': [1]}
                },
                'u0': {
                    'operates': {'qubits': [0, 1]},
                    'purpose': 'cross-resonance',
                    'type': 'control'
                },
                'u1': {
                    'operates': {'qubits': [1, 0]},
                    'purpose': 'cross-resonance',
                    'type': 'control'
                }
            }
        )

        self._defaults = PulseDefaults.from_dict({
            'qubit_freq_est': [4.9, 5.0],
            'meas_freq_est': [6.5, 6.6],
            'buffer': 10,
            'pulse_library': [
                {
                    'name': 'test_pulse_1',
                    'samples': [[0.0, 0.0], [0.0, 0.1]]
                },
                {
                    'name': 'test_pulse_2',
                    'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0]]
                },
                {
                    'name': 'test_pulse_3',
                    'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]]
                },
                {
                    'name': 'test_pulse_4',
                    'samples': 7 * [
                        [0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]
                    ]
                }
            ],
            'cmd_def': [
                Command.from_dict({
                    'name': 'u1',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='fc', ch='d0',
                                             t0=0, phase='-P0').to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'u1',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='fc', ch='d1',
                                             t0=0, phase='-P0').to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'u2',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='fc', ch='d0',
                                             t0=0,
                                             phase='-P1').to_dict(),
                        PulseQobjInstruction(name='test_pulse_4', ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='fc', ch='d0', t0=0,
                                             phase='-P0').to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'u2',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='fc', ch='d1', t0=0,
                                             phase='-P1').to_dict(),
                        PulseQobjInstruction(name='test_pulse_4',
                                             ch='d1', t0=0).to_dict(),
                        PulseQobjInstruction(name='fc', ch='d1',
                                             t0=0, phase='-P0').to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'u3',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1', ch='d0',
                                             t0=0).to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'u3',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_3', ch='d1',
                                             t0=0).to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'cx',
                    'qubits': [0, 1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1', ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2', ch='u0',
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1', ch='d1',
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc', ch='d1',
                                             t0=20, phase=2.1).to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'ParametrizedGate',
                    'qubits': [0, 1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1', ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2', ch='u0',
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='pv', ch='d1',
                                             t0=2, val='cos(P2)').to_dict(),
                        PulseQobjInstruction(name='test_pulse_1', ch='d1',
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc', ch='d1',
                                             t0=20, phase=2.1).to_dict()
                    ]}).to_dict(),
                Command.from_dict({
                    'name': 'measure',
                    'qubits': [0, 1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1', ch='m0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1', ch='m1',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='acquire', duration=10, t0=0,
                                             qubits=[0, 1],
                                             memory_slot=[0, 1]).to_dict()
                    ]}).to_dict()
            ]
        })

        mock_time = datetime.datetime.now()
        dt = 1.3333  # pylint: disable=invalid-name
        self._properties = BackendProperties(
            backend_name='fake_openpulse_2q',
            backend_version='0.0.0',
            last_update_date=mock_time,
            qubits=[
                [Nduv(date=mock_time, name='T1', unit='µs', value=71.9500421005539),
                 Nduv(date=mock_time, name='frequency', unit='MHz', value=4919.96800692)],
                [Nduv(date=mock_time, name='T1', unit='µs', value=81.9500421005539),
                 Nduv(date=mock_time, name='frequency', unit='GHz', value=5.01996800692)]
            ],
            gates=[
                Gate(gate='u1', qubits=[0],
                     parameters=[
                         Nduv(date=mock_time, name='gate_error', unit='', value=0.06),
                         Nduv(date=mock_time, name='gate_length', unit='ns', value=0.)]),
                Gate(gate='u3', qubits=[0],
                     parameters=[
                         Nduv(date=mock_time, name='gate_error', unit='', value=0.06),
                         Nduv(date=mock_time, name='gate_length', unit='ns', value=2 * dt)]),
                Gate(gate='u3', qubits=[1],
                     parameters=[
                         Nduv(date=mock_time, name='gate_error', unit='', value=0.06),
                         Nduv(date=mock_time, name='gate_length', unit='ns', value=4 * dt)]),
                Gate(gate='cx', 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)]),
            ],
            general=[]
        )

        super().__init__(configuration)
Пример #10
0
    def __init__(self):
        configuration = PulseBackendConfiguration(
            backend_name='fake_openpulse_3q',
            backend_version='0.0.0',
            n_qubits=3,
            meas_levels=[0, 1, 2],
            basis_gates=['u1', 'u2', 'u3', 'cx', 'id'],
            simulator=False,
            local=True,
            conditional=True,
            open_pulse=True,
            memory=False,
            max_shots=65536,
            gates=[GateConfig(name='TODO', parameters=[], qasm_def='TODO')],
            coupling_map=[[0, 1], [1, 2]],
            n_registers=3,
            n_uchannels=3,
            u_channel_lo=[
                [UchannelLO(q=0, scale=1. + 0.j)],
                [UchannelLO(q=0, scale=-1. + 0.j), UchannelLO(q=1, scale=1. + 0.j)],
                [UchannelLO(q=0, scale=1. + 0.j)]
            ],
            qubit_lo_range=[[4.5, 5.5], [4.5, 5.5], [4.5, 5.5]],
            meas_lo_range=[[6.0, 7.0], [6.0, 7.0], [6.0, 7.0]],
            dt=1.3333,
            dtm=10.5,
            rep_times=[100, 250, 500, 1000],
            meas_map=[[0, 1, 2]],
            channel_bandwidth=[
                [-0.2, 0.4], [-0.3, 0.3], [-0.3, 0.3],
                [-0.02, 0.02], [-0.02, 0.02], [-0.02, 0.02],
                [-0.2, 0.4], [-0.3, 0.3], [-0.3, 0.3]
            ],
            meas_kernels=['kernel1'],
            discriminators=['max_1Q_fidelity'],
            acquisition_latency=[[100, 100], [100, 100], [100, 100]],
            conditional_latency=[
                [100, 1000], [1000, 100], [100, 1000],
                [100, 1000], [1000, 100], [100, 1000],
                [1000, 100], [100, 1000], [1000, 100]
            ],
            channels={
                'acquire0': {
                    'type': 'acquire',
                    'purpose': 'acquire',
                    'operates': {'qubits': [0]}
                },
                'acquire1': {
                    'type': 'acquire',
                    'purpose': 'acquire',
                    'operates': {'qubits': [1]}
                },
                'acquire2': {
                    'type': 'acquire',
                    'purpose': 'acquire',
                    'operates': {'qubits': [2]}
                },
                'd0': {
                    'type': 'drive',
                    'purpose': 'drive',
                    'operates': {'qubits': [0]}
                },
                'd1': {
                    'type': 'drive',
                    'purpose': 'drive',
                    'operates': {'qubits': [1]}
                },
                'd2': {
                    'type': 'drive',
                    'purpose': 'drive',
                    'operates': {'qubits': [2]}
                },
                'm0': {
                    'type': 'measure',
                    'purpose': 'measure',
                    'operates': {'qubits': [0]}
                },
                'm1': {
                    'type': 'measure',
                    'purpose': 'measure',
                    'operates': {'qubits': [1]}
                },
                'm2': {
                    'type': 'measure',
                    'purpose': 'measure',
                    'operates': {'qubits': [2]}
                },
                'u0': {
                    'type': 'control',
                    'purpose': 'cross-resonance',
                    'operates': {'qubits': [0, 1]}
                },
                'u1': {
                    'type': 'control',
                    'purpose': 'cross-resonance',
                    'operates': {'qubits': [1, 0]}
                },
                'u2': {
                    'type': 'control',
                    'purpose': 'cross-resonance',
                    'operates': {'qubits': [2, 1]}
                }
            }
        )

        self._defaults = PulseDefaults.from_dict({
            'qubit_freq_est': [4.9, 5.0, 4.8],
            'meas_freq_est': [6.5, 6.6, 6.4],
            'buffer': 10,
            'pulse_library': [
                {
                    'name': 'test_pulse_1',
                    'samples': [[0.0, 0.0], [0.0, 0.1]]
                },
                {
                    'name': 'test_pulse_2',
                    'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0]]
                },
                {
                    'name': 'test_pulse_3',
                    'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]]
                },
                {
                    'name': 'test_pulse_4',
                    'samples': 7 * [
                        [0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]
                    ]
                }
            ],

            'cmd_def': [
                Command.from_dict({
                    'name': 'u1',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='fc',
                                             ch='d0',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u1',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='fc',
                                             ch='d1',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u1',
                    'qubits': [2],
                    'sequence': [
                        PulseQobjInstruction(name='fc',
                                             ch='d2',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u2',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='fc',
                                             ch='d0',
                                             t0=0,
                                             phase='-P1').to_dict(),
                        PulseQobjInstruction(name='test_pulse_4',
                                             ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d0',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u2',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='fc',
                                             ch='d1',
                                             t0=0,
                                             phase='-P1').to_dict(),
                        PulseQobjInstruction(name='test_pulse_4',
                                             ch='d1',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d1',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u2',
                    'qubits': [2],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_3',
                                             ch='d2',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d2',
                                             t0=0,
                                             phase='-P0').to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u3',
                    'qubits': [0],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d0',
                                             t0=0).to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'u3',
                    'qubits': [1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_3',
                                             ch='d1',
                                             t0=0).to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'cx',
                    'qubits': [0, 1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2',
                                             ch='u0',
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d1',
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d1',
                                             t0=20,
                                             phase=2.1).to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'cx',
                    'qubits': [1, 2],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d1',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2',
                                             ch='u1',
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d2',
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d2',
                                             t0=20,
                                             phase=2.1).to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'ParametrizedGate',
                    'qubits': [0, 1],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2',
                                             ch='u0',
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='pv',
                                             ch='d1',
                                             t0=2,
                                             val='cos(P2)').to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d1',
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d1',
                                             t0=20,
                                             phase=2.1).to_dict()]}).to_dict(),
                Command.from_dict({
                    'name': 'measure',
                    'qubits': [0, 1, 2],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='m0',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='m1',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='m2',
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='acquire',
                                             duration=10,
                                             t0=0,
                                             qubits=[0, 1, 2],
                                             memory_slot=[0, 1, 2]).to_dict()]
                }).to_dict()
            ]
        })
        super().__init__(configuration)
Пример #11
0
    def _build_defaults(self) -> PulseDefaults:
        """Build backend defaults."""

        qubit_freq_est = self.qubit_frequency
        meas_freq_est = np.linspace(6.4, 6.6, self.n_qubits).tolist()
        pulse_library = [{
            'name': 'test_pulse_1',
            'samples': [[0.0, 0.0], [0.0, 0.1]]
        }, {
            'name': 'test_pulse_2',
            'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0]]
        }, {
            'name':
            'test_pulse_3',
            'samples': [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]]
        }, {
            'name':
            'test_pulse_4',
            'samples':
            7 * [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]]
        }]

        measure_command_sequence = [
            PulseQobjInstruction(name='acquire',
                                 duration=10,
                                 t0=0,
                                 qubits=list(range(self.n_qubits)),
                                 memory_slot=list(range(
                                     self.n_qubits))).to_dict()
        ]
        measure_command_sequence += [
            PulseQobjInstruction(name='test_pulse_1', ch='m{}'.format(i),
                                 t0=0).to_dict() for i in range(self.n_qubits)
        ]

        measure_command = Command.from_dict({
            'name':
            'measure',
            'qubits':
            list(range(self.n_qubits)),
            'sequence':
            measure_command_sequence
        }).to_dict()

        cmd_def = [measure_command]

        for gate in self.single_qubit_gates:
            for i in range(self.n_qubits):
                cmd_def.append(
                    Command.from_dict({
                        'name':
                        gate,
                        'qubits': [i],
                        'sequence': [
                            PulseQobjInstruction(name='fc',
                                                 ch='d{}'.format(i),
                                                 t0=0,
                                                 phase='-P0').to_dict(),
                            PulseQobjInstruction(name='test_pulse_3',
                                                 ch='d{}'.format(i),
                                                 t0=0).to_dict()
                        ]
                    }).to_dict())

        for qubit1, qubit2 in self.coupling_map:
            cmd_def += [
                Command.from_dict({
                    'name':
                    'cx',
                    'qubits': [qubit1, qubit2],
                    'sequence': [
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d{}'.format(qubit1),
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name='test_pulse_2',
                                             ch='u{}'.format(qubit1),
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name='test_pulse_1',
                                             ch='d{}'.format(qubit2),
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name='fc',
                                             ch='d{}'.format(qubit2),
                                             t0=20,
                                             phase=2.1).to_dict()
                    ]
                }).to_dict()
            ]

        return PulseDefaults.from_dict({
            'qubit_freq_est': qubit_freq_est,
            'meas_freq_est': meas_freq_est,
            'buffer': 0,
            'pulse_library': pulse_library,
            'cmd_def': cmd_def
        })
    def _build_defaults(self) -> PulseDefaults:
        """Build backend defaults."""

        qubit_freq_est = self.qubit_frequency
        meas_freq_est = np.linspace(6.4, 6.6, self.n_qubits).tolist()
        pulse_library = [
            {
                "name": "test_pulse_1",
                "samples": [[0.0, 0.0], [0.0, 0.1]]
            },
            {
                "name": "test_pulse_2",
                "samples": [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0]]
            },
            {
                "name": "test_pulse_3",
                "samples": [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]]
            },
            {
                "name": "test_pulse_4",
                "samples":
                7 * [[0.0, 0.0], [0.0, 0.1], [0.0, 1.0], [0.5, 0.0]],
            },
        ]

        measure_command_sequence = [
            PulseQobjInstruction(
                name="acquire",
                duration=10,
                t0=0,
                qubits=list(range(self.n_qubits)),
                memory_slot=list(range(self.n_qubits)),
            ).to_dict()
        ]
        measure_command_sequence += [
            PulseQobjInstruction(name="test_pulse_1", ch=f"m{i}",
                                 t0=0).to_dict() for i in range(self.n_qubits)
        ]

        measure_command = Command.from_dict({
            "name":
            "measure",
            "qubits":
            list(range(self.n_qubits)),
            "sequence":
            measure_command_sequence,
        }).to_dict()

        cmd_def = [measure_command]

        for gate in self.single_qubit_gates:
            for i in range(self.n_qubits):
                cmd_def.append(
                    Command.from_dict({
                        "name":
                        gate,
                        "qubits": [i],
                        "sequence": [
                            PulseQobjInstruction(name="fc",
                                                 ch=f"d{i}",
                                                 t0=0,
                                                 phase="-P0").to_dict(),
                            PulseQobjInstruction(name="test_pulse_3",
                                                 ch=f"d{i}",
                                                 t0=0).to_dict(),
                        ],
                    }).to_dict())

        for qubit1, qubit2 in self.coupling_map:
            cmd_def += [
                Command.from_dict({
                    "name":
                    "cx",
                    "qubits": [qubit1, qubit2],
                    "sequence": [
                        PulseQobjInstruction(name="test_pulse_1",
                                             ch=f"d{qubit1}",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="test_pulse_2",
                                             ch=f"u{qubit1}",
                                             t0=10).to_dict(),
                        PulseQobjInstruction(name="test_pulse_1",
                                             ch=f"d{qubit2}",
                                             t0=20).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch=f"d{qubit2}",
                                             t0=20,
                                             phase=2.1).to_dict(),
                    ],
                }).to_dict()
            ]

        return PulseDefaults.from_dict({
            "qubit_freq_est": qubit_freq_est,
            "meas_freq_est": meas_freq_est,
            "buffer": 0,
            "pulse_library": pulse_library,
            "cmd_def": cmd_def,
        })
    def __init__(self):
        configuration = PulseBackendConfiguration(
            backend_name="fake_openpulse_3q",
            backend_version="0.0.0",
            n_qubits=3,
            meas_levels=[0, 1, 2],
            basis_gates=["u1", "u2", "u3", "cx", "id"],
            simulator=False,
            local=True,
            conditional=True,
            open_pulse=True,
            memory=False,
            max_shots=65536,
            gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")],
            coupling_map=[[0, 1], [1, 2]],
            n_registers=3,
            n_uchannels=3,
            u_channel_lo=[
                [UchannelLO(q=0, scale=1.0 + 0.0j)],
                [
                    UchannelLO(q=0, scale=-1.0 + 0.0j),
                    UchannelLO(q=1, scale=1.0 + 0.0j)
                ],
                [UchannelLO(q=0, scale=1.0 + 0.0j)],
            ],
            qubit_lo_range=[[4.5, 5.5], [4.5, 5.5], [4.5, 5.5]],
            meas_lo_range=[[6.0, 7.0], [6.0, 7.0], [6.0, 7.0]],
            dt=1.3333,
            dtm=10.5,
            rep_times=[100, 250, 500, 1000],
            meas_map=[[0, 1, 2]],
            channel_bandwidth=[
                [-0.2, 0.4],
                [-0.3, 0.3],
                [-0.3, 0.3],
                [-0.02, 0.02],
                [-0.02, 0.02],
                [-0.02, 0.02],
                [-0.2, 0.4],
                [-0.3, 0.3],
                [-0.3, 0.3],
            ],
            meas_kernels=["kernel1"],
            discriminators=["max_1Q_fidelity"],
            acquisition_latency=[[100, 100], [100, 100], [100, 100]],
            conditional_latency=[
                [100, 1000],
                [1000, 100],
                [100, 1000],
                [100, 1000],
                [1000, 100],
                [100, 1000],
                [1000, 100],
                [100, 1000],
                [1000, 100],
            ],
            channels={
                "acquire0": {
                    "type": "acquire",
                    "purpose": "acquire",
                    "operates": {
                        "qubits": [0]
                    }
                },
                "acquire1": {
                    "type": "acquire",
                    "purpose": "acquire",
                    "operates": {
                        "qubits": [1]
                    }
                },
                "acquire2": {
                    "type": "acquire",
                    "purpose": "acquire",
                    "operates": {
                        "qubits": [2]
                    }
                },
                "d0": {
                    "type": "drive",
                    "purpose": "drive",
                    "operates": {
                        "qubits": [0]
                    }
                },
                "d1": {
                    "type": "drive",
                    "purpose": "drive",
                    "operates": {
                        "qubits": [1]
                    }
                },
                "d2": {
                    "type": "drive",
                    "purpose": "drive",
                    "operates": {
                        "qubits": [2]
                    }
                },
                "m0": {
                    "type": "measure",
                    "purpose": "measure",
                    "operates": {
                        "qubits": [0]
                    }
                },
                "m1": {
                    "type": "measure",
                    "purpose": "measure",
                    "operates": {
                        "qubits": [1]
                    }
                },
                "m2": {
                    "type": "measure",
                    "purpose": "measure",
                    "operates": {
                        "qubits": [2]
                    }
                },
                "u0": {
                    "type": "control",
                    "purpose": "cross-resonance",
                    "operates": {
                        "qubits": [0, 1]
                    },
                },
                "u1": {
                    "type": "control",
                    "purpose": "cross-resonance",
                    "operates": {
                        "qubits": [1, 0]
                    },
                },
                "u2": {
                    "type": "control",
                    "purpose": "cross-resonance",
                    "operates": {
                        "qubits": [2, 1]
                    },
                },
            },
        )

        self._defaults = PulseDefaults.from_dict({
            "qubit_freq_est": [4.9, 5.0, 4.8],
            "meas_freq_est": [6.5, 6.6, 6.4],
            "buffer":
            10,
            "pulse_library": [
                {
                    "name": "x90p_d0",
                    "samples": 2 * [0.1 + 0j]
                },
                {
                    "name": "x90p_d1",
                    "samples": 2 * [0.1 + 0j]
                },
                {
                    "name": "x90p_d2",
                    "samples": 2 * [0.1 + 0j]
                },
                {
                    "name": "x90m_d0",
                    "samples": 2 * [-0.1 + 0j]
                },
                {
                    "name": "x90m_d1",
                    "samples": 2 * [-0.1 + 0j]
                },
                {
                    "name": "x90m_d2",
                    "samples": 2 * [-0.1 + 0j]
                },
                {
                    "name": "y90p_d0",
                    "samples": 2 * [0.1j]
                },
                {
                    "name": "y90p_d1",
                    "samples": 2 * [0.1j]
                },
                {
                    "name": "y90p_d2",
                    "samples": 2 * [0.1j]
                },
                {
                    "name": "xp_d0",
                    "samples": 2 * [0.2 + 0j]
                },
                {
                    "name": "ym_d0",
                    "samples": 2 * [-0.2j]
                },
                {
                    "name": "xp_d1",
                    "samples": 2 * [0.2 + 0j]
                },
                {
                    "name": "ym_d1",
                    "samples": 2 * [-0.2j]
                },
                {
                    "name": "cr90p_u0",
                    "samples": 9 * [0.1 + 0j]
                },
                {
                    "name": "cr90m_u0",
                    "samples": 9 * [-0.1 + 0j]
                },
                {
                    "name": "cr90p_u1",
                    "samples": 9 * [0.1 + 0j]
                },
                {
                    "name": "cr90m_u1",
                    "samples": 9 * [-0.1 + 0j]
                },
                {
                    "name": "measure_m0",
                    "samples": 10 * [0.1 + 0j]
                },
                {
                    "name": "measure_m1",
                    "samples": 10 * [0.1 + 0j]
                },
                {
                    "name": "measure_m2",
                    "samples": 10 * [0.1 + 0j]
                },
            ],
            "cmd_def": [
                Command.from_dict({
                    "name":
                    "u1",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P0").to_dict()
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u1",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P0").to_dict()
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u1",
                    "qubits": [2],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=0,
                                             phase="-P0").to_dict()
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u2",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P1").to_dict(),
                        PulseQobjInstruction(name="y90p_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=2,
                                             phase="-P0").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u2",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P1").to_dict(),
                        PulseQobjInstruction(name="y90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=2,
                                             phase="-P0").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u2",
                    "qubits": [2],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=0,
                                             phase="-P1").to_dict(),
                        PulseQobjInstruction(name="y90p_d2", ch="d2",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=2,
                                             phase="-P0").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u3",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P2").to_dict(),
                        PulseQobjInstruction(name="x90p_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=2,
                                             phase="-P0").to_dict(),
                        PulseQobjInstruction(name="x90m_d0", ch="d0",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=4,
                                             phase="-P1").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u3",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P2").to_dict(),
                        PulseQobjInstruction(name="x90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=2,
                                             phase="-P0").to_dict(),
                        PulseQobjInstruction(name="x90m_d1", ch="d1",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=4,
                                             phase="-P1").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u3",
                    "qubits": [2],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=0,
                                             phase="-P2").to_dict(),
                        PulseQobjInstruction(name="x90p_d2", ch="d2",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=2,
                                             phase="-P0").to_dict(),
                        PulseQobjInstruction(name="x90m_d2", ch="d2",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d2",
                                             t0=4,
                                             phase="-P1").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "cx",
                    "qubits": [0, 1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase=1.57).to_dict(),
                        PulseQobjInstruction(name="ym_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="xp_d0", ch="d0",
                                             t0=11).to_dict(),
                        PulseQobjInstruction(name="x90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="cr90p_u0", ch="u0",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="cr90m_u0", ch="u0",
                                             t0=13).to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "cx",
                    "qubits": [1, 2],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase=1.57).to_dict(),
                        PulseQobjInstruction(name="ym_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="xp_d1", ch="d1",
                                             t0=11).to_dict(),
                        PulseQobjInstruction(name="x90p_d2", ch="d2",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="cr90p_u1", ch="u1",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="cr90m_u1", ch="u1",
                                             t0=13).to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "measure",
                    "qubits": [0, 1, 2],
                    "sequence": [
                        PulseQobjInstruction(name="measure_m0", ch="m0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="measure_m1", ch="m1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="measure_m2", ch="m2",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(
                            name="acquire",
                            duration=10,
                            t0=0,
                            qubits=[0, 1, 2],
                            memory_slot=[0, 1, 2],
                        ).to_dict(),
                    ],
                }).to_dict(),
            ],
        })
        super().__init__(configuration)
Пример #14
0
    def __init__(self):
        configuration = PulseBackendConfiguration(
            backend_name="fake_openpulse_2q",
            backend_version="0.0.0",
            n_qubits=2,
            meas_levels=[0, 1, 2],
            basis_gates=["u1", "u2", "u3", "cx", "id"],
            simulator=False,
            local=True,
            conditional=True,
            open_pulse=True,
            memory=False,
            max_shots=65536,
            gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")],
            coupling_map=[[0, 1]],
            n_registers=2,
            n_uchannels=2,
            u_channel_lo=[
                [UchannelLO(q=0, scale=1.0 + 0.0j)],
                [
                    UchannelLO(q=0, scale=-1.0 + 0.0j),
                    UchannelLO(q=1, scale=1.0 + 0.0j)
                ],
            ],
            qubit_lo_range=[[4.5, 5.5], [4.5, 5.5]],
            meas_lo_range=[[6.0, 7.0], [6.0, 7.0]],
            dt=1.3333,
            dtm=10.5,
            rep_times=[100, 250, 500, 1000],
            meas_map=[[0, 1]],
            channel_bandwidth=[
                [-0.2, 0.4],
                [-0.3, 0.3],
                [-0.3, 0.3],
                [-0.02, 0.02],
                [-0.02, 0.02],
                [-0.02, 0.02],
            ],
            meas_kernels=["kernel1"],
            discriminators=["max_1Q_fidelity"],
            acquisition_latency=[[100, 100], [100, 100]],
            conditional_latency=[
                [100, 1000],
                [1000, 100],
                [100, 1000],
                [1000, 100],
                [100, 1000],
                [1000, 100],
            ],
            hamiltonian={
                "h_str": [
                    "np.pi*(2*v0-alpha0)*O0",
                    "np.pi*alpha0*O0*O0",
                    "2*np.pi*r*X0||D0",
                    "2*np.pi*r*X0||U1",
                    "2*np.pi*r*X1||U0",
                    "np.pi*(2*v1-alpha1)*O1",
                    "np.pi*alpha1*O1*O1",
                    "2*np.pi*r*X1||D1",
                    "2*np.pi*j*(Sp0*Sm1+Sm0*Sp1)",
                ],
                "description":
                "A hamiltonian for a mocked 2Q device, with 1Q and 2Q terms.",
                "qub": {
                    "0": 3,
                    "1": 3
                },
                "vars": {
                    "v0": 5.00,
                    "v1": 5.1,
                    "j": 0.01,
                    "r": 0.02,
                    "alpha0": -0.33,
                    "alpha1": -0.33,
                },
            },
            channels={
                "acquire0": {
                    "operates": {
                        "qubits": [0]
                    },
                    "purpose": "acquire",
                    "type": "acquire"
                },
                "acquire1": {
                    "operates": {
                        "qubits": [1]
                    },
                    "purpose": "acquire",
                    "type": "acquire"
                },
                "d0": {
                    "operates": {
                        "qubits": [0]
                    },
                    "purpose": "drive",
                    "type": "drive"
                },
                "d1": {
                    "operates": {
                        "qubits": [1]
                    },
                    "purpose": "drive",
                    "type": "drive"
                },
                "m0": {
                    "type": "measure",
                    "purpose": "measure",
                    "operates": {
                        "qubits": [0]
                    }
                },
                "m1": {
                    "type": "measure",
                    "purpose": "measure",
                    "operates": {
                        "qubits": [1]
                    }
                },
                "u0": {
                    "operates": {
                        "qubits": [0, 1]
                    },
                    "purpose": "cross-resonance",
                    "type": "control",
                },
                "u1": {
                    "operates": {
                        "qubits": [1, 0]
                    },
                    "purpose": "cross-resonance",
                    "type": "control",
                },
            },
            processor_type={
                "family": "Canary",
                "revision": "1.0",
                "segment": "A",
            },
        )

        self._defaults = PulseDefaults.from_dict({
            "qubit_freq_est": [4.9, 5.0],
            "meas_freq_est": [6.5, 6.6],
            "buffer":
            10,
            "pulse_library": [
                {
                    "name": "x90p_d0",
                    "samples": 2 * [0.1 + 0j]
                },
                {
                    "name": "x90p_d1",
                    "samples": 2 * [0.1 + 0j]
                },
                {
                    "name": "x90m_d0",
                    "samples": 2 * [-0.1 + 0j]
                },
                {
                    "name": "x90m_d1",
                    "samples": 2 * [-0.1 + 0j]
                },
                {
                    "name": "y90p_d0",
                    "samples": 2 * [0.1j]
                },
                {
                    "name": "y90p_d1",
                    "samples": 2 * [0.1j]
                },
                {
                    "name": "xp_d0",
                    "samples": 2 * [0.2 + 0j]
                },
                {
                    "name": "ym_d0",
                    "samples": 2 * [-0.2j]
                },
                {
                    "name": "cr90p_u0",
                    "samples": 9 * [0.1 + 0j]
                },
                {
                    "name": "cr90m_u0",
                    "samples": 9 * [-0.1 + 0j]
                },
                {
                    "name": "measure_m0",
                    "samples": 10 * [0.1 + 0j]
                },
                {
                    "name": "measure_m1",
                    "samples": 10 * [0.1 + 0j]
                },
            ],
            "cmd_def": [
                Command.from_dict({
                    "name":
                    "u1",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P0").to_dict()
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u1",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P0").to_dict()
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u2",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P1").to_dict(),
                        PulseQobjInstruction(name="y90p_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=2,
                                             phase="-P0").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u2",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P1").to_dict(),
                        PulseQobjInstruction(name="y90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=2,
                                             phase="-P0").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u3",
                    "qubits": [0],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase="-P2").to_dict(),
                        PulseQobjInstruction(name="x90p_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=2,
                                             phase="-P0").to_dict(),
                        PulseQobjInstruction(name="x90m_d0", ch="d0",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=4,
                                             phase="-P1").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "u3",
                    "qubits": [1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=0,
                                             phase="-P2").to_dict(),
                        PulseQobjInstruction(name="x90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=2,
                                             phase="-P0").to_dict(),
                        PulseQobjInstruction(name="x90m_d1", ch="d1",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="fc",
                                             ch="d1",
                                             t0=4,
                                             phase="-P1").to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "cx",
                    "qubits": [0, 1],
                    "sequence": [
                        PulseQobjInstruction(name="fc",
                                             ch="d0",
                                             t0=0,
                                             phase=1.57).to_dict(),
                        PulseQobjInstruction(name="ym_d0", ch="d0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="xp_d0", ch="d0",
                                             t0=11).to_dict(),
                        PulseQobjInstruction(name="x90p_d1", ch="d1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="cr90p_u0", ch="u0",
                                             t0=2).to_dict(),
                        PulseQobjInstruction(name="cr90m_u0", ch="u0",
                                             t0=13).to_dict(),
                    ],
                }).to_dict(),
                Command.from_dict({
                    "name":
                    "measure",
                    "qubits": [0, 1],
                    "sequence": [
                        PulseQobjInstruction(name="measure_m0", ch="m0",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(name="measure_m1", ch="m1",
                                             t0=0).to_dict(),
                        PulseQobjInstruction(
                            name="acquire",
                            duration=10,
                            t0=0,
                            qubits=[0, 1],
                            memory_slot=[0, 1],
                        ).to_dict(),
                    ],
                }).to_dict(),
            ],
        })

        mock_time = datetime.datetime.now()
        dt = 1.3333
        self._properties = BackendProperties(
            backend_name="fake_openpulse_2q",
            backend_version="0.0.0",
            last_update_date=mock_time,
            qubits=[
                [
                    Nduv(date=mock_time,
                         name="T1",
                         unit="µs",
                         value=71.9500421005539),
                    Nduv(date=mock_time,
                         name="T2",
                         unit="µs",
                         value=69.4240447362455),
                    Nduv(date=mock_time,
                         name="frequency",
                         unit="MHz",
                         value=4919.96800692),
                    Nduv(date=mock_time,
                         name="readout_error",
                         unit="",
                         value=0.02),
                ],
                [
                    Nduv(date=mock_time,
                         name="T1",
                         unit="µs",
                         value=81.9500421005539),
                    Nduv(date=mock_time,
                         name="T2",
                         unit="µs",
                         value=75.5598482446578),
                    Nduv(date=mock_time,
                         name="frequency",
                         unit="GHz",
                         value=5.01996800692),
                    Nduv(date=mock_time,
                         name="readout_error",
                         unit="",
                         value=0.02),
                ],
            ],
            gates=[
                Gate(
                    gate="u1",
                    qubits=[0],
                    parameters=[
                        Nduv(date=mock_time,
                             name="gate_error",
                             unit="",
                             value=0.06),
                        Nduv(date=mock_time,
                             name="gate_length",
                             unit="ns",
                             value=0.0),
                    ],
                ),
                Gate(
                    gate="u3",
                    qubits=[0],
                    parameters=[
                        Nduv(date=mock_time,
                             name="gate_error",
                             unit="",
                             value=0.06),
                        Nduv(date=mock_time,
                             name="gate_length",
                             unit="ns",
                             value=2 * dt),
                    ],
                ),
                Gate(
                    gate="u3",
                    qubits=[1],
                    parameters=[
                        Nduv(date=mock_time,
                             name="gate_error",
                             unit="",
                             value=0.06),
                        Nduv(date=mock_time,
                             name="gate_length",
                             unit="ns",
                             value=4 * dt),
                    ],
                ),
                Gate(
                    gate="cx",
                    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),
                    ],
                ),
            ],
            general=[],
        )

        super().__init__(configuration)
Пример #15
0
 def _set_defaults_from_json(self):
     if not self.props_filename:
         raise QiskitError("No properties file has been defined")
     defs = self._load_json(self.defs_filename)
     decode_pulse_defaults(defs)
     self._defaults = PulseDefaults.from_dict(defs)