Skip to content
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

Add a new argument concurrent_measurements to target class #10258

Merged
merged 35 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions qiskit/providers/backend_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def convert_to_target(
if filter_faulty:
faulty_qubits = set(properties.faulty_qubits())
qubit_properties = qubit_props_list_from_props(properties=properties)
target = Target(num_qubits=configuration.n_qubits, qubit_properties=qubit_properties)
target = Target(
num_qubits=configuration.n_qubits,
qubit_properties=qubit_properties,
concurrent_measurements=getattr(configuration, "meas_map", None),
)
# Parse instructions
gates: Dict[str, Any] = {}
for gate in properties.gates:
Expand Down Expand Up @@ -122,7 +126,10 @@ def convert_to_target(
target.add_instruction(Measure(), measure_props)
# Parse from configuration because properties doesn't exist
else:
target = Target(num_qubits=configuration.n_qubits)
target = Target(
num_qubits=configuration.n_qubits,
concurrent_measurements=getattr(configuration, "meas_map", None),
)
for gate in configuration.gates:
name = gate.name
gate_props = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def convert_to_target(conf_dict: dict, props_dict: dict = None, defs_dict: dict
qubit_props = None
if props_dict:
qubit_props = qubit_props_from_props(props_dict)
target = Target(qubit_properties=qubit_props)
target = Target(qubit_properties=qubit_props, concurrent_measurements=conf_dict.get("meas_map"))
# Parse from properties if it exsits
if props_dict is not None:
# Parse instructions
Expand Down
14 changes: 12 additions & 2 deletions 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 Optional, List, Any
from collections.abc import Mapping
from collections import defaultdict
import datetime
Expand Down Expand Up @@ -239,6 +239,7 @@ class Target(Mapping):
"_non_global_strict_basis",
"qubit_properties",
"_global_operations",
"concurrent_measurements",
)

@deprecate_arg("aquire_alignment", new_alias="acquire_alignment", since="0.23.0")
Expand All @@ -252,6 +253,7 @@ def __init__(
pulse_alignment=1,
acquire_alignment=1,
qubit_properties=None,
concurrent_measurements=None,
):
"""
Create a new Target object
Expand Down Expand Up @@ -287,7 +289,9 @@ 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``
Raises:
concurrent_measurements(list): A list of sets of qubits that must be
measured together. This must be provided
as a nested list like [[0, 1], [2, 3, 4]].
ValueError: If both ``num_qubits`` and ``qubit_properties`` are both
defined and the value of ``num_qubits`` differs from the length of
``qubit_properties``.
Expand Down Expand Up @@ -322,6 +326,7 @@ def __init__(
"length of the input qubit_properties list"
)
self.qubit_properties = qubit_properties
self.concurrent_measurements = concurrent_measurements

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,
concurrent_measurements: Optional[List[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,9 @@ 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.
concurrent_measurements(list): A list of sets of qubits that must be
measured together. This must be provided
as a nested list like [[0, 1], [2, 3, 4]].
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 +1315,7 @@ def from_configuration(
pulse_alignment=pulse_alignment,
acquire_alignment=acquire_alignment,
qubit_properties=qubit_properties,
concurrent_measurements=concurrent_measurements,
)
name_mapping = get_standard_gate_name_mapping()
if custom_name_mapping is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
features:
- |
Added :attr:`~.Target.concurrent_measurements` which represents a hardware constraint of qubits
measured concurrently. This constraint is provided in the nested list form,
in which each element represents qubit group to be measured together.
In an example below,

.. code-block:: python

[[0, 1], [2, 3, 4]]

qubits 0 and 1, and 2, 3 and 4 are measured together on the device.
This constraint doesn't block measuring an individual qubit,
however, Qiskit scheduler must consider the alignment of
measure operations for those qubits.
9 changes: 9 additions & 0 deletions test/python/transpiler/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,15 @@ def test_inst_map(self):
self.assertEqual(target.pulse_alignment, constraints.pulse_alignment)
self.assertEqual(target.acquire_alignment, constraints.acquire_alignment)

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

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