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

Control logic decompositions

OverviewCompute/uncomputeGlobal phasesPhase shiftsLCU(QSVT)Resources

In quantum algorithms, a very common primitive is to apply a subroutine controlled by the state of specific control qubit(s). A generic way to do this is to decompose the subroutine, and apply each constituent of the decomposition controlled by the control qubit(s). Frequently, a subroutine or its decomposition contain a global phase, i.e., a phase applied to all states of the system in the same manner. While a global phase does not have any impact on a quantum computation using the subroutine itself (because it doesn't affect the measurement outcomes), it becomes relevant if the routine is applied in a controlled manner, because this causes the phase to become local, and thus yields a relative phase shift between states of the control qubit(s).

Example

If we denote equality of a circuit up to a global phase by \cong, we may express this as

0: ───GlobalPhase(a)─┤ ≅ 0: ───┤.

The core statement of this decomposition for a single control qubit is then as follows:

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

Note that qml.GlobalPhase comes with a negative sign convention, so that we have to introduce a minus sign for the qml.PhaseShift. For multiple control qubits, any of the controls can be chosen as target, and the remaining controls are applied to the phase shift instead:

0: ──╭GlobalPhase(a)─┤ = 0: ──────────┤ = 0: ──────────┤ = 0: ──────────┤ 1: ──├●──────────────┤ 1: ──╭Rϕ(-a)─┤ 1: ──╭●──────┤ 1: ──╭●──────┤ 2: ──├●──────────────┤ 2: ──├●──────┤ 2: ──├Rϕ(-a)─┤ 2: ──├●──────┤ 3: ──╰●──────────────┤ 3: ──╰●──────┤ 3: ──╰●──────┤ 3: ──╰Rϕ(-a)─┤

For controls on the off-state, or |0\rangle, the control state is inherited by the control nodes of the phase shift. When a control qubit controlled on |0\rangle is chosen as the target of the shift, it needs to be replaced by a flipped phase shift, R_\phi^{(0)}. Refer to the tab on controlled phase shifts for more.

Calculation

For a single control qubit, the equivalence between a controlled phase and a phase shift operator acting on the control qubit is shown in Fig. 4.5 of [2]. It is particularly convenient to calculate if we put the control qubit in the first place and compare the matrix of an operator U controlled on |1\rangle of that qubit to a phase shift operator, R_\phi:

c-U = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & U_{00} & U_{01} \\ 0 & 0 & U_{10} & U_{11} \end{pmatrix}\qquad R_\phi(\phi) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\phi} & 0 \\ 0 & 0 & 0 & e^{i\phi} \end{pmatrix}

As we can see, if U is a "global" phase, the two matrices match. The case for more control qubits follows from the fact that circuit identities continue to hold if we add the same control nodes to them on both sides. The case for control on the |0\rangle state simply exchanges the upper left identity matrix and the lower right "global" phase matrix in the comparison above. This is exactly what a flipped phase shift operator looks like.

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