Skip to content

Commit

Permalink
Revert "Add ESP readout support to Qiskit (Qiskit#6543)"
Browse files Browse the repository at this point in the history
The changes made in Qiskit#6543 were unecessary and add ibm backend specific
options to common interfaces in terra. This commit reverts Qiskit#6543 so it
can be isolated to just the ibmq provider as the new options added in
it are not common to all providers and isolated to just ibm backends.
The changes made in Qiskit#6543 should have been done directly in the ibm
provider and no changes to terra are actually needed here. Terra already
provides all the functionality to enable the provider to add custom options
like this. A provider can advertise the new run time option via the
backend's `Options` object, expose the backend configuration option as
a custom attribute at construction time, and pass the setting from the
options to assemble so it gets set in the qobj config appropriately
without requiring any changes from terra. However, this isn't all
necessarily clear as the interface for `BackendV1` was primarily
inherited from `BaseBackend` which didn't have this level of flexibility
and doesn't make the distinction between required, optional, and custom
options and backend attributes super clear. This is something we can
hopefully address in the next version of the backend interface
`BackendV2` (ideas for this are being collected in Qiskit#5885).

This reverts commit 6d605a0.
  • Loading branch information
mtreinish committed Jun 14, 2021
1 parent 6d605a0 commit 7c2c069
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 85 deletions.
21 changes: 1 addition & 20 deletions qiskit/compiler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def assemble(
parameter_binds: Optional[List[Dict[Parameter, float]]] = None,
parametric_pulses: Optional[List[str]] = None,
init_qubits: bool = True,
use_measure_esp: Optional[bool] = None,
**run_config: Dict,
) -> Qobj:
"""Assemble a list of circuits or pulse schedules into a ``Qobj``.
Expand Down Expand Up @@ -141,12 +140,7 @@ def assemble(
['gaussian', 'constant']
init_qubits: Whether to reset the qubits to the ground state for each shot.
Default: ``True``.
use_measure_esp: Whether to use excited state promoted (ESP) readout for the final
measurement in each circuit. ESP readout discriminates between the ``|0>`` and higher
transmon states to improve readout fidelity. See
`here <https://arxiv.org/pdf/2008.08571.pdf>`_.
Default: ``True`` if the backend supports ESP readout, else ``False``.
Default: ``True``.
**run_config: Extra arguments used to configure the run (e.g., for Aer configurable
backends). Refer to the backend documentation for details on these
arguments.
Expand All @@ -169,7 +163,6 @@ def assemble(
max_credits,
seed_simulator,
init_qubits,
use_measure_esp,
rep_delay,
qubit_lo_freq,
meas_lo_freq,
Expand Down Expand Up @@ -237,7 +230,6 @@ def _parse_common_args(
max_credits,
seed_simulator,
init_qubits,
use_measure_esp,
rep_delay,
qubit_lo_freq,
meas_lo_freq,
Expand Down Expand Up @@ -266,8 +258,6 @@ def _parse_common_args(
- If any of qubit or meas lo's, or associated ranges do not have length equal to
``n_qubits``.
- If qubit or meas lo's do not fit into perscribed ranges.
- If ``use_measure_esp`` is set to ``True`` on a device which does not support ESP
readout.
"""
# grab relevant info from backend if it exists
backend_config = None
Expand Down Expand Up @@ -353,22 +343,13 @@ def _parse_common_args(
for lo_config in schedule_los
]

measure_esp_enabled = getattr(backend_config, "measure_esp_enabled", False)
use_measure_esp = use_measure_esp or measure_esp_enabled # default to backend support value
if use_measure_esp and not measure_esp_enabled:
raise QiskitError(
"ESP readout not supported on this device. Please make sure the flag "
"'use_measure_esp' is unset or set to 'False'."
)

# create run configuration and populate
run_config_dict = dict(
shots=shots,
memory=memory,
max_credits=max_credits,
seed_simulator=seed_simulator,
init_qubits=init_qubits,
use_measure_esp=use_measure_esp,
rep_delay=rep_delay,
qubit_lo_freq=qubit_lo_freq,
meas_lo_freq=meas_lo_freq,
Expand Down
2 changes: 1 addition & 1 deletion qiskit/execute_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def execute(
Optionally specify a particular scheduling method.
init_qubits (bool): Whether to reset the qubits to the ground state for each shot.
Default: ``True``.
Default: ``True``.
run_config (dict):
Extra arguments used to configure the run (e.g. for Aer configurable backends).
Expand Down
9 changes: 1 addition & 8 deletions qiskit/providers/models/backendconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def __init__(
dtm=None,
processor_type=None,
parametric_pulses=None,
measure_esp_enabled=False,
**kwargs,
):
"""Initialize a QasmBackendConfiguration Object
Expand Down Expand Up @@ -301,10 +300,7 @@ def __init__(
- segment: Segment this processor belongs to within a larger chip.
parametric_pulses (list): A list of pulse shapes which are supported on the backend.
For example: ``['gaussian', 'constant']``
measure_esp_enabled (bool): Whether excited state promoted (ESP) readout is enabled on
this device. ESP readout discriminates between the ``|0>`` and higher transmon
states to improve readout fidelity. See
`here <https://arxiv.org/pdf/2008.08571.pdf>`_. Defaults to ``False``.
**kwargs: optional fields
"""
self._data = {}
Expand Down Expand Up @@ -364,8 +360,6 @@ def __init__(
if parametric_pulses is not None:
self.parametric_pulses = parametric_pulses

self.measure_esp_enabled = measure_esp_enabled

# convert lo range from GHz to Hz
if "qubit_lo_range" in kwargs.keys():
kwargs["qubit_lo_range"] = [
Expand Down Expand Up @@ -427,7 +421,6 @@ def to_dict(self):
"max_shots": self.max_shots,
"coupling_map": self.coupling_map,
"dynamic_reprate_enabled": self.dynamic_reprate_enabled,
"measure_esp_enabled": self.measure_esp_enabled,
}

if hasattr(self, "supported_instructions"):
Expand Down
7 changes: 1 addition & 6 deletions qiskit/schemas/backend_configuration_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://www.qiskit.org/schemas/backend_config_schema.json",
"description": "Qiskit device backend configuration",
"version": "1.4.4",
"version": "1.4.3",
"definitions": {
"hamiltonian": {
"type": "object",
Expand Down Expand Up @@ -157,11 +157,6 @@
"description": "Whether delay between programs can be set dynamically using 'rep_delay').",
"default": false
},
"measure_esp_enabled": {
"type": "boolean",
"description": "Whether ESP readout is supported by the backend.",
"default": false
},
"supported_instructions": {
"type": "array",
"minItems": 0,
Expand Down
23 changes: 0 additions & 23 deletions releasenotes/notes/esp-readout-3aa5fff772ddbab1.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions test/python/compiler/test_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,33 +471,6 @@ def test_init_qubits_false(self):
qobj = assemble(self.circ, init_qubits=False)
self.assertEqual(qobj.config.init_qubits, False)

def test_measure_esp_not_enabled(self):
"""Check that an error is raised if ``use_measure_esp=True`` on a device which does not
support ESP readout."""
setattr(self.backend_config, "measure_esp_enabled", False)
with self.assertRaises(QiskitError):
assemble(self.circ, self.backend, use_measure_esp=True)

def test_measure_esp_defaults(self):
"""Check that ``use_measure_esp`` defaults to True if ESP readout is enabled on the device
and false otherwise."""
# esp readout enabled
setattr(self.backend_config, "measure_esp_enabled", True)
qobj = assemble(self.circ, self.backend)
self.assertEqual(qobj.config.use_measure_esp, True)

# esp readout not enabled
setattr(self.backend_config, "measure_esp_enabled", False)
qobj = assemble(self.circ, self.backend)
self.assertEqual(qobj.config.use_measure_esp, False)

def test_measure_esp(self):
"""Test that ``use_measure_esp=True`` works on a device that supports ESP readout."""
# esp readout enabled
setattr(self.backend_config, "measure_esp_enabled", True)
qobj = assemble(self.circ, self.backend, use_measure_esp=True)
self.assertEqual(qobj.config.use_measure_esp, True)

def test_circuit_with_global_phase(self):
"""Test that global phase for a circuit is handled correctly."""
circ = QuantumCircuit(2)
Expand Down

0 comments on commit 7c2c069

Please sign in to comment.