diagonal#

Functionality#

Circuit implementing a diagonal transformation.


diagonal.py#

Callee Diagonal

Given the state vector of a \(n\)-qubit quantum state \(\ket{\psi} = [a_0, a_1, \ldots, a_{2^n-1}]^{\top}\), and a list of \(2^n\) complex numbers \([d_0, d_1, \ldots, d_{2^n-1}]\), this circuit implements the transformation:

\[ U_{\text{Diagonal}}: [a_0, a_1, \ldots, a_{2^n-1}]^{\top} \mapsto [d_0 a_0, d_1 a_1, \ldots, d_{2^n-1} a_{2^n-1}]^{\top}. \]

To ensure the unitarity of this transformation, the elements of the diagonal must satisfy \(|d_i| = 1\) for all \(i = 0, \ldots, 2^n - 1\).

Diagonal operations are useful as representations of Boolean functions, as they can map from \(\{0,1\}^{2^n}\) to \(\{0,1\}^{2^n}\) space. For example a phase oracle can be seen as a diagonal gate with \(\{1,-1\}\) on the diagonals. Such an oracle will induce a \(+1\) or \(-1\) phase on the amplitude of any corresponding basis state.

Corresponding diagonal gates appear in many classically hard oracular problems such as Forrelation or Hidden Shift circuits.

Diagonal gates are represented and simulated more efficiently than a dense \(2^n \times 2^n\) unitary matrix.

The reference implementation is via the method described in Theorem 7 of [10]. The code is based on Emanuel Malvetti’s semester thesis at ETH in 2018, supervised by Raban Iten and Prof. Renato Renner.

Note:

Each element of the diagonal must satisfy \(|d_i| = 1\) to ensure the unitarity of the transformation.

Test expectations:

The amplitude of each computational basis state is multiplied by the corresponding diagonal element \(d_i\), leaving the measurement probability unchanged. This is only observable on statevector-based backend without additional processing.

Doc references: [11] [12]

API#

qolumbina.programs.diagonal.diagonal#

Diagonal matrix circuit.

class Diagonal(diag)[source]#

Bases: QuantumCircuit

Circuit implementing a diagonal transformation.

Parameters:

diag (Sequence[complex]) – A list of \(2^n\) complex numbers representing the diagonal elements of the unitary transformation, where this diagonal operation acts on \(n\) qubits. Each element must satisfy \(|d_i| = 1\).

Raises:

CircuitError – if the list of the diagonal entries or the qubit list is in bad format; if the number of diagonal entries is not \(2^k\), where \(k\) denotes the number of qubits.

class DiagonalGate(diag)[source]#

Bases: Gate

A generic diagonal quantum gate.

Matrix form:

\[\begin{split}\text{DiagonalGate}\ q_0, q_1, .., q_{n-1} = \begin{pmatrix} D[0] & 0 & \dots & 0 \\ 0 & D[1] & \dots & 0 \\ \vdots & \vdots & \ddots & 0 \\ 0 & 0 & \dots & D[n-1] \end{pmatrix}\end{split}\]

Diagonal gates are useful as representations of Boolean functions, as they can map from \(\{0,1\}^{2^n}\) to \(\{0,1\}^{2^n}\) space. For example a phase oracle can be seen as a diagonal gate with \(\{1, -1\}\) on the diagonals. Such an oracle will induce a \(+1\) or \(-1\) phase on the amplitude of any corresponding basis state.

Diagonal gates appear in many classically hard oracular problems such as Forrelation or Hidden Shift circuits.

Diagonal gates are represented and simulated more efficiently than a dense \(2^n \times 2^n\) unitary matrix.

The reference implementation is via the method described in Theorem 7 of [1]. The code is based on Emanuel Malvetti’s semester thesis at ETH in 2018, supervised by Raban Iten and Prof. Renato Renner.

References:

[1] Shende et al., Synthesis of Quantum Logic Circuits, 2009 arXiv:0406176

Parameters:

diag (Sequence[complex]) – list of the \(2^k\) diagonal entries (for a diagonal gate on \(k\) qubits).

inverse(annotated=False)[source]#

Return the inverse of the diagonal gate.

Parameters:

annotated (bool)

validate_parameter(parameter)[source]#

Diagonal Gate parameter should accept complex (in addition to the Gate parameter types) and always return build-in complex.

class UCPauliRotGate(angle_list, rot_axis)[source]#

Bases: Gate

Uniformly controlled Pauli rotations.

Implements the UCGate for the special case that all unitaries are Pauli rotations, \(U_i = R_P(a_i)\) where \(P \in \{X, Y, Z\}\) and \(a_i \in \mathbb{R}\) is the rotation angle.

Parameters:
  • angle_list (list[float]) – List of rotation angles \([a_0, ..., a_{2^{k-1}}]\).

  • rot_axis (str) – Rotation axis. Must be either of "X", "Y" or "Z".

class UCRZGate(angle_list)[source]#

Bases: UCPauliRotGate

Uniformly controlled Pauli-Z rotations.

Implements the UCGate for the special case that all unitaries are Pauli-Z rotations, \(U_i = R_Z(a_i)\) where \(a_i \in \mathbb{R}\) is the rotation angle.

Parameters:

angle_list (list[float]) – List of rotation angles \([a_0, ..., a_{2^{k-1}}]\).