PennyLane
Install
Install
  1. Compilation/
  2. Efficient Adjoint Operations

Efficient Adjoint Operations

OverviewDetailsAdjoint QROMResources

Quantum Read-Only Memory (QROM) is a method to load a classical dataset into a quantum data register using an index register and possibly an auxiliary register. General implementations, including SelectSwap, can use many multicontrolled gates.

Here, the adjoint QROM can be implemented as in Figure 1 if the b-qubit data register must be set to be |0\rangle afterwards [2]. The n-qubit index register is unchanged. Observe that the multicontrolled gates are replaced by Hadamards, measurements, and a diagonal correction \Delta. Therefore, the adjoint QROM would be cheaper to implement. This is analogous to the previous example of the adjoint Elbow implemented without T gates if the target qubit must be set to |0\rangle afterwards.

Definition of adjoint QROM with measurements

Figure 1. Implementation of adjoint QROM with only Hadamards, measurements, and a diagonal correction matrix, \Delta, assuming the b-qubit data register must become state |0\rangle. \Delta represents a diagonal correction matrix consisting of \pm 1 terms on the diagonal.

Definitions of QROM and adjoint QROM

By definition, the index register contains n qubits while the data register contains b qubits. Given an arbitrary initial state \sum_i \alpha_i |i\rangle_{\text{index}} |0\rangle_{\text{data}}, the action of QROM is:

\mathrm{QROM}(\sum_i \alpha_i |i\rangle_{\text{index}} |0\rangle_{\text{data}}) = \sum_i \alpha_i |i\rangle_{\text{index}} |\phi_i\rangle_{\text{data}},

where |\phi_i\rangle is the i^{\text{th}} bitstring that we wish to load.

Then, adjoint QROM performs the reverse operation to ensure the data register is finally |0\rangle.

Here, we shall confirm that there exists a diagonal \Delta such that the circuit in Figure 1 is equivalent to adjoint QROM i.e., the target qubits are reset to |0\rangle.

Step-by-step walkthrough of the circuit

At a high level, this particular measurement-based adjoint QROM circuit applies Hadamard gates to the data register qubits that we then reset to |0\rangle with measurements and X gates, as needed. This potentially introduces a -1 phase error along elements of the diagonal of the control (i.e., index) qubits of QROM. We correct those errors by applying a diagonal \Delta matrix.

Applying the Hadamards

Given the initial state \sum_i \alpha_i |i\rangle_{\text{index}} |\phi_i\rangle_{\text{data}} , applying Hadamard gates to the data register yields:

\sum_i \alpha_i |i\rangle_{\text{index}} \Bigg( \frac{1}{\sqrt{2^b}} \sum_ x (-1)^{\phi_i \odot x} |x\rangle_{\text{data}} \Bigg),

where \odot represents bitwise multiplication such that v \odot u = v_0 u_0 \oplus v_1 u_1 \oplus \dots \oplus v_{n-1}u_{n-1}, and \oplus represents the XOR operation, or addition modulo 2. For example:

1101 \odot 0101 = (1 \times 0)\oplus (1\times 1)\oplus (0\times 0) \oplus (1\times 1) = 0\rightarrow (-1)^{1101 \odot 0101} = +1

Indeed, when the 4-qubit Hadamard is applied to the state |1101\rangle, the output of the |0101\rangle basis is +1 before normalisation.

Resetting target qubits to |0\rangle

After measuring, we are going to get a bitstring |y\rangle from the data qubits, and the state will collapse to:

\sum_i \alpha_i (-1)^{\phi_i \odot y} |i\rangle_{\text{index}} |y\rangle_{\text{data}}.

Knowing the bitstring |y\rangle, it is straightforward to classically apply X gates to reset the data register to |0\rangle.

Correcting any -1 phase error

The goal is to end up with the state \sum_i \alpha_i |i\rangle_{\text{index}} |0\rangle_{\text{data}}. However, we observe that the above equation contains coefficients of the form (-1)^{\phi_i \odot y}, which can only be \pm 1. To eliminate those -1 phases, we apply a diagonal matrix \Delta consisting of \pm 1 terms. The result is the desired outcome state.

PennyLane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Built by researchers, for research. Created with ❤️ by Xanadu.

Research

  • Research
  • Performance
  • Hardware & Simulators
  • Demos
  • Compilation Hub
  • Quantum Datasets

Education

  • Teach
  • Learn
  • Codebook
  • Coding Challenges
  • Videos
  • Glossary

Software

  • Install PennyLane
  • Features
  • Documentation
  • Catalyst Compilation Docs
  • Development Guide
  • API
  • GitHub
Stay updated with our newsletter

© Copyright 2026 | 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