Skip to main contentIBM Quantum Documentation


class qiskit.synthesis.XXDecomposer(basis_fidelity=1.0, euler_basis='U', embodiments=None, backup_optimizer=None)

GitHub(opens in a new tab)

Bases: object(opens in a new tab)

A class for optimal decomposition of 2-qubit unitaries into 2-qubit basis gates of XX type (i.e., each locally equivalent to CAN(α,0,0)CAN(\alpha, 0, 0) for a possibly varying alphaalpha).


  • basis_fidelity (dict(opens in a new tab) |float(opens in a new tab)) – available strengths and fidelity of each. Can be either (1) a dictionary mapping XX angle values to fidelity at that angle; or (2) a single float f, interpreted as {pi: f, pi/2: f/2, pi/3: f/3}.
  • euler_basis (str(opens in a new tab)) – Basis string provided to OneQubitEulerDecomposer for 1Q synthesis. Defaults to "U".
  • embodiments (dict(opens in a new tab)[float(opens in a new tab), QuantumCircuit] | None) – A dictionary mapping interaction strengths alpha to native circuits which embody the gate CAN(α,0,0)CAN(\alpha, 0, 0). Strengths are taken so that π/2\pi/2 represents the class of a full CXGate.
  • backup_optimizer (Callable[..., QuantumCircuit] | None) – If supplied, defers synthesis to this callable when XXDecomposer has no efficient decomposition of its own. Useful for special cases involving 2 or 3 applications of XX(π/2)XX(\pi/2), in which case standard synthesis methods provide lower 1Q gate count.

If embodiments is not passed, or if an entry is missing, it will be populated as needed using the method _default_embodiment.


__call__(unitary, basis_fidelity=None, approximate=True, use_dag=False)

GitHub(opens in a new tab)

Fashions a circuit which (perhaps approximately) models the special unitary operation unitary, using the circuit templates supplied at initialization as embodiments. The routine uses basis_fidelity to select the optimal circuit template, including when performing exact synthesis; the contents of basis_fidelity is a dictionary mapping interaction strengths (scaled so that CX=RZX(π/2)CX = RZX(\pi/2) corresponds to π/2\pi/2) to circuit fidelities.


  • unitary (Operator or ndarray) – 4×44 \times 4 unitary to synthesize.
  • basis_fidelity (dict(opens in a new tab) orfloat(opens in a new tab)) – Fidelity of basis gates. Can be either (1) a dictionary mapping XX angle values to fidelity at that angle; or (2) a single float f, interpreted as {pi: f, pi/2: f/2, pi/3: f/3}. If given, overrides the basis_fidelity given at init.
  • approximate (bool(opens in a new tab)) – Approximates if basis fidelities are less than 1.0 .
  • use_dag (bool(opens in a new tab)) – If true a DAGCircuit is returned instead of a QuantumCircuit when this class is called.


Synthesized circuit.

Return type





GitHub(opens in a new tab)

Counts the number of gates that would be emitted during re-synthesis.


This method is used by ConsolidateBlocks.

Was this page helpful?
Report a bug or request content on GitHub.