-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpilerpriority: high
Milestone
Description
Environment
- Qiskit version: 2.0.1
- Python version: 3.12.10
- Operating system: macOS 15.5
What is happening?
The transpilation of the RZZ gate in Qiskit 2.0 is less optimal compared to Qiskit 1.4.
For the example below, Qiskit 2.0 produces circuits with two CZ gates, whereas Qiskit 1.4 results in circuits with zero or one CZ gate.
Credit to @kifumi
How can we reproduce the issue?
from math import pi
from qiskit import QuantumCircuit, __version__, generate_preset_pass_manager
print(f"qiskit version: {__version__}")
pm = generate_preset_pass_manager(optimization_level=3, basis_gates=["rz", "cz", "sx", "x"])
for angle in [pi / 2, pi]:
qc = QuantumCircuit(2)
qc.rzz(angle, 0, 1)
t_qc = pm.run(qc)
print(t_qc)
output
qiskit version: 2.0.1
global phase: π/4
q_0: ─────────────────────────────■────────■─────────────────────────────
┌─────────┐┌────┐┌─────────┐ │ ┌────┐ │ ┌─────────┐┌────┐┌─────────┐
q_1: ┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├─■─┤ √X ├─■─┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├
└─────────┘└────┘└─────────┘ └────┘ └─────────┘└────┘└─────────┘
global phase: 0
q_0: ─────────────────────────────■───────■─────────────────────────────
┌─────────┐┌────┐┌─────────┐ │ ┌───┐ │ ┌─────────┐┌────┐┌─────────┐
q_1: ┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├─■─┤ X ├─■─┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├
└─────────┘└────┘└─────────┘ └───┘ └─────────┘└────┘└─────────┘
qiskit version: 2.1.0.dev0+31c12d8
global phase: π/4
q_0: ─────────────────────────────■────────■─────────────────────────────
┌─────────┐┌────┐┌─────────┐ │ ┌────┐ │ ┌─────────┐┌────┐┌─────────┐
q_1: ┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├─■─┤ √X ├─■─┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├
└─────────┘└────┘└─────────┘ └────┘ └─────────┘└────┘└─────────┘
global phase: 0
q_0: ─────────────────────────────■───────■─────────────────────────────
┌─────────┐┌────┐┌─────────┐ │ ┌───┐ │ ┌─────────┐┌────┐┌─────────┐
q_1: ┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├─■─┤ X ├─■─┤ Rz(π/2) ├┤ √X ├┤ Rz(π/2) ├
└─────────┘└────┘└─────────┘ └───┘ └─────────┘└────┘└─────────┘
What should happen?
Achieves the same quality as Qiskit 1.4
qiskit version: 1.4.3
global phase: 7π/4
┌──────────┐
q_0: ──────■─┤ Rz(-π/2) ├───────────
┌───┐ │ └──┬───┬───┘┌─────────┐
q_1: ┤ X ├─■────┤ X ├────┤ Rz(π/2) ├
└───┘ └───┘ └─────────┘
global phase: π/2
┌────────┐
q_0: ┤ Rz(-π) ├
├────────┤
q_1: ┤ Rz(-π) ├
└────────┘
Any suggestions?
No response
kifumi, ShellyGarion and mtreinish
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpilerpriority: high