qml.estimator.ops.PCPhase

class PCPhase(num_wires, dim, rotation_precision=None, wires=None)[source]

Bases: ResourceOperator

A resource operator representing a projector-controlled phase gate.

This gate applies a complex phase \(e^{i\phi}\) to the first dim basis vectors of the input state while applying a complex phase \(e^{-i \phi}\) to the remaining basis vectors. For example, consider the 2-qubit case where dim = 3:

\[\begin{split}\Pi(\phi) = \begin{bmatrix} e^{i\phi} & 0 & 0 & 0 \\ 0 & e^{i\phi} & 0 & 0 \\ 0 & 0 & e^{i\phi} & 0 \\ 0 & 0 & 0 & e^{-i\phi} \end{bmatrix}.\end{split}\]

This can also be written as \(\Pi(\phi) = \exp(i\phi(2\Pi-\mathbb{I}_N))\), where \(N=2^n\) is the Hilbert space dimension for \(n\) qubits and \(\Pi\) is the diagonal projector with dim ones and N-dim zeros.

Parameters:
  • num_wires (int) – the number of wires this operator acts on

  • dim (int) – the dimension of the target subspace

  • rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the PhaseShift gates used to implement this operation.

  • wires (WiresLike | None) – the wire the operation acts on

Resources:

The resources are derived from the decomposition of the generator \(G\) of the PCPhase gate into multiple projectors, which generate (multi-controlled) PhaseShift gates, potentially complemented with (non-controlled) X gates and/or a global phase. The generator is given as \(G = 2 \Pi - \mathbb{I}_N\), where \(\Pi\) is a projector. The projector \(\Pi\) is decomposed into sums and differences of powers of two, which correspond to multi-controlled PhaseShift gates.

See also

The corresponding PennyLane operation PCPhase.

Example

The resources for this operation are computed using:

>>> import pennylane.estimator as qre
>>> pc_phase = qre.PCPhase(num_wires=2, dim=2, rotation_precision=1e-5)
>>> print(qre.estimate(pc_phase))
--- Resources: ---
 Total wires: 2
   algorithmic wires: 2
   allocated wires: 0
     zero state: 0
     any state: 0
 Total gates : 28
   'T': 28

resource_keys

resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

resource_keys = {'dim', 'num_wires', 'rotation_precision'}
resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

Returns:

A dictionary containing the resource parameters:
  • num_wires (int): the number of wires this operator acts on

  • dim (int): the dimension of the target subspace

  • rotation_precision(float | None): The error threshold for the approximate Clifford + T decomposition of the PhaseShift gates used to implement this operation.

Return type:

dict

resource_decomp(num_wires, dim[, ...])

Returns a list of GateCount objects representing the operator's resources.

resource_rep(num_wires, dim[, ...])

Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.

classmethod resource_decomp(num_wires, dim, rotation_precision=None)[source]

Returns a list of GateCount objects representing the operator’s resources.

Parameters:
  • num_wires (int) – the number of wires this operator acts on

  • dim (int) – the dimension of the target subspace

  • rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the PhaseShift gates used to implement this operation.

Resources:

The resources are derived from the decomposition of the generator \(G\) of the PCPhase gate into multiple projectors, which generate (multi-controlled) PhaseShift gates, potentially complemented with (non-controlled) X gates and/or a global phase. The generator is given as \(G = 2 \Pi - \mathbb{I}_N\), where \(\Pi\) is a projector. The projector \(\Pi\) is decomposed into sums and differences of powers of two, which correspond to multi-controlled PhaseShift gates.

Returns:

A list of GateCount objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.

Return type:

list[GateCount]

classmethod resource_rep(num_wires, dim, rotation_precision=None)[source]

Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.

Parameters:
  • num_wires (int) – the number of wires this operator acts on

  • dim (int) – the dimension of the target subspace

  • rotation_precision (float | None) – The error threshold for the approximate Clifford + T decomposition of the PhaseShift gates used to implement this operation.

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

Contents

Using PennyLane

Release news

Development

API

Internals