Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PassManagerConfig.from_backend with BackendV1 and no CouplingMap #10172

Merged
merged 3 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion qiskit/transpiler/passmanager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def from_backend(cls, backend, **pass_manager_options):
res.inst_map = backend.instruction_schedule_map
if res.coupling_map is None:
if backend_version < 2:
res.coupling_map = CouplingMap(getattr(config, "coupling_map", None))
cmap_edge_list = getattr(config, "coupling_map", None)
if cmap_edge_list is not None:
res.coupling_map = CouplingMap(cmap_edge_list)
else:
res.coupling_map = backend.coupling_map
if res.instruction_durations is None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
fixes:
- |
Fixed an issue with the :meth:`.PassManagerConfig.from_backend` constructor
when building a :class:`~.PassManagerConfig` object from a :class:`~.BackendV1`
instance that didn't have a coupling map attribute defined. Previously, the
constructor would incorrectly create a :class:`~.CouplingMap` object with
0 qubits instead of using ``None``.
Fixed `#10171 <https://github.com/Qiskit/qiskit-terra/issues/10171>`__
3 changes: 2 additions & 1 deletion test/python/transpiler/test_passmanager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def test_simulator_backend_v1(self):
config = PassManagerConfig.from_backend(backend)
self.assertIsInstance(config, PassManagerConfig)
self.assertIsNone(config.inst_map)
self.assertIsNone(config.coupling_map)

def test_invalid_user_option(self):
"""Test from_backend() with an invalid user option."""
Expand All @@ -103,7 +104,7 @@ def test_str(self):
initial_layout: None
basis_gates: ['id', 'rz', 'sx', 'x']
inst_map: None
coupling_map:
coupling_map: None
layout_method: None
routing_method: None
translation_method: None
Expand Down