Skip to content

Commit

Permalink
update_from_instruction_schedule_map
Browse files Browse the repository at this point in the history
  • Loading branch information
to24toro committed Aug 17, 2023
1 parent b253d1c commit c63073f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 4 additions & 8 deletions qiskit/transpiler/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,8 @@ def update_from_instruction_schedule_map(self, inst_map, inst_name_map=None, err
props = None

entry = get_calibration(inst_name, qargs)
if entry.user_provided and getattr(props, "_calibration", None) != entry:
# It only copies user-provided calibration from the inst map.
# Backend defined entry must already exist in Target.

if getattr(props, "_calibration", None) != entry:
if self.dt is not None:
try:
duration = entry.get_schedule().duration * self.dt
Expand All @@ -512,15 +511,12 @@ def update_from_instruction_schedule_map(self, inst_map, inst_name_map=None, err
duration = None
else:
duration = None
if props is None:
continue
props = InstructionProperties(
duration=duration,
calibration=entry,
)
else:
if props is None:
# Edge case. Calibration is backend defined, but this is not
# registered in the backend target. Ignore this entry.
continue
try:
# Update gate error if provided.
props.error = error_dict[inst_name][qargs]
Expand Down
2 changes: 2 additions & 0 deletions test/python/transpiler/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,9 +1360,11 @@ def test_loading_legacy_ugate_instmap(self):
target.add_instruction(RZGate(Parameter("θ")), {(0,): InstructionProperties()})
target.add_instruction(Measure(), {(0,): InstructionProperties()})
names_before = set(target.operation_names)
print(names_before)

target.update_from_instruction_schedule_map(instmap)
names_after = set(target.operation_names)
print(names_after)

# Otherwise u3 and sx-rz basis conflict in 1q decomposition.
self.assertSetEqual(names_before, names_after)
Expand Down

0 comments on commit c63073f

Please sign in to comment.