-
Notifications
You must be signed in to change notification settings - Fork 3k
Add a new argument concurrent_measurements to target class #10258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
6a3b145
3cd1192
58023f5
93a9262
2cc5451
a21cc84
b3607ee
bd1e169
d70796f
2a651dd
8d92531
9b2b80d
891c1bd
83a31b3
f7a1cdb
cf4357b
407f87d
609cfc3
0b34040
985a552
ca03dff
dc45405
3cc4189
a4926d3
6deb381
e49b319
6a2c9a1
3ce53fa
3d4d0a3
dc3838d
837ba2a
a054b2b
8f1770b
d949c59
e44756a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
|
|
||
| import itertools | ||
|
|
||
| from typing import Any | ||
| from typing import Union, Optional, Dict, List, Any | ||
| from collections.abc import Mapping | ||
| from collections import defaultdict | ||
| import datetime | ||
|
|
@@ -44,6 +44,7 @@ | |
| from qiskit.transpiler.timing_constraints import TimingConstraints | ||
| from qiskit.providers.exceptions import BackendPropertyError | ||
| from qiskit.pulse.exceptions import PulseError | ||
| from qiskit.pulse.utils import format_meas_map | ||
| from qiskit.utils.deprecation import deprecate_arg, deprecate_func | ||
| from qiskit.exceptions import QiskitError | ||
|
|
||
|
|
@@ -239,6 +240,7 @@ class Target(Mapping): | |
| "_non_global_strict_basis", | ||
| "qubit_properties", | ||
| "_global_operations", | ||
| "meas_map", | ||
| ) | ||
|
|
||
| @deprecate_arg("aquire_alignment", new_alias="acquire_alignment", since="0.23.0") | ||
|
|
@@ -252,6 +254,7 @@ def __init__( | |
| pulse_alignment=1, | ||
| acquire_alignment=1, | ||
| qubit_properties=None, | ||
| meas_map=None, | ||
| ): | ||
| """ | ||
| Create a new Target object | ||
|
|
@@ -287,6 +290,7 @@ def __init__( | |
| matches the qubit number the properties are defined for. If some | ||
| qubits don't have properties available you can set that entry to | ||
| ``None`` | ||
| meas_map(list, dict): List of sets of qubits that must be measured together. | ||
| Raises: | ||
| ValueError: If both ``num_qubits`` and ``qubit_properties`` are both | ||
| defined and the value of ``num_qubits`` differs from the length of | ||
|
|
@@ -322,6 +326,7 @@ def __init__( | |
| "length of the input qubit_properties list" | ||
| ) | ||
| self.qubit_properties = qubit_properties | ||
| self.meas_map = format_meas_map(meas_map) if isinstance(meas_map, list) else meas_map | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Despite documenting the list option in the doc string, we actually convert to the dictionary option here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to convert the data format here? Probably this is bit confusing to users if input data is implicitly modified. Since formatted meas map is useful for implementing pulse scheduling, probably we can do this format in the scheduler. Then we can restrict the input to list format.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed at dc45405. |
||
|
|
||
| def add_instruction(self, instruction, properties=None, name=None): | ||
| """Add a new instruction to the :class:`~qiskit.transpiler.Target` | ||
|
|
@@ -1215,6 +1220,7 @@ def from_configuration( | |
| inst_map: InstructionScheduleMap | None = None, | ||
| backend_properties: BackendProperties | None = None, | ||
| instruction_durations: InstructionDurations | None = None, | ||
| meas_map: Optional[Union[List[List[int]], Dict[int, List[int]]]] = None, | ||
| dt: float | None = None, | ||
| timing_constraints: TimingConstraints | None = None, | ||
| custom_name_mapping: dict[str, Any] | None = None, | ||
|
|
@@ -1263,6 +1269,7 @@ def from_configuration( | |
| instruction_durations: Optional instruction durations for instructions. If specified | ||
| it will take priority for setting the ``duration`` field in the | ||
| :class:`~InstructionProperties` objects for the instructions in the target. | ||
| meas_map: List of sets of qubits that must be measured together. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, only one of the two accepted formats is documented here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you pointed out, the document is not easy for users or developers to understand. |
||
| dt: The system time resolution of input signals in seconds | ||
| timing_constraints: Optional timing constraints to include in the | ||
| :class:`~.Target` | ||
|
|
@@ -1306,6 +1313,7 @@ def from_configuration( | |
| pulse_alignment=pulse_alignment, | ||
| acquire_alignment=acquire_alignment, | ||
| qubit_properties=qubit_properties, | ||
| meas_map=format_meas_map(meas_map) if isinstance(meas_map, list) else meas_map, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again, the inconsistency between the doc string and the actual format used later. |
||
| ) | ||
| name_mapping = get_standard_gate_name_mapping() | ||
| if custom_name_mapping is not None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two representations of
meas_mapare accepted as input, but only one is documented here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, most part of the
meas_maptype is list and this is converted into Dict in inner codes. However, I think that 'meas_map' accepts Dict, e.g. macros.measure, in some cases because Dict ofmeas_mapis easy to understand intuitively rather than List if there exist hardware constraints.I treated the
meas_maptype as Dict and implemented macros.measure in backendV2. (It seems that format_measmap was implemented because it is easier to use for Dict than for List.)So, if the input is a List, I would like to use format_measmap to convert the List to a Dict, and accept both List and Dict as input.