You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a VF2PostLayout on a quantum circuit with an initial layout that is optimal, i.e. already has the lowest cost for the given target quantum computer, returns VF2PostLayoutStopReason.NO_SOLUTION_FOUND and None as post_layout in the property set of the pass.
How can we reproduce the issue?
def linear_target(n, trivial_layout_is_best):
cm = CouplingMap.from_line(n)
tqc = Target(num_qubits=n)
if trivial_layout_is_best:
# the first qubits of the device have the lowest errors
cx_props = {(v, u): InstructionProperties(error=10 ** (n-v)) for v, u in cm.get_edges()}
else:
# the last qubits of the device have the lowest errors
cx_props = {(v, u): InstructionProperties(error=10 ** (-v)) for v, u in cm.get_edges()}
tqc.add_instruction(CXGate(), cx_props)
return tqc
def run_vf2post(target, qc):
pm = PassManager()
pm.append(VF2PostLayout(target=target))
pm.run(qc)
return pm
n = 4
qc = QuantumCircuit(n)
qc.cx(0, 1)
qc.cx(1,2)
pm0 = run_vf2post(linear_target(n, trivial_layout_is_best=False), qc)
print(pm0.property_set['VF2PostLayout_stop_reason'])
print(pm0.property_set['post_layout'])
pm1 = run_vf2post(linear_target(n, trivial_layout_is_best=True), qc)
print(pm1.property_set['VF2PostLayout_stop_reason'])
print(pm1.property_set['post_layout'])
VF2PostLayout should always populate the post_layout field, if the pass can determine a layout that does not require the insertion of swap gates. Alternatively, VF2PostLayout should indicate that there is such a layout but that it already equals the initial layout of the input quantum circuit.
A typical use case where this issue becomes relevant is an user that determines a quantum circuit compliant with the coupling map of the target quantum computer outside of Qiskit and only wants to adapt their mapped quantum circuit to the current calibration data before submitting their quantum circuit to the queue. VF2PostLayout is presented as the prime solution for this task in arXiv:2209.15512 and it works really well but caused some confusion in the described case.
Any suggestions?
I will shortly submit a PR that extends the VF2PostLayout with a NO_BETTER_SOLUTION_FOUND indication in the described corner case.
The text was updated successfully, but these errors were encountered:
Environment
What is happening?
Running a VF2PostLayout on a quantum circuit with an initial layout that is optimal, i.e. already has the lowest cost for the given target quantum computer, returns
VF2PostLayoutStopReason.NO_SOLUTION_FOUND
and None aspost_layout
in the property set of the pass.How can we reproduce the issue?
What should happen?
VF2PostLayout should always populate the
post_layout
field, if the pass can determine a layout that does not require the insertion of swap gates. Alternatively, VF2PostLayout should indicate that there is such a layout but that it already equals the initial layout of the input quantum circuit.A typical use case where this issue becomes relevant is an user that determines a quantum circuit compliant with the coupling map of the target quantum computer outside of Qiskit and only wants to adapt their mapped quantum circuit to the current calibration data before submitting their quantum circuit to the queue. VF2PostLayout is presented as the prime solution for this task in arXiv:2209.15512 and it works really well but caused some confusion in the described case.
Any suggestions?
I will shortly submit a PR that extends the VF2PostLayout with a
NO_BETTER_SOLUTION_FOUND
indication in the described corner case.The text was updated successfully, but these errors were encountered: