Skip to content

Commit

Permalink
Avoid useless deepcopy of target with custom pulse gates in transpile (
Browse files Browse the repository at this point in the history
…#10973)

* Avoid useless deepcopy of target in transpile

* Fix lint
  • Loading branch information
itoko authored Oct 5, 2023
1 parent 0803fa7 commit d0effae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def callback_func(**kwargs):
)

_skip_target = False
_given_inst_map = bool(inst_map) # check before inst_map is overwritten
# If a target is specified have it override any implicit selections from a backend
if target is not None:
if coupling_map is None:
Expand Down Expand Up @@ -335,7 +336,7 @@ def callback_func(**kwargs):

timing_constraints = _parse_timing_constraints(backend, timing_constraints)

if inst_map is not None and inst_map.has_custom_gate() and target is not None:
if _given_inst_map and inst_map.has_custom_gate() and target is not None:
# Do not mutate backend target
target = copy.deepcopy(target)
target.update_from_instruction_schedule_map(inst_map)
Expand Down

0 comments on commit d0effae

Please sign in to comment.