Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6a3b145
fix measure_v2
to24toro May 22, 2023
3cd1192
modify measure_all
to24toro May 23, 2023
58023f5
dispatch backend
to24toro May 23, 2023
93a9262
add test of the builder with backendV2
to24toro May 24, 2023
2cc5451
reconfigure test codes and some func
to24toro May 26, 2023
a21cc84
refactoring
to24toro May 26, 2023
b3607ee
add reno
to24toro May 31, 2023
bd1e169
fix _measure_v2
to24toro May 31, 2023
d70796f
fix backend.meas_map in measure_v2
to24toro May 31, 2023
2a651dd
fix reno
to24toro May 31, 2023
8d92531
delete get_qubit_channels from utils
to24toro Jun 5, 2023
9b2b80d
add get_qubits_channels in qubit_channels
to24toro Jun 5, 2023
891c1bd
recostruct test about the builder with backendV2
to24toro Jun 5, 2023
83a31b3
add meas_map to Target class
to24toro Jun 5, 2023
f7a1cdb
Merge branch 'main' into feature/target_from_cofiguration
to24toro Jun 13, 2023
cf4357b
fix after mergin main branch
to24toro Jun 13, 2023
407f87d
fix documents about meas_map
to24toro Jun 18, 2023
609cfc3
Merge branch 'main' into feature/target_from_cofiguration
to24toro Jun 27, 2023
0b34040
format target.py
to24toro Jun 27, 2023
985a552
add reno
to24toro Jun 27, 2023
ca03dff
add meas_map to target in convert_to_target
to24toro Jul 6, 2023
dc45405
add the more description about meas_map
to24toro Jul 6, 2023
3cc4189
Update releasenotes/notes/enable_target_aware_meas_map-0d8542402a74e9…
to24toro Jul 6, 2023
a4926d3
fix test_meas_map
to24toro Jul 6, 2023
6deb381
remove format_meas_map
to24toro Jul 6, 2023
e49b319
rename meas_map in target to concurrent_measuments
to24toro Jul 12, 2023
6a2c9a1
Merge branch 'main' into feature/target_from_cofiguration
to24toro Jul 12, 2023
3ce53fa
change reno
to24toro Jul 12, 2023
3d4d0a3
remove Unused Union Dict
to24toro Jul 12, 2023
dc3838d
concurrent_measurements set as getattr(configuration, meas_map)
to24toro Jul 12, 2023
837ba2a
Update qiskit/transpiler/target.py
to24toro Jul 19, 2023
a054b2b
Update qiskit/transpiler/target.py
to24toro Jul 19, 2023
8f1770b
Merge branch 'main' into feature/target_from_cofiguration
to24toro Jul 19, 2023
d949c59
format
to24toro Jul 19, 2023
e44756a
Merge branch 'main' into feature/target_from_cofiguration
to24toro Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion qiskit/transpiler/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -252,6 +254,7 @@ def __init__(
pulse_alignment=1,
acquire_alignment=1,
qubit_properties=None,
meas_map=None,
):
"""
Create a new Target object
Expand Down Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

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_map are accepted as input, but only one is documented here.

Copy link
Copy Markdown
Contributor Author

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_map type 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 of meas_map is easy to understand intuitively rather than List if there exist hardware constraints.

I treated the meas_map type 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.

Raises:
ValueError: If both ``num_qubits`` and ``qubit_properties`` are both
defined and the value of ``num_qubits`` differs from the length of
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, only one of the two accepted formats is documented here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
I fixed at 407f87d .

dt: The system time resolution of input signals in seconds
timing_constraints: Optional timing constraints to include in the
:class:`~.Target`
Expand Down Expand Up @@ -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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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:
Expand Down
11 changes: 11 additions & 0 deletions test/python/transpiler/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from qiskit import pulse
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
from qiskit.pulse.calibration_entries import CalibrationPublisher, ScheduleDef
from qiskit.pulse.utils import format_meas_map
from qiskit.transpiler.coupling import CouplingMap
from qiskit.transpiler.instruction_durations import InstructionDurations
from qiskit.transpiler.timing_constraints import TimingConstraints
Expand Down Expand Up @@ -1903,6 +1904,16 @@ def test_inst_map(self):
self.assertEqual(target.pulse_alignment, constraints.pulse_alignment)
self.assertEqual(target.acquire_alignment, constraints.acquire_alignment)

def test_meas_map(self):
fake_backend = FakeVigo()
config = fake_backend.configuration()
target = Target.from_configuration(
basis_gates=config.basis_gates,
meas_map=config.meas_map,
)
meas_map = format_meas_map(config.meas_map)
self.assertEqual(meas_map, target.meas_map)

def test_custom_basis_gates(self):
basis_gates = ["my_x", "cx"]
custom_name_mapping = {"my_x": XGate()}
Expand Down