Closed ajavadia closed 5 months ago
We have a discussion about refactoring the Layout
class in #11604 , @ajavadia could you give your opinion there? :-)
I think there are some other issues with the generate_preset_pass_manager
. Even when an actual Layout object is supplied, it fails with TranspilerError: 'Sabre swap runs on physical circuits only.'
. Needs more exploration.
@ajavadia do you have a re-create. I wrote a quick test to check this and it seems to at least work for my test:
coupling_map_list = [[0, 1]]
# Circuit that doesn't fit in the coupling map
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 0)
qc.measure_all()
pm_list = generate_preset_pass_manager(
optimization_level=optimization_level,
coupling_map=coupling_map_list,
basis_gates=["u", "cx"],
seed_transpiler=42,
initial_layout=[1, 0],
)
pm_object = generate_preset_pass_manager(
optimization_level=optimization_level,
coupling_map=coupling_map_list,
basis_gates=["u", "cx"],
seed_transpiler=42,
initial_layout=Layout.from_intlist([1, 0], *qc.qregs),
)
tqc_list = pm_list.run(qc)
tqc_obj = pm_list.run(qc)
self.assertIsInstance(pm_list, PassManager)
self.assertIsInstance(pm_object, PassManager)
self.assertEqual(tqc_list, tqc_obj)
(I checked the output circuits and they worked fine). Is the issue just the type hint for the argument?
What should we add?
Now that https://github.com/Qiskit/qiskit/pull/10344 is merged, we should make the
generate_preset_pass_manager
function take an integer list for layout. This is a user entry point and should be easy to use. The Layout object is a pain to use all around (I would love to completely eliminate it, since it doesn't contain any more information than a list of int. The circuit qubits have an order).