Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected Output of VF2PostLayout #11089

Closed
sbrandhsn opened this issue Oct 23, 2023 · 0 comments · Fixed by #11090
Closed

Expected Output of VF2PostLayout #11089

sbrandhsn opened this issue Oct 23, 2023 · 0 comments · Fixed by #11090
Labels
bug Something isn't working

Comments

@sbrandhsn
Copy link
Contributor

Environment

  • Qiskit Terra version: '0.45.0.dev0+a1a9cc3'
  • Python version: 3.11.5
  • Operating system: macOs Sonoma 14.0

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 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'])
  • Output:

VF2PostLayoutStopReason.SOLUTION_FOUND
Layout({
2: Qubit(QuantumRegister(4, 'q'), 1),
1: Qubit(QuantumRegister(4, 'q'), 2),
3: Qubit(QuantumRegister(4, 'q'), 0)
})
VF2PostLayoutStopReason.NO_SOLUTION_FOUND
None

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant