Exemplo n.º 1
0
def configuration_from_server_data(
    raw_config: Dict,
    instance: str = "",
) -> Optional[Union[QasmBackendConfiguration, PulseBackendConfiguration]]:
    """Create an IBMBackend instance from raw server data.

    Args:
        raw_config: Raw configuration.
        instance: Service instance.

    Returns:
        Backend configuration.
    """
    # Make sure the raw_config is of proper type
    if not isinstance(raw_config, dict):
        logger.warning(  # type: ignore[unreachable]
            "An error occurred when retrieving backend "
            "information. Some backends might not be available.")
        return None
    try:
        _decode_backend_configuration(raw_config)
        try:
            return PulseBackendConfiguration.from_dict(raw_config)
        except (KeyError, TypeError):
            return QasmBackendConfiguration.from_dict(raw_config)
    except Exception:  # pylint: disable=broad-except
        logger.warning(
            'Remote backend "%s" for service instance %s could not be instantiated due to an '
            "invalid config: %s",
            raw_config.get("backend_name", raw_config.get("name", "unknown")),
            repr(instance),
            traceback.format_exc(),
        )
    return None
Exemplo n.º 2
0
    def __init__(self, backend, backend_name, local=True):
        """FakeBackend initializer.

        Args:
            backend (IBMQBackend): IBMQBackend instance
            backend_name (str): The name to give the backend.
            local (bool): Determines if Aer of IBMQ simulator should be used.
        """
        if backend.configuration().open_pulse:
            config = PulseBackendConfiguration.from_dict(backend.configuration().to_dict())
        else:
            config = QasmBackendConfiguration.from_dict(backend.configuration().to_dict())
        super().__init__(config)
        self._credentials = _Credentials()
        self._properties = backend.properties()
        self._configuration.simulator = True
        self._configuration.local = local
        self._configuration.backend_name = backend_name
        if AER_VERSION >= 60000:
            self.noise_model = NoiseModel.from_backend(self, warnings=False)
        else:
            self.noise_model = NoiseModel.from_backend(self)
        if local:
            self.sim = Aer.get_backend('qasm_simulator')
        else:
            pro = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
            self.sim = pro.backends.ibmq_qasm_simulator
Exemplo n.º 3
0
    def _discover_remote_backends(self):
        """Return the remote backends available.

        Returns:
            dict[str:IBMQBackend]: a dict of the remote backend instances,
                keyed by backend name.
        """
        ret = OrderedDict()
        configs_list = self._api.available_backends()
        for raw_config in configs_list:
            try:
                if raw_config.get('open_pulse', False):
                    config = PulseBackendConfiguration.from_dict(raw_config)
                else:
                    config = QasmBackendConfiguration.from_dict(raw_config)
                backend_cls = IBMQSimulator if config.simulator else IBMQBackend
                ret[config.backend_name] = backend_cls(
                    configuration=config,
                    provider=self._ibm_provider,
                    credentials=self.credentials,
                    api=self._api)
            except ModelValidationError as ex:
                logger.warning(
                    'Remote backend "%s" could not be instantiated due to an '
                    'invalid config: %s',
                    raw_config.get('backend_name',
                                   raw_config.get('name', 'unknown')),
                    ex)

        return ret
 def __init__(self):
     dirname = os.path.dirname(__file__)
     filename = "conf_manhattan.json"
     with open(os.path.join(dirname, filename)) as f_conf:
         conf = json.load(f_conf)
     configuration = PulseBackendConfiguration.from_dict(conf)
     configuration.backend_name = 'fake_manhattan'
     self._defaults = None
     self._properties = None
     super().__init__(configuration)
Exemplo n.º 5
0
    def __init__(self):
        """
         0 ↔ 1 ↔ 3 ↔ 4
             ↕
             2
        """
        dirname = os.path.dirname(__file__)
        filename = "conf_burlington.json"
        with open(os.path.join(dirname, filename), "r") as f_conf:
            conf = json.load(f_conf)

        configuration = PulseBackendConfiguration.from_dict(conf)
        configuration.backend_name = 'fake_burlington'
        super().__init__(configuration)
Exemplo n.º 6
0
    def __init__(self):
        """
          00 ↔ 01 ↔ 02 ↔ 03 ↔ 04
                ↕         ↕
          05 ↔ 06 ↔ 07 ↔ 08 ↔ 09
           ↕         ↕         ↕
          10 ↔ 11 ↔ 12 ↔ 13 ↔ 14
                ↕         ↕
          15 ↔ 16 ↔ 17 ↔ 18 ↔ 19
        """
        dirname = os.path.dirname(__file__)
        filename = "conf_almaden.json"
        with open(os.path.join(dirname, filename), "r") as f_conf:
            conf = json.load(f_conf)

        configuration = PulseBackendConfiguration.from_dict(conf)
        configuration.backend_name = 'fake_almaden'
        super().__init__(configuration)
Exemplo n.º 7
0
    def __init__(self):
        """
         0 ↔ 1 ↔ 2
             ↕
             3
             ↕
             4
        """
        dirname = os.path.dirname(__file__)
        filename = "conf_valencia.json"
        with open(os.path.join(dirname, filename), "r") as f_conf:
            conf = json.load(f_conf)

        configuration = PulseBackendConfiguration.from_dict(conf)
        configuration.backend_name = 'fake_valencia'
        self._defaults = None
        self._properties = None
        super().__init__(configuration)
Exemplo n.º 8
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=[[1, 0]],
            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)
                          ]],
            meas_level=[1, 2],
            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, 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]],
            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]])

        self._defaults = PulseDefaults(qubit_freq_est=[4.9, 5.0],
                                       meas_freq_est=[6.5, 6.6],
                                       buffer=10,
                                       pulse_library=[],
                                       cmd_def=[])

        super().__init__(configuration)
Exemplo n.º 9
0
    def _discover_remote_backends(self,
                                  timeout: Optional[float] = None
                                  ) -> Dict[str, IBMQBackend]:
        """Return the remote backends available for this provider.

        Args:
            timeout: Maximum number of seconds to wait for the discovery of
                remote backends.

        Returns:
            A dict of the remote backend instances, keyed by backend name.
        """
        ret = OrderedDict()  # type: ignore[var-annotated]
        configs_list = self._api_client.list_backends(timeout=timeout)
        for raw_config in configs_list:
            # Make sure the raw_config is of proper type
            if not isinstance(raw_config, dict):
                logger.warning(
                    "An error occurred when retrieving backend "
                    "information. Some backends might not be available.")
                continue

            try:
                decode_backend_configuration(raw_config)
                if raw_config.get('open_pulse', False):
                    config = PulseBackendConfiguration.from_dict(raw_config)
                else:
                    config = QasmBackendConfiguration.from_dict(raw_config)
                backend_cls = IBMQSimulator if config.simulator else IBMQBackend
                ret[config.backend_name] = backend_cls(
                    configuration=config,
                    provider=self,
                    credentials=self.credentials,
                    api_client=self._api_client)
            except Exception as ex:  # pylint: disable=broad-except
                logger.warning(
                    'Remote backend "%s" for provider %s could not be instantiated due to an '
                    'invalid config: %s: %s',
                    raw_config.get('backend_name',
                                   raw_config.get('name', 'unknown')),
                    repr(self),
                    type(ex).__name__, ex)

        return ret
Exemplo n.º 10
0
 def __init__(self):
     """
       00 ↔ 01 ↔ 02 ↔ 03 ↔ 04
        ↕                   ↕
       05 ↔ 06 ↔ 07 ↔ 08 ↔ 09
        ↕         ↕         ↕
       10 ↔ 11 ↔ 12 ↔ 13 ↔ 14
        ↕                   ↕
       15 ↔ 16 ↔ 17 ↔ 18 ↔ 19
     """
     dirname = os.path.dirname(__file__)
     filename = "conf_johannesburg.json"
     with open(os.path.join(dirname, filename)) as f_conf:
         conf = json.load(f_conf)
     configuration = PulseBackendConfiguration.from_dict(conf)
     configuration.backend_name = 'fake_johannesburg'
     self._defaults = None
     self._properties = None
     super().__init__(configuration)
Exemplo n.º 11
0
    def _discover_remote_backends(self,
                                  timeout: Optional[float] = None
                                  ) -> Dict[str, IBMQBackend]:
        """Return the remote backends available.

        Args:
            timeout (float or None): number of seconds to wait for the discovery.

        Returns:
            dict[str:IBMQBackend]: a dict of the remote backend instances,
                keyed by backend name.
        """
        ret = OrderedDict()
        configs_list = self._api.list_backends(timeout=timeout)
        for raw_config in configs_list:
            # Make sure the raw_config is of proper type
            if not isinstance(raw_config, dict):
                logger.warning(
                    "An error occurred when retrieving backend "
                    "information. Some backends might not be available.")
                continue

            try:
                if raw_config.get('open_pulse', False):
                    config = PulseBackendConfiguration.from_dict(raw_config)
                else:
                    config = QasmBackendConfiguration.from_dict(raw_config)
                backend_cls = IBMQSimulator if config.simulator else IBMQBackend
                ret[config.backend_name] = backend_cls(
                    configuration=config,
                    provider=self,
                    credentials=self.credentials,
                    api=self._api)
            except ModelValidationError as ex:
                logger.warning(
                    'Remote backend "%s" could not be instantiated due to an '
                    'invalid config: %s',
                    raw_config.get('backend_name',
                                   raw_config.get('name', 'unknown')), ex)

        return ret
Exemplo n.º 12
0
    def __init__(self):
        """
                       06                  17
                       ↕                    ↕
        00 ↔ 01 ↔ 04 ↔ 07 ↔ 10 ↔ 12 ↔ 15 ↔ 18 ↔ 20 ↔ 23
             ↕                   ↕                    ↕
             02                  13                  24
             ↕                   ↕                    ↕
             03 ↔ 05 ↔ 08 ↔ 11 ↔ 14 ↔ 16 ↔ 19 ↔ 22 ↔ 25 ↔ 26
                       ↕                    ↕
                       09                  20
        """
        dirname = os.path.dirname(__file__)
        filename = "conf_paris.json"
        with open(os.path.join(dirname, filename), "r") as f_conf:
            conf = json.load(f_conf)

        configuration = PulseBackendConfiguration.from_dict(conf)
        configuration.backend_name = 'fake_paris'
        self._defaults = None
        self._properties = None
        super().__init__(configuration)
Exemplo n.º 13
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)
Exemplo n.º 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=[[1, 0]],
            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)]
            ],
            meas_level=[1, 2],
            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]
            ]
        )

        self._defaults = PulseDefaults(
            qubit_freq_est=[4.9, 5.0],
            meas_freq_est=[6.5, 6.6],
            buffer=10,
            pulse_library=[PulseLibraryItem(name='test_pulse_1', samples=[0.j, 0.1j]),
                           PulseLibraryItem(name='test_pulse_2', samples=[0.j, 0.1j, 1j]),
                           PulseLibraryItem(name='test_pulse_3',
                                            samples=[0.j, 0.1j, 1j, 0.5 + 0j])],
            cmd_def=[Command(name='u1', qubits=[0],
                             sequence=[PulseQobjInstruction(name='fc', ch='d0',
                                                            t0=0, phase='-P1*np.pi')]),
                     Command(name='u3', qubits=[0],
                             sequence=[PulseQobjInstruction(name='test_pulse_1', ch='d0', t0=0)]),
                     Command(name='u3', qubits=[1],
                             sequence=[PulseQobjInstruction(name='test_pulse_3', ch='d1', t0=0)]),
                     Command(name='cx', qubits=[0, 1],
                             sequence=[PulseQobjInstruction(name='test_pulse_1', ch='d0', t0=0),
                                       PulseQobjInstruction(name='test_pulse_2', ch='u0', t0=10),
                                       PulseQobjInstruction(name='pv', ch='d1',
                                                            t0=2, val='cos(P2)'),
                                       PulseQobjInstruction(name='test_pulse_1', ch='d1', t0=20),
                                       PulseQobjInstruction(name='fc', ch='d1',
                                                            t0=20, phase=2.1)]),
                     Command(name='measure', qubits=[0],
                             sequence=[PulseQobjInstruction(name='test_pulse_1', ch='m0', t0=0),
                                       PulseQobjInstruction(name='acquire', duration=10, t0=0,
                                                            qubits=[0], memory_slot=[0])])]
        )

        super().__init__(configuration)
Exemplo n.º 15
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)
Exemplo n.º 16
0
    def _build_conf(self) -> PulseBackendConfiguration:
        """Build configuration for backend."""
        h_str = [
            ",".join([
                "_SUM[i,0,{n_qubits}".format(n_qubits=self.n_qubits),
                "wq{i}/2*(I{i}-Z{i})]"
            ]), ",".join([
                "_SUM[i,0,{n_qubits}".format(n_qubits=self.n_qubits),
                "omegad{i}*X{i}||D{i}]"
            ])
        ]
        variables = []
        for (qubit1, qubit2) in self.coupling_map:
            h_str += [
                "jq{q1}q{q2}*Sp{q1}*Sm{q2}".format(q1=qubit1, q2=qubit2),
                "jq{q1}q{q2}*Sm{q1}*Sp{q2}".format(q1=qubit1, q2=qubit2)
            ]

            variables.append(("jq{q1}q{q2}".format(q1=qubit1, q2=qubit2), 0))
        for i, (qubit1, qubit2) in enumerate(self.coupling_map):
            h_str.append("omegad{0}*X{1}||U{2}".format(qubit1, qubit2, i))
        for i in range(self.n_qubits):
            variables += [("omegad{}".format(i), 0), ("wq{}".format(i), 0)]
        hamiltonian = {
            'h_str':
            h_str,
            'description':
            'Hamiltonian description for {} qubits backend.'.format(
                self.n_qubits),
            'qub': {i: 2
                    for i in range(self.n_qubits)},
            'vars':
            dict(variables)
        }

        meas_map = [list(range(self.n_qubits))]
        qubit_lo_range = [[freq - 0.5, freq + 0.5]
                          for freq in self.qubit_frequency]
        meas_lo_range = [[6.5, 7.5] for _ in range(self.n_qubits)]
        u_channel_lo = [[UchannelLO(q=i, scale=1.0 + 0.0j)]
                        for i in range(len(self.coupling_map))]

        return PulseBackendConfiguration(backend_name=self.name,
                                         backend_version=self.version,
                                         n_qubits=self.n_qubits,
                                         meas_levels=[0, 1, 2],
                                         basis_gates=self.basis_gates,
                                         simulator=False,
                                         local=True,
                                         conditional=True,
                                         open_pulse=True,
                                         memory=False,
                                         max_shots=65536,
                                         gates=[],
                                         coupling_map=self.coupling_map,
                                         n_registers=self.n_qubits,
                                         n_uchannels=self.n_qubits,
                                         u_channel_lo=u_channel_lo,
                                         meas_level=[1, 2],
                                         qubit_lo_range=qubit_lo_range,
                                         meas_lo_range=meas_lo_range,
                                         dt=self.dt,
                                         dtm=10.5,
                                         rep_times=[1000],
                                         meas_map=meas_map,
                                         channel_bandwidth=[],
                                         meas_kernels=['kernel1'],
                                         discriminators=['max_1Q_fidelity'],
                                         acquisition_latency=[],
                                         conditional_latency=[],
                                         hamiltonian=hamiltonian)
Exemplo n.º 17
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)
                          ]],
            meas_level=[1, 2],
            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]])

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

        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',
                     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.)
                     ]),
                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)
                     ]),
            ],
            general=[])

        super().__init__(configuration)
    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)
    def __init__(
        self,
        t_off: float = 0.0,
        ix: float = 0.0,
        iy: float = 0.0,
        iz: float = 0.0,
        zx: float = 0.0,
        zy: float = 0.0,
        zz: float = 0.0,
        b: float = 0.0,
    ):
        """Initialize fake backend.

        Args:
            t_off: Offset of gate duration.
            ix: IX term coefficient.
            iy: IY term coefficient.
            iz: IZ term coefficient.
            zx: ZX term coefficient.
            zy: ZY term coefficient.
            zz: ZZ term coefficient.
            b: Offset term.
        """
        self.fit_func_args = {
            "t_off": t_off,
            "px0": 2 * np.pi * (ix + zx),
            "px1": 2 * np.pi * (ix - zx),
            "py0": 2 * np.pi * (iy + zy),
            "py1": 2 * np.pi * (iy - zy),
            "pz0": 2 * np.pi * (iz + zz),
            "pz1": 2 * np.pi * (iz - zz),
            "b": b,
        }
        configuration = PulseBackendConfiguration(
            backend_name="fake_cr_hamiltonian",
            backend_version="0.1.0",
            n_qubits=2,
            basis_gates=["sx", "rz", "x", "cx"],
            gates=None,
            local=True,
            simulator=True,
            conditional=False,
            open_pulse=True,
            memory=True,
            max_shots=10000,
            coupling_map=[[0, 1], [1, 0]],
            n_uchannels=2,
            u_channel_lo=[],
            meas_levels=[2],
            qubit_lo_range=[],
            meas_lo_range=[],
            dt=1,
            dtm=1,
            rep_times=[],
            meas_kernels=[],
            discriminators=[],
            channels={
                "d0": {
                    "operates": {
                        "qubits": [0]
                    },
                    "purpose": "drive",
                    "type": "drive"
                },
                "d1": {
                    "operates": {
                        "qubits": [1]
                    },
                    "purpose": "drive",
                    "type": "drive"
                },
                "u0": {
                    "operates": {
                        "qubits": [0, 1]
                    },
                    "purpose": "cross-resonance",
                    "type": "control",
                },
                "u1": {
                    "operates": {
                        "qubits": [0, 1]
                    },
                    "purpose": "cross-resonance",
                    "type": "control",
                },
            },
            timing_constraints={
                "granularity": 16,
                "min_length": 64
            },
        )

        super().__init__(configuration)
        setattr(
            self._configuration,
            "_control_channels",
            {
                (0, 1): [pulse.ControlChannel(0)],
                (1, 0): [pulse.ControlChannel(1)],
            },
        )
Exemplo n.º 20
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)
Exemplo n.º 21
0
 def _get_config_from_dict(self, conf):
     return PulseBackendConfiguration.from_dict(conf)