Performs the operators \(R_A\) or \(R_B\). For more information on these operators check the paper.


Depending on the parameter, the diffuser acts on the subspaces \(\mathcal H_x=\{\ket{x}\}\cup\{\ket{y}\,|\,x\rightarrow y\}\) where \(x\) has odd (even=False) or even (even=True) height. Note that “even” refers to the parity of the h attribute instead of the distance from the root. If the max_depth of the tree is odd, and even=False then \(R_A\) (otherwise \(R_B\)) is performed, and vice verse if the max_depth is even.

ctrlList[Qubit], optional

A list of qubits that allows performant controlling. The default is [].


We set up a QuantumBackTrackingTree and perform the diffuser on a marked node

from qrisp import auto_uncompute, QuantumBool, QuantumFloat
from qrisp.quantum_backtracking import QuantumBacktrackingTree

def reject(tree):
    return QuantumBool()

def accept(tree):
    return (tree.h == 1)

tree = QuantumBacktrackingTree(3, QuantumFloat(
    1, name = "branch_qf*"), accept, reject)

>>> print(tree.qs.statevector())
>>> tree.qstep_diffuser(even = False)
>>> print(tree.qs.statevector())

We see that the node (as expected) is invariant under \(R_A\).