Skip to content

Commit

Permalink
deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Oct 16, 2023
1 parent 1e52ac8 commit 1a375df
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions qiskit/transpiler/passes/layout/noise_adaptive_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Choose a noise-adaptive Layout based on current calibration data for the backend."""

import math

from copy import deepcopy
import rustworkx as rx

from qiskit.transpiler.layout import Layout
Expand Down Expand Up @@ -73,21 +73,20 @@ def __init__(self, backend_prop, coupling_map=None):
self.backend_prop = target_to_backend_properties(self.target)
else:
self.target = None
self.backend_prop = backend_prop

if coupling_map:
# A backend might have more properties than qubits/gates in the configuration. This is a
# problem that the Target path should handle differently (by solving that possible
# inconsistency internally). For the non-target path, this is a possible solution.
# See https://github.com/Qiskit/qiskit/issues/7677
backend_prop = deepcopy(backend_prop)
edge_set = set(coupling_map.graph.edge_list())
self.backend_prop.gates = filter(
backend_prop.gates = filter(
lambda ginfo: tuple(ginfo.qubits) in edge_set,
backend_prop.gates,
)
self.backend_prop.qubits = backend_prop.qubits[
: 1 + max(coupling_map.physical_qubits)
]
backend_prop.qubits = backend_prop.qubits[: 1 + max(coupling_map.physical_qubits)]
self.backend_prop = backend_prop

self.swap_graph = rx.PyDiGraph()
self.cx_reliability = {}
Expand Down

0 comments on commit 1a375df

Please sign in to comment.