-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Environment
- Qiskit version: 1.3 dev
- Python version: 3.10
- Operating system: mac
What is happening?
Circuits that are mapped and routed can become unmapped unintentionally due to ElidePermutation treating inserted SWAPs as unwanted.
How can we reproduce the issue?
Suppose i ran some routing passes and got the following circuit on a line of 4 qubits. Then i just want to bring it down to some basis gates. Optimization level 2 and 3 (due to ElidePermutation) will undo the mapping.
circuit_routed = QuantumCircuit(4)
circuit_routed.cx(0, 1)
circuit_routed.h(1)
circuit_routed.swap(1, 2)
circuit_routed.cx(2, 3)
print(circuit_routed)
pm = generate_preset_pass_manager(basis_gates=['cx', 'sx', 'rz'], routing_method='none', optimization_level=2)
circuit_basis = pm.run(circuit_routed)
circuit_basis = pm.run(circuit_routed)
print(circuit_basis)
gives
q_0: ──■───────────────
┌─┴─┐┌───┐
q_1: ┤ X ├┤ H ├─X──────
└───┘└───┘ │
q_2: ───────────X───■──
┌─┴─┐
q_3: ─────────────┤ X ├
└───┘
global phase: π/4
Qubit(QuantumRegister(4, 'q'), 0) -> 0 ──■───────────────────────────────────
┌─┴─┐┌─────────┐┌────┐┌─────────┐
Qubit(QuantumRegister(4, 'q'), 1) -> 1 ┤ X ├┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├──■──
└───┘└─────────┘└────┘└─────────┘ │
Qubit(QuantumRegister(4, 'q'), 2) -> 2 ───────────────────────────────────┼──
┌─┴─┐
Qubit(QuantumRegister(4, 'q'), 3) -> 3 ─────────────────────────────────┤ X ├
└───┘
What should happen?
routing_method='none' should disable ElidePermutation (or anything that wants to remove swaps)
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working