Ejemplo n.º 1
0
    def properties(
        self,
        refresh: bool = False,
        datetime: Optional[python_datetime] = None
    ) -> Optional[BackendProperties]:
        """Return the online backend properties with optional filtering.

        Args:
            refresh: if True, the return is via a QX API call.
                Otherwise, a cached version is returned.
            datetime: by specifying a datetime,
                this function returns an instance of the BackendProperties whose
                timestamp is closest to, but older than, the specified datetime.

        Returns:
            The properties of the backend. If the backend has no properties to
            display, it returns ``None``.
        """
        # pylint: disable=arguments-differ
        if datetime:
            # Do not use cache for specific datetime properties.
            api_properties = self._api.backend_properties(self.name(),
                                                          datetime=datetime)
            if not api_properties:
                return None
            return BackendProperties.from_dict(api_properties)

        if refresh or self._properties is None:
            api_properties = self._api.backend_properties(self.name())
            self._properties = BackendProperties.from_dict(api_properties)

        return self._properties
Ejemplo n.º 2
0
    def properties(
        self,
        refresh: bool = False,
        datetime: Optional[python_datetime] = None
    ) -> Optional[BackendProperties]:
        """Return the backend properties, subject to optional filtering.

        Args:
            refresh: If ``True``, re-query the server for the backend properties.
                Otherwise, return a cached version.
            datetime: By specifying `datetime`, this function returns an instance
                of the :class:`BackendProperties<qiskit.providers.models.BackendProperties>`
                whose timestamp is closest to, but older than, the specified `datetime`.

        Returns:
            The backend properties or ``None`` if the backend properties are not
            currently available.
        """
        # pylint: disable=arguments-differ
        if datetime:
            # Do not use cache for specific datetime properties.
            api_properties = self._api.backend_properties(self.name(),
                                                          datetime=datetime)
            if not api_properties:
                return None
            return BackendProperties.from_dict(api_properties)

        if refresh or self._properties is None:
            api_properties = self._api.backend_properties(self.name())
            self._properties = BackendProperties.from_dict(api_properties)

        return self._properties
Ejemplo n.º 3
0
    def properties(self):
        """Return backend properties"""
        dummy_date = datetime.datetime.now().isoformat()
        properties = {
            'backend_name':
            self.name(),
            'backend_version':
            self.configuration().backend_version,
            'last_update_date':
            dummy_date,
            'qubits': [[{
                'name': 'DUMMY',
                'date': dummy_date,
                'unit': 'ms',
                'value': 0
            }]],
            'gates': [{
                'qubits': [0],
                'gate':
                'DUMMY',
                'parameters': [{
                    'name': 'DUMMY',
                    'date': dummy_date,
                    'unit': 'ms',
                    'value': 0
                }]
            }],
            'general': []
        }

        return BackendProperties.from_dict(properties)
Ejemplo n.º 4
0
 def properties(self):
     """Returns a snapshot of device properties as recorded on 8/30/19."""
     dirname = os.path.dirname(__file__)
     filename = "props_tokyo.json"
     with open(os.path.join(dirname, filename)) as f_prop:
         props = json.load(f_prop)
     return BackendProperties.from_dict(props)
 def properties(self):
     """Returns a snapshot of device properties"""
     dirname = os.path.dirname(__file__)
     filename = "props_poughkeepsie.json"
     with open(os.path.join(dirname, filename)) as f_prop:
         props = json.load(f_prop)
     return BackendProperties.from_dict(props)
Ejemplo n.º 6
0
    def properties(self):
        """Return backend properties"""
        properties = {
            'backend_name':
            self.name(),
            'backend_version':
            self.configuration().backend_version,
            'last_update_date':
            '2000-01-01 00:00:00Z',
            'qubits': [[{
                'name': 'TODO',
                'date': '2000-01-01 00:00:00Z',
                'unit': 'TODO',
                'value': 0
            }]],
            'gates': [{
                'qubits': [0],
                'gate':
                'TODO',
                'parameters': [{
                    'name': 'TODO',
                    'date': '2000-01-01 00:00:00Z',
                    'unit': 'TODO',
                    'value': 0
                }]
            }],
            'general': []
        }

        return BackendProperties.from_dict(properties)
Ejemplo n.º 7
0
    def properties(self):
        """Return backend properties"""

        coupling_map = self.configuration().coupling_map
        unique_qubits = list(set().union(*coupling_map))

        properties = {
            'backend_name': self.name(),
            'backend_version': self.configuration().backend_version,
            'last_update_date': '2000-01-01 00:00:00Z',
            'qubits': [
                [
                    {
                        "date": "2000-01-01 00:00:00Z",
                        "name": "T1",
                        "unit": "\u00b5s",
                        "value": 0.0
                    },
                    {
                        "date": "2000-01-01 00:00:00Z",
                        "name": "T2",
                        "unit": "\u00b5s",
                        "value": 0.0
                    },
                    {
                        "date": "2000-01-01 00:00:00Z",
                        "name": "frequency",
                        "unit": "GHz",
                        "value": 0.0
                    },
                    {
                        "date": "2000-01-01 00:00:00Z",
                        "name": "readout_error",
                        "unit": "",
                        "value": 0.0
                    }
                ] for _ in range(len(unique_qubits))
            ],
            'gates': [{
                "gate": "cx",
                "name": "CX" + str(pair[0]) + "_" + str(pair[1]),
                "parameters": [
                    {
                        "date": "2000-01-01 00:00:00Z",
                        "name": "gate_error",
                        "unit": "",
                        "value": 0.0
                    }
                ],
                "qubits": [
                    pair[0],
                    pair[1]
                ]
            } for pair in coupling_map],
            'general': []
        }

        return BackendProperties.from_dict(properties)
Ejemplo n.º 8
0
 def properties(self):
     """Returns a snapshot of device properties"""
     if not self._properties:
         dirname = os.path.dirname(__file__)
         filename = "props_montreal.json"
         with open(os.path.join(dirname, filename), "r") as f_prop:
             props = json.load(f_prop)
         self._properties = BackendProperties.from_dict(props)
     return self._properties
Ejemplo n.º 9
0
 def properties(self):
     """Returns a snapshot of device properties as recorded on 8/30/19.
     Sets the qubit 1 as non-operational.
     """
     props = super().properties().to_dict()
     props['qubits'][1].append({"date": "2000-01-01 00:00:00Z",
                                "name": "operational",
                                "unit": "",
                                "value": 0})
     return BackendProperties.from_dict(props)
Ejemplo n.º 10
0
    def properties(self):
        """Return the backend properties for this job.

        Returns:
            BackendProperties: the backend properties used for this job.
        """
        self._wait_for_submission()

        properties = self._api.job_properties(job_id=self.job_id())
        return BackendProperties.from_dict(properties)
Ejemplo n.º 11
0
 def properties(self):
     """Returns a snapshot of device properties as recorded on 10/24/19.
     """
     if not self._properties:
         dirname = os.path.dirname(__file__)
         filename = "props_cambridge.json"
         with open(os.path.join(dirname, filename), "r") as f_prop:
             props = json.load(f_prop)
         self._properties = BackendProperties.from_dict(props)
     return self._properties
Ejemplo n.º 12
0
    def properties(
        self,
        refresh: bool = False,
        datetime: Optional[python_datetime] = None
    ) -> Optional[BackendProperties]:
        """Return the backend properties, subject to optional filtering.

        This data describes qubits properties (such as T1 and T2),
        gates properties (such as gate length and error), and other general
        properties of the backend.

        The schema for backend properties can be found in
        `Qiskit/ibm-quantum-schemas
        <https://github.com/Qiskit/ibm-quantum-schemas/blob/main/schemas/backend_properties_schema.json>`_.

        Args:
            refresh: If ``True``, re-query the server for the backend properties.
                Otherwise, return a cached version.
            datetime: By specifying `datetime`, this function returns an instance
                of the :class:`BackendProperties<qiskit.providers.models.BackendProperties>`
                whose timestamp is closest to, but older than, the specified `datetime`.

        Returns:
            The backend properties or ``None`` if the backend properties are not
            currently available.

        Raises:
            TypeError: If an input argument is not of the correct type.
        """
        # pylint: disable=arguments-differ
        if not isinstance(refresh, bool):
            raise TypeError("The 'refresh' argument needs to be a boolean. "
                            "{} is of type {}".format(refresh, type(refresh)))
        if datetime and not isinstance(datetime, python_datetime):
            raise TypeError("'{}' is not of type 'datetime'.")

        if datetime:
            warnings.warn(
                'Unless a UTC timezone information is present, the parameter `datetime`'
                'is now expected to be in local time instead of UTC.',
                stacklevel=2)
            datetime = local_to_utc(datetime)

        if datetime or refresh or self._properties is None:
            api_properties = self._api_client.backend_properties(
                self.name(), datetime=datetime)
            if not api_properties:
                return None
            decode_backend_properties(api_properties)
            api_properties = utc_to_local_all(api_properties)
            backend_properties = BackendProperties.from_dict(api_properties)
            if datetime:  # Don't cache result.
                return backend_properties
            self._properties = backend_properties
        return self._properties
Ejemplo n.º 13
0
    def properties(self):
        """Return the online backend properties.

        The return is via QX API call.

        Returns:
            BackendProperties: The properties of the backend.
        """
        api_properties = self._api.backend_properties(self.name())

        return BackendProperties.from_dict(api_properties)
Ejemplo n.º 14
0
    def properties(self):
        """Return backend properties"""
        properties = {
            'backend_name': self.name(),
            'backend_version': self.configuration().backend_version,
            'last_update_date': '2000-01-01 00:00:00Z',
            'qubits': [],
            'gates': [],
            'general': []
        }

        return BackendProperties.from_dict(properties)
Ejemplo n.º 15
0
 def properties(self):
     """Returns a snapshot of device properties as recorded on 8/30/19.
     Sets the gate CX(Q1, Q3) (and symmetric) as non-operational.
     """
     props = super().properties().to_dict()
     for gate in props['gates']:
         if gate['gate'] == 'cx' and set(gate['qubits']) == {3, 1}:
             gate['parameters'].append({"date": "2000-01-01 00:00:00Z",
                                        "name": "operational",
                                        "unit": "",
                                        "value": 0})
     return BackendProperties.from_dict(props)
Ejemplo n.º 16
0
    def properties(
        self,
        refresh: bool = False,
        datetime: Optional[datetime] = None  # pylint: disable=redefined-outer-name
    ) -> Optional[BackendProperties]:
        """Return the online backend properties with optional filtering.

        Args:
            refresh (bool): if True, the return is via a QX API call.
                Otherwise, a cached version is returned.
            datetime (datetime.datetime): by specifying a datetime,
                this function returns an instance of the BackendProperties whose
                timestamp is closest to, but older than, the specified datetime.

        Returns:
            BackendProperties: The properties of the backend. If the backend has
                no properties to display, it returns ``None``.
        """
        # pylint: disable=arguments-differ
        if datetime:
            if not isinstance(self._api, BaseClient):
                warnings.warn('Retrieving the properties of a '
                              'backend in a specific datetime is '
                              'only available when using IBM Q v2')
                return None

            # Do not use cache for specific datetime properties.
            api_properties = self._api.backend_properties(self.name(),
                                                          datetime=datetime)
            if not api_properties:
                return None
            return BackendProperties.from_dict(api_properties)

        if refresh or self._properties is None:
            api_properties = self._api.backend_properties(self.name())
            self._properties = BackendProperties.from_dict(api_properties)

        return self._properties
Ejemplo n.º 17
0
 def properties(self):
     """Returns a snapshot of device properties as recorded on 8/30/19.
     Sets the gate CX(Q1, Q3) as non-operational.
     """
     props = super().properties().to_dict()
     for gate in props["gates"]:
         if gate["gate"] == "cx" and gate["qubits"] == [1, 3]:
             gate["parameters"].append({
                 "date": "2000-01-01 00:00:00Z",
                 "name": "operational",
                 "unit": "",
                 "value": 0
             })
     return BackendProperties.from_dict(props)
Ejemplo n.º 18
0
    def properties(self):
        """Return the online backend properties.

        The return is via QX API call.

        Returns:
            BackendProperties: The properties of the backend. If the backend
            is a simulator, it returns ``None``.
        """
        if self.configuration().simulator:
            return None

        api_properties = self._api.backend_properties(self.name())

        return BackendProperties.from_dict(api_properties)
Ejemplo n.º 19
0
    def properties(self, refresh=False):
        """Return the online backend properties.

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

        Returns:
            BackendProperties: The properties of the backend.
        """
        # pylint: disable=arguments-differ
        if refresh or self._properties is None:
            api_properties = self._api.backend_properties(self.name())
            self._properties = BackendProperties.from_dict(api_properties)

        return self._properties
Ejemplo n.º 20
0
    def properties(self) -> Optional[BackendProperties]:
        """Return the backend properties for this job.

        Returns:
            the backend properties used for this job, or None if
                properties are not available.

        Raises:
            IBMQJobApiError: if there was some unexpected failure in the server.
        """
        with api_to_job_error():
            properties = self._api.job_properties(job_id=self.job_id())

        if not properties:
            return None

        return BackendProperties.from_dict(properties)
Ejemplo n.º 21
0
    def properties(self) -> Optional[BackendProperties]:
        """Return the backend properties for this job.

        Returns:
            The backend properties used for this job, or ``None`` if
            properties are not available.

        Raises:
            IBMQJobApiError: If an unexpected error occurred when communicating
                with the server.
        """
        with api_to_job_error():
            properties = self._api.job_properties(job_id=self.job_id())

        if not properties:
            return None

        return BackendProperties.from_dict(properties)
Ejemplo n.º 22
0
    def properties(self):
        """Return the backend properties for this job.

        The properties might not be available if the job hasn't completed,
        in which case None is returned.

        Returns:
            BackendProperties: the backend properties used for this job, or None if
                properties are not available.
        """
        self._wait_for_submission()

        properties = self._api.job_properties(job_id=self.job_id())

        # Backend properties of a job might not be available if the job hasn't
        # completed. This is to ensure the properties returned are up to date.
        if not properties:
            return None
        return BackendProperties.from_dict(properties)
Ejemplo n.º 23
0
    def properties(
        self,
        refresh: bool = False,
        datetime: Optional[python_datetime] = None
    ) -> Optional[BackendProperties]:
        """Return the backend properties, subject to optional filtering.

        Args:
            refresh: If ``True``, re-query the server for the backend properties.
                Otherwise, return a cached version.
            datetime: By specifying `datetime`, this function returns an instance
                of the :class:`BackendProperties<qiskit.providers.models.BackendProperties>`
                whose timestamp is closest to, but older than, the specified `datetime`.

        Returns:
            The backend properties or ``None`` if the backend properties are not
            currently available.
        """
        # pylint: disable=arguments-differ
        if datetime:
            warnings.warn(
                'Unless a UTC timezone information is present, the parameter `datetime`'
                'is now expected to be in local time instead of UTC.',
                stacklevel=2)
            datetime = local_to_utc(datetime)

        if datetime or refresh or self._properties is None:
            api_properties = self._api.backend_properties(self.name(),
                                                          datetime=datetime)
            if not api_properties:
                return None
            decode_backend_properties(api_properties)
            warnings.warn(
                'All timestamps in backend properties are now in local time '
                'instead of UTC.',
                stacklevel=2)
            api_properties = utc_to_local_all(api_properties)
            backend_properties = BackendProperties.from_dict(api_properties)
            if datetime:  # Don't cache result.
                return backend_properties
            self._properties = backend_properties
        return self._properties
Ejemplo n.º 24
0
    def properties(self) -> Optional[BackendProperties]:
        """Return the backend properties for this job.

        Returns:
            The backend properties used for this job, or ``None`` if
            properties are not available.

        Raises:
            IBMQJobApiError: If an unexpected error occurred when communicating
                with the server.
        """
        with api_to_job_error():
            properties = self._api.job_properties(job_id=self.job_id())

        if not properties:
            return None

        warnings.warn('All timestamps in backend properties are now in '
                      'local time instead of UTC.', stacklevel=2)
        decode_backend_properties(properties)
        properties = utc_to_local_all(properties)
        return BackendProperties.from_dict(properties)
Ejemplo n.º 25
0
def properties_from_server_data(properties: Dict) -> BackendProperties:
    """Decode backend properties.

    Args:
        properties: Raw properties data.

    Returns:
        A ``BackendProperties`` instance.
    """
    properties["last_update_date"] = dateutil.parser.isoparse(
        properties["last_update_date"])
    for qubit in properties["qubits"]:
        for nduv in qubit:
            nduv["date"] = dateutil.parser.isoparse(nduv["date"])
    for gate in properties["gates"]:
        for param in gate["parameters"]:
            param["date"] = dateutil.parser.isoparse(param["date"])
    for gen in properties["general"]:
        gen["date"] = dateutil.parser.isoparse(gen["date"])

    properties = utc_to_local_all(properties)
    return BackendProperties.from_dict(properties)
Ejemplo n.º 26
0
    def _get_noise_model_from_backend_v2(
        self,
        gate_error=True,
        readout_error=True,
        thermal_relaxation=True,
        temperature=0,
        gate_lengths=None,
        gate_length_units="ns",
        standard_gates=None,
    ):
        """Build noise model from BackendV2.

        This is a temporary fix until qiskit-aer supports building noise model
        from a BackendV2 object.
        """

        from qiskit.circuit import Delay
        from qiskit.providers.exceptions import BackendPropertyError
        from qiskit.providers.aer.noise import NoiseModel
        from qiskit.providers.aer.noise.device.models import (
            _excited_population,
            basic_device_gate_errors,
            basic_device_readout_errors,
        )
        from qiskit.providers.aer.noise.passes import RelaxationNoisePass

        if self._props_dict is None:
            self._set_props_dict_from_json()

        properties = BackendProperties.from_dict(self._props_dict)
        basis_gates = self.operation_names
        num_qubits = self.num_qubits
        dt = self.dt

        noise_model = NoiseModel(basis_gates=basis_gates)

        # Add single-qubit readout errors
        if readout_error:
            for qubits, error in basic_device_readout_errors(properties):
                noise_model.add_readout_error(error, qubits)

        # Add gate errors
        with warnings.catch_warnings():
            warnings.filterwarnings(
                "ignore",
                module="qiskit.providers.aer.noise.device.models",
            )
            gate_errors = basic_device_gate_errors(
                properties,
                gate_error=gate_error,
                thermal_relaxation=thermal_relaxation,
                gate_lengths=gate_lengths,
                gate_length_units=gate_length_units,
                temperature=temperature,
                standard_gates=standard_gates,
            )
        for name, qubits, error in gate_errors:
            noise_model.add_quantum_error(error, name, qubits)

        if thermal_relaxation:
            # Add delay errors via RelaxationNiose pass
            try:
                excited_state_populations = [
                    _excited_population(freq=properties.frequency(q),
                                        temperature=temperature)
                    for q in range(num_qubits)
                ]
            except BackendPropertyError:
                excited_state_populations = None
            try:
                delay_pass = RelaxationNoisePass(
                    t1s=[properties.t1(q) for q in range(num_qubits)],
                    t2s=[properties.t2(q) for q in range(num_qubits)],
                    dt=dt,
                    op_types=Delay,
                    excited_state_populations=excited_state_populations,
                )
                noise_model._custom_noise_passes.append(delay_pass)
            except BackendPropertyError:
                # Device does not have the required T1 or T2 information
                # in its properties
                pass

        return noise_model
Ejemplo n.º 27
0
 def device_properties(self):
     properties = {
         "general": [],
         "last_update_date":
         "2019-04-22T03:26:08+00:00",
         "gates": [{
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [0]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [0]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [0]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [1]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [1]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [1]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [2]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [2]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [2]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [3]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [3]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [3]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [4]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [4]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [4]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [5]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [5]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [5]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [6]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [6]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [6]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [7]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [7]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [7]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [8]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [8]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [8]
         }, {
             "gate":
             "u1",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [9]
         }, {
             "gate":
             "u2",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [9]
         }, {
             "gate":
             "u3",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-23T01:45:04+00:00",
                 "unit": ""
             }],
             "qubits": [9]
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:26:00+00:00",
                 "unit": ""
             }],
             "qubits": [0, 1],
             "name":
             "CX0_1"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:29:15+00:00",
                 "unit": ""
             }],
             "qubits": [1, 2],
             "name":
             "CX1_2"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:32:48+00:00",
                 "unit": ""
             }],
             "qubits": [2, 3],
             "name":
             "CX2_3"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:26:00+00:00",
                 "unit": ""
             }],
             "qubits": [3, 4],
             "name":
             "CX3_4"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:29:15+00:00",
                 "unit": ""
             }],
             "qubits": [4, 5],
             "name":
             "CX4_5"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:32:48+00:00",
                 "unit": ""
             }],
             "qubits": [5, 6],
             "name":
             "CX5_6"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:26:00+00:00",
                 "unit": ""
             }],
             "qubits": [6, 7],
             "name":
             "CX6_7"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:29:15+00:00",
                 "unit": ""
             }],
             "qubits": [7, 8],
             "name":
             "CX7_8"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:32:48+00:00",
                 "unit": ""
             }],
             "qubits": [8, 9],
             "name":
             "CX8_9"
         }, {
             "gate":
             "cx",
             "parameters": [{
                 "name": "gate_error",
                 "value": 0.001,
                 "date": "2019-04-22T02:26:00+00:00",
                 "unit": ""
             }],
             "qubits": [9, 0],
             "name":
             "CX9_0"
         }],
         "qubits": [
             [{
                 "name": "T1",
                 "value": 23.809868955712616,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 43.41142418044261,
                 "date": "2019-04-22T01:33:33+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.032871440179164,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.03489999999999993,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 68.14048367144501,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 56.95903203933663,
                 "date": "2019-04-22T01:34:36+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 4.896209948700639,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.19589999999999996,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 83.26776276928099,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 23.49615795695734,
                 "date": "2019-04-22T01:31:32+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.100093544085939,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.09050000000000002,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 57.397746445609975,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 98.47976889309517,
                 "date": "2019-04-22T01:32:32+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.238526396839902,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.24350000000000005,
                 "date": "2019-04-20T15:31:39+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 23.809868955712616,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 43.41142418044261,
                 "date": "2019-04-22T01:33:33+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.032871440179164,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.03489999999999993,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 68.14048367144501,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 56.95903203933663,
                 "date": "2019-04-22T01:34:36+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 4.896209948700639,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.19589999999999996,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 83.26776276928099,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 23.49615795695734,
                 "date": "2019-04-22T01:31:32+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.100093544085939,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.09050000000000002,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 57.397746445609975,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 98.47976889309517,
                 "date": "2019-04-22T01:32:32+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.238526396839902,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.24350000000000005,
                 "date": "2019-04-20T15:31:39+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 23.809868955712616,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 43.41142418044261,
                 "date": "2019-04-22T01:33:33+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 5.032871440179164,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.03489999999999993,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
             [{
                 "name": "T1",
                 "value": 68.14048367144501,
                 "date": "2019-04-22T01:30:15+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "T2",
                 "value": 56.95903203933663,
                 "date": "2019-04-22T01:34:36+00:00",
                 "unit": "\u00b5s"
             }, {
                 "name": "frequency",
                 "value": 4.896209948700639,
                 "date": "2019-04-22T03:26:08+00:00",
                 "unit": "GHz"
             }, {
                 "name": "readout_error",
                 "value": 0.19589999999999996,
                 "date": "2019-04-22T01:29:47+00:00",
                 "unit": ""
             }],
         ],
         "backend_name":
         "mock_4q",
         "backend_version":
         "1.0.0"
     }
     return BackendProperties.from_dict(properties)
Ejemplo n.º 28
0
 def _set_props_from_json(self):
     if not self.props_filename:
         raise QiskitError("No properties file has been defined")
     props = self._load_json(self.props_filename)
     decode_backend_properties(props)
     self._properties = BackendProperties.from_dict(props)
Ejemplo n.º 29
0
def _target_to_backend_properties(target: Target):
    properties_dict = {
        "backend_name": "",
        "backend_version": "",
        "last_update_date": None,
        "general": [],
    }
    gates = []
    qubits = []
    for gate, qargs_list in target.items():
        if gate != "measure":
            for qargs, props in qargs_list.items():
                property_list = []
                if props is not None:
                    if props.duration is not None:
                        property_list.append({
                            "date": datetime.datetime.utcnow(),
                            "name": "gate_length",
                            "unit": "s",
                            "value": props.duration,
                        })
                    if props.error is not None:
                        property_list.append({
                            "date": datetime.datetime.utcnow(),
                            "name": "gate_error",
                            "unit": "",
                            "value": props.error,
                        })
                if property_list:
                    gates.append({
                        "gate":
                        gate,
                        "qubits":
                        list(qargs),
                        "parameters":
                        property_list,
                        "name":
                        gate + "_".join([str(x) for x in qargs]),
                    })
        else:
            qubit_props = {x: None for x in range(target.num_qubits)}
            for qargs, props in qargs_list.items():
                if qargs is None:
                    continue
                qubit = qargs[0]
                props_list = []
                if props.error is not None:
                    props_list.append({
                        "date": datetime.datetime.utcnow(),
                        "name": "readout_error",
                        "unit": "",
                        "value": props.error,
                    })
                if props.duration is not None:
                    props_list.append({
                        "date": datetime.datetime.utcnow(),
                        "name": "readout_length",
                        "unit": "s",
                        "value": props.duration,
                    })
                if not props_list:
                    qubit_props = {}
                    break
                qubit_props[qubit] = props_list
            if qubit_props and all(x is not None
                                   for x in qubit_props.values()):
                qubits = [qubit_props[i] for i in range(target.num_qubits)]
    if gates or qubits:
        properties_dict["gates"] = gates
        properties_dict["qubits"] = qubits
        return BackendProperties.from_dict(properties_dict)
    else:
        return None
Ejemplo n.º 30
0
def load_properties(filename):
    """Deserialize a BackendProperties object from a JSON file."""
    with open(filename, 'r') as file:
        return BackendProperties.from_dict(json.load(file))