mapomatic
mapomatic copied to clipboard
Add support for BackendV2
trafficstars
import mapomatic
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeBelemV2
qc = QuantumCircuit(5)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 3)
qc.cx(0, 4)
qc.measure_all()
backend = FakeBelemV2()
trans_qc = transpile(qc, backend)
print(mapomatic.best_overall_layout(trans_qc, [backend]))
Traceback (most recent call last):
File "/home/kevinsung/projects/scratch/mapomatic-backendv2.py", line 16, in <module>
print(mapomatic.best_overall_layout(trans_qc, [backend]))
File "/home/kevinsung/projects/mapomatic/mapomatic/layouts.py", line 190, in best_overall_layout
config = backend.configuration()
AttributeError: 'FakeBelemV2' object has no attribute 'configuration'
I think the proper way to go about this is to rewrite the codebase assuming the input is a BackendV2. If the input is not a BackendV2, first convert it using BackendV2Converter.
I made an attempt at this and started to run into some difficulties. It appears that mapomatic makes some assumptions about the backend that are not satisfied by BackendV2. In particular I had trouble translating the following expressions:
backend.configuration().simulatorbackend.configuration().processor_type.get('segment', '')