Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Remove unsupported instructions after loop and not inside loop (#652)
Browse files Browse the repository at this point in the history
* Remove unsupported instructions after loop and not inside loop

* Release note

* Skip gates that are supported but do not have a properties map

* Updated release note

* Update releasenotes/notes/fix_loop-35cd0efcf5a0d0b6.yaml

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* United two info messages to one

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>
  • Loading branch information
3 people authored Jun 8, 2023
1 parent 38fa725 commit 79bafc6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 15 additions & 6 deletions qiskit_ibm_provider/utils/json_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def target_from_server_data(
) -> Target:
"""Decode transpiler target from backend data set.
This function directly generate ``Target`` instance without generate
This function directly generates ``Target`` instance without generating
intermediate legacy objects such as ``BackendProperties`` and ``PulseDefaults``.
Args:
Expand Down Expand Up @@ -130,6 +130,7 @@ def target_from_server_data(
all_instructions = set.union(supported_instructions, basis_gates, set(required))
faulty_qubits = set()
faulty_ops = set()
unsupported_instructions = []

# Create name to Qiskit instruction object repr mapping
for name in all_instructions:
Expand All @@ -155,8 +156,10 @@ def target_from_server_data(
"Please add new gate class to Qiskit or provide GateConfig for this name.",
name,
)
all_instructions.remove(name)
continue
unsupported_instructions.append(name)

for name in unsupported_instructions:
all_instructions.remove(name)

# Create empty inst properties from gate configs
for name, spec in gate_configs.items():
Expand Down Expand Up @@ -224,9 +227,11 @@ def target_from_server_data(
for cmd in map(Command.from_dict, pulse_defaults["cmd_def"]):
name = cmd.name
qubits = tuple(cmd.qubits)
if (name, qubits) in faulty_ops:
continue
if name not in all_instructions or qubits not in prop_name_map[name]:
if (
name not in all_instructions
or name not in prop_name_map
or qubits not in prop_name_map[name]
):
logger.info(
"Gate calibration for instruction %s on qubits %s is found "
"in the PulseDefaults payload. However, this entry is not defined in "
Expand All @@ -235,6 +240,10 @@ def target_from_server_data(
qubits,
)
continue

if (name, qubits) in faulty_ops:
continue

entry = PulseQobjDef(converter=converter, name=cmd.name)
entry.define(cmd.sequence)
try:
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/fix_loop-35cd0efcf5a0d0b6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
A bug that the backend target generation fails with an error
in some edge cases is fixed. See Qiskit/qiskit-ibm-provider/#650
for more details.

0 comments on commit 79bafc6

Please sign in to comment.