PennyLane
  • Why PennyLane
  • Getting Started
  • Documentation
  • Ecosystem
Install
Install
  1. Compilation/
  2. Control logic decompositions

Control logic decompositions

OverviewCompute/uncomputeGlobal phasesPhase shiftsLCU(QSVT)Resources

Phase shift operators are omnipresent in quantum computing. Depending on the abstraction of the quantum programming language used and the preferred representation, it is convenient to be able to translate between "generic" phase shifts ( which are defined to act on the state |1\rangle) and "flipped" phase shifts (acting on the state |0\rangle). It is also useful to know their relationship to Pauli Z rotations and how all these relationships translate to controlled versions.

The most significant equivalence from this page might be

0: ──╭Rϕ(a)─┤ ≅ 0: ──╭RZ(a)──────────────────────────────────────┤ 1: ──├●─────┤ 1: ──├●─────╭RZ(a/2)─────────────────────────────┤ 2: ──╰●─────┤ 2: ──╰●─────╰●────────RZ(a/4)──GlobalPhase(-a/8)─┤.

We will refer to the operator with matrix representation

R_\phi(\phi) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{pmatrix}

in the computational basis as a "generic" phase shift, or just phase shift.

Relationship to Pauli Z rotation

As the Pauli Z rotation gate and the phase shift gate both just cause a relative phase change, they are equivalent to each other up to a global phase:

──Rϕ(a)─┤ = ──RZ(a)──GlobalPhase(-a/2)─┤ ≅ ──RZ(a)──┤,

where we used \cong to express equality up to a global phase. Note that qml.GlobalPhase comes with a negative sign convention and R_Z(\phi) = \exp(-i\tfrac{1}{2} \phi Z).

Controlled phase shift

If phase shifts need to be applied controlled by the state of some control qubits and we want to compile into R_Z gates, we need to pay attention to the global phases mentioned in the previous section. In turn, decomposing a (multi-) controlled global phase yields (smaller) controlled phase shifts. See the tab on controlled global phases for more details.

This leads to the following cascading decomposition into (controlled) R_Z gates, exemplified for two controls:

0: ──╭Rϕ(a)─┤ 1: ──├●─────┤ 2: ──╰●─────┤ = 0: ──╭RZ(a)─╭GlobalPhase(-a/2)─┤ 1: ──├●─────├●─────────────────┤ 2: ──╰●─────╰●─────────────────┤ = 0: ──╭RZ(a)───────────┤ 1: ──├●─────╭Rϕ(a/2)──┤ 2: ──╰●─────╰●────────┤ = 0: ──╭RZ(a)─────────────────────────────┤ 1: ──├●─────╭RZ(a/2)─╭GlobalPhase(-a/4)─┤ 2: ──╰●─────╰●───────╰●─────────────────┤ = 0: ──╭RZ(a)───────────────────┤ 1: ──├●─────╭RZ(a/2)──────────┤ 2: ──╰●─────╰●────────Rϕ(a/4)─┤ ≅ 0: ──╭RZ(a)───────────────────┤ 1: ──├●─────╭RZ(a/2)──────────┤ 2: ──╰●─────╰●────────RZ(a/4)─┤

As we can see, the seemingly harmless equivalence up to a global phase has a significant impact on the controlled decomposition if we represent it as (controlled) R_Z rotations. The actual impact on the gate count of course will depend on further decompositions of the controlled rotations.

"Flipped" phase shift

In many scenarios, we would like to apply a phase shift to the |0\rangle, rather than the |1\rangle state, which we call a "flipped" phase shift, R^0_\phi. Its matrix representation in the computational basis is

R^{0}_\phi(\phi) = \begin{pmatrix} e^{i\phi} & 0 \\ 0 & 1 \end{pmatrix}.

If we only have "generic" phase shifts available, we may decompose R^0_\phi by flipping the qubit before and after a "generic" shift with the same angle:

──Rϕ^0(a)─┤ = ──X──Rϕ(a)──X─┤.

In matrix representation, this equality reads

R^{0}_\phi(a) = \begin{pmatrix} e^{ia} & 0 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 0 & e^{ia} \end{pmatrix} \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = X R_\phi(a) X.

Alternatively, we may recognize that a phase shift really just affects the phases relative to each other, and write

──Rϕ^0(a)─┤ = ──Rϕ(-a)──GlobalPhase(-a)─┤ ≅ ──Rϕ(-a)──┤ ≅ ──RZ(-a)──┤.

In matrix representation, this equality reads

R^{0}_\phi(a) = \begin{pmatrix} e^{ia} & 0 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} e^{ia} & 0 \\ 0 & e^{ia} \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 0 & e^{-ia} \end{pmatrix} \cong R_{\phi}(-a).

Controlled "flipped" phase shifts

Finally, we combine the controlled phase shift logic from the beginning with the "flipped" phase shifts discussed just above.

For simplicity, we start with a single control qubit controlling a "flipped" phase shift on its |1\rangle state:

0: ──╭●───────┤ 1: ──╰Rϕ^0(a)─┤.

The explicit bit flip decomposition from above naively would lead to the circuit

0: ──╭●───────┤ = 0: ──╭●──╭●─────╭●─┤ 1: ──╰Rϕ^0(a)─┤ 1: ──╰X──╰Rϕ(a)─╰X─┤.

However, we may apply the controlled compute/uncompute simplification to reduce the circuit to

0: ──╭●───────┤ = 0: ─────╭●────────┤ 1: ──╰Rϕ^0(a)─┤ 1: ──X──╰Rϕ(a)──X─┤.

If we use the second decomposition from above, we arrive at

0: ──╭●───────┤ = 0: ──╭●───────╭●───────────────┤ = 0: ──╭●───────Rϕ(a)─┤ 1: ──╰Rϕ^0(a)─┤ 1: ──╰Rϕ(-a)──╰GlobalPhase(-a)─┤ 1: ──╰Rϕ(-a)────────┤,

which requires a second parametrized gate. Note that if we decompose to R_Z gates as we did above, we find for the two decompositions

0: ──╭●───────┤ ≅ 0: ─────╭●──────RZ(a/2)─┤ 1: ──╰Rϕ^0(a)─┤ 1: ──X──╰RZ(a)──X───────┤,

and

0: ──╭●───────┤ ≅ 0: ──╭●───────RZ(a/2)─┤ 1: ──╰Rϕ^0(a)─┤ 1: ──╰RZ(-a)──────────┤,

respectively. Those are equivalent because the controlled R_Z gate will simply flip the sign of its angle when pulling a Pauli X gate through its target.

PennyLane

PennyLane is an open-source software framework for quantum machine learning, quantum chemistry, and quantum computing, with the ability to run on all hardware. Built with ❤️ by Xanadu.

Stay updated with our newsletter

For researchers

  • Research
  • Features
  • Demos
  • Compilation
  • Datasets
  • Performance
  • Learn
  • Videos
  • Documentation
  • Teach

For learners

  • Learn
  • Codebook
  • Teach
  • Videos
  • Challenges
  • Demos
  • Compilation
  • Glossary

For developers

  • Features
  • Documentation
  • API
  • GitHub
  • Datasets
  • Demos
  • Compilation
  • Performance
  • Devices
  • Catalyst

© Copyright 2025 | Xanadu | All rights reserved

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.

Privacy Policy|Terms of Service|Cookie Policy|Code of Conduct