mapomatic icon indicating copy to clipboard operation
mapomatic copied to clipboard

Add support for BackendV2

Open kevinsung opened this issue 2 years ago • 2 comments
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'

kevinsung avatar Nov 23 '22 22:11 kevinsung

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.

kevinsung avatar Dec 19 '22 14:12 kevinsung

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().simulator
  • backend.configuration().processor_type.get('segment', '')

kevinsung avatar Jan 06 '23 14:01 kevinsung