Skip to content

Commit

Permalink
Add qubits to Delay target entry
Browse files Browse the repository at this point in the history
If any instructions available in a target are ideal, with no qubits or
properties set, the target class assumes the backend is ideal (like in
the case of an ideal simulator where are all instructions are globally
defined and have no error or duration). To avoid this we need to define
the Delay instruction on all qubits explicitly. This commit makes this
change to ensure the target for backends still shows the qubits and
properties for the other operations. However, in adding an instruction
with no properties defined a bug in the plot gate error map function was
uncovered where it errored because it assumes all instructions have
properties defined, this was fixed at the same time.
  • Loading branch information
mtreinish committed May 2, 2022
1 parent 2d8e130 commit 9459bd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qiskit/test/mock/utils/backend_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def convert_to_target(conf_dict: dict, props_dict: dict = None, defs_dict: dict
if props_dict:
qubit_props = qubit_props_from_props(props_dict)
target = Target(qubit_properties=qubit_props)
target.add_instruction(Delay(Parameter("t")))
# Parse from properties if it exsits
if props_dict is not None:
# Parse instructions
Expand Down Expand Up @@ -125,6 +124,9 @@ def convert_to_target(conf_dict: dict, props_dict: dict = None, defs_dict: dict
target[inst][(qubit,)].calibration = sched
else:
target[inst][qarg].calibration = sched
target.add_instruction(
Delay(Parameter("t")), {(bit,): None for bit in range(target.num_qubits)}
)
return target


Expand Down
2 changes: 2 additions & 0 deletions qiskit/visualization/gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@ def plot_error_map(backend, figsize=(12, 9), show_title=True, qubit_coordinates=
if prop_dict is None or None in prop_dict:
continue
for qargs, inst_props in prop_dict.items():
if inst_props is None:
continue
if gate == "measure":
if inst_props.error is not None:
read_err[qargs[0]] = inst_props.error
Expand Down

0 comments on commit 9459bd7

Please sign in to comment.