qiskit-community/qiskit-research

Cost function using virtual qubits

Opened this issue · 0 comments

When trying to get the error for qubits used by the CX gate the code below assumes that the layout is virtual and it will raise errors with certain layouts for physical qubits.

https://github.com/qiskit-research/qiskit-research/blob/f4c1fe929d1e865a7c01fc85f85207a3a966aaff/qiskit_research/utils/cost_funcs.py#L54

The correct version would be:

fid *= (1-props.gate_error('cx', [layout[q0], layout[q1]]))

where layout is one of the matching layouts for the circuit. this is how it is handled in the original cost function code in mapomatic: https://github.com/Qiskit-Partners/mapomatic/blob/965ad30f20482fc14984cde371d5e1ab6b8335db/mapomatic/layouts.py#L210