Two-qubit synthesis to ["cx", "rz", "sx", "x"] returns a wrong circuit (1 - F_avg ≈ 0.07) near the two-CX boundary
Qiskit bug report -- text for each field of the GitHub form
Open https://github.com/Qiskit/qiskit/issues/new/choose and choose Bug report. Copy each block below into the field with the same name.
Title
Two-qubit synthesis to ["cx", "rz", "sx", "x"] returns a wrong circuit (1 - F_avg ≈ 0.07) near the two-CX boundary
Environment
- Qiskit version: 2.5.2 (latest release on PyPI at the time of writing; reproduced in a fresh virtual environment with numpy 2.5.3, scipy 1.18.1, rustworkx 0.18.1)
- Python version: 3.12.13
- Operating system: Linux (WSL2, glibc 2.43)
What is happening?
For the canonical two-qubit gate exp(i(0.6 XX + 0.3 YY + c ZZ)) with c = 3e-8, 1e-7 and 3e-7, TwoQubitBasisDecomposer(CXGate(), euler_basis="ZSX") returns a circuit whose unitary differs from the input with average gate infidelity 6.99e-2. The circuit has 3 CX gates, so the error is not visible from the gate counts.
The same failure appears in plain transpile() of a UnitaryGate to basis_gates=["cx", "rz", "sx", "x"], at every optimization level (0-3): 3 CX at levels 0-1 and 2 CX at levels 2-3, with the same infidelity. It also appears when the core is dressed with fixed single-qubit layers on both sides.
Not affected in our tests:
- the same decomposer with its default Euler basis (
TwoQubitBasisDecomposer(CXGate())): exact on the same inputs; - a CZ basis (
["cz", "rz", "sx", "x"]), levels 1 and 3; - a two-qubit
GenericBackendV2target with error data, levels 1 and 3; - the same gate given as
RXX/RYY/RZZinstead of aUnitaryGate.
Results are exact at c = 1e-8 (2 CX, within the documented approximation) and from c = 5e-7 upward.
How can we reproduce the issue?
from qiskit import QuantumCircuit, transpile
from qiskit.circuit.library import CXGate, UnitaryGate
from qiskit.quantum_info import Operator, average_gate_fidelity
from qiskit.synthesis import TwoQubitBasisDecomposer
core = QuantumCircuit(2)
core.rxx(-1.2, 0, 1) # a = 0.6
core.ryy(-0.6, 0, 1) # b = 0.3
core.rzz(-2e-7, 0, 1) # c = 1e-7
u = Operator(core)
out = TwoQubitBasisDecomposer(CXGate(), euler_basis="ZSX")(u.data)
print("decomposer ZSX:", 1 - average_gate_fidelity(Operator(out), u)) # ~6.99e-02
out_default = TwoQubitBasisDecomposer(CXGate())(u.data)
print("decomposer default:", 1 - average_gate_fidelity(Operator(out_default), u)) # ~1e-16
qc = QuantumCircuit(2)
qc.append(UnitaryGate(u.data), [0, 1])
for level in range(4):
t = transpile(qc, basis_gates=["cx", "rz", "sx", "x"], optimization_level=level)
print("transpile level", level, ":", 1 - average_gate_fidelity(Operator(t), u)) # ~6.99e-02 at every level
Scan over c (1 - F_avg, number of 2-qubit gates), UnitaryGate input:
What should happen?
The synthesized circuit should match the input to within the decomposer's requested fidelity (1 - 1e-9 by default), as it does with the default Euler basis and with a CZ basis.
Any suggestions?
The infidelity is identical (6.987e-2) at every c in the band and with or without single-qubit dressing, which suggests one wrongly taken branch -- perhaps in the ZSX single-qubit synthesis of a local factor near a degenerate angle -- rather than accumulated rounding. This is a guess from the outside; we have not read the source.
For context: we found this while testing a downstream two-qubit synthesizer that delegated its CX-basis step to this decomposer; we now check the decomposer's output and fall back to the default Euler basis when it is off. A larger scan (four families of near-degenerate cores, 272 blocks) found 48 blocks with this 6.99e-2 error and no failures of the default-Euler decomposer.
### How can we reproduce the issue? What should happen? The synthesized circuit should match the input to within the decomposer's requested fidelity (1 - 1e-9 by default), as it does with the default Euler basis and with a CZ basis. ### What should happen? Any suggestions? The infidelity is identical (6.987e-2) at every c in the band and with or without single-qubit dressing, which suggests one wrongly taken branch -- perhaps in the ZSX single-qubit synthesis of a local factor near a degenerate angle -- rather than accumulated rounding. This is a guess from the outside; we have not read the source. For context: we found this while testing a downstream two-qubit synthesizer that delegated its CX-basis step to this decomposer; we now check the decomposer's output and fall back to the default Euler basis when it is off. A larger scan (four families of near-degenerate cores, 272 blocks) found 48 blocks with this 6.99e-2 error and no failures of the default-Euler decomposer. ### Any suggestions? _No response_Source: Qiskit/qiskit