Skip to content

workbench_algorithms.subroutines.amplitude_amplification

Qubricks for implementing amplitude amplification.

AmplitudeAmplifiedQubrick

AmplitudeAmplifiedQubrick(
    base_qubrick: Qubrick,
    init_refl: Qubrick,
    good_refl: Qubrick,
    fixed_point: bool = False,
    eps: float = 0.001,
    use_radians: bool = False,
    **kwargs,
)

Bases: Qubrick

Performs amplitude amplification on the input Qubrick to provide an "amplified" Qubrick.

This Qubrick is intended to be used as a wrapper around a base Qubrick along with Amplitude Amplification (the AmpAmp Qubrick) in order to produce an amplitude amplified version of the base Qubrick.

Parameters:

Name Type Description Default
base_qubrick Qubrick

The base qubrick to be amplified.

required
init_refl Qubrick

Reflection about the initial state.

required
good_refl Qubrick

Reflection about the good (target) state.

required
fixed_point bool

Whether to use fixed point amplitude amplification rather than vanilla amplitude amplification. Defaults to False.

False
eps float

Desired error \(\epsilon\) such that \(|\langle\psi_{f}|\psi_{targ}\rangle|^2 \geq 1 - \epsilon\). Needed to calculate the fixed point rotation angles, not necessary for vanilla amp amp. Defaults to 1e-3.

0.001
use_radians bool

(Deprecated) True if angles in Radians

False
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(
    sys_reg: Qubits,
    p_succ: float,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the base qubrick along with amplitude amplification.

Parameters:

Name Type Description Default
sys_reg Qubits

Main register the computation is performed on.

required
p_succ float

The initial probability of obtaining the "good" state. If fixed_point is set in the initalizer, this can be a lower bound on the success probability, if not it must be the exact success probability.

required
ctrl int | Qubits

Register the amplitude amplification is controlled on. Defaults to 0.

0
**kwargs dict[str, Any]

Optional arguments that may be passed on to the AmpAmp Qubrick, reflection Qubricks, or the base Qubrick.

{}

Other Parameters:

Name Type Description
be_ancilla_reg Qubrick

Block encoding register.

data PauliSum or List[int]

Data for select qubricks.

AmpAmp

AmpAmp(
    init_refl: Qubrick,
    good_refl: Qubrick,
    fixed_point: bool = False,
    eps: float = 0.001,
    use_radians: bool = False,
    **kwargs,
)

Bases: Qubrick

Performs amplitude amplification to boost the amplitude of a desired outcome.

Amplitude amplification takes two reflections: a "good" reflection about a target state \(|\psi_{\text{good}}\rangle\) and a "starting" reflection about the state \(|\psi_{0}\rangle\) that forms the starting point of the routine. If the starting state \(|\psi_0\rangle\) is prepared with some (potentially low) overlap with the target state \(|\psi_{\text{good}}\rangle\), repeatedly applying these two reflections \(\mathcal{O}(1/\sqrt{p})\) times should result in a final state which has \(\Omega(1)\) overlap with the target state.

These reflections can't be made blindly: if you pick a number of iterations that is too small, you "undercook" the state, and if you pick a number that is too high, you "overcook" the state, leading to low fidelities in both cases. The optimal number of iterations depends on the initial success probability p_succ, which you may or may not know a priori. AmpAmp requires p_succ to be passed as an argument in order to calculate the number of rounds needed and provides provision for two scenarios:

  1. If you know p_succ exactly a priori, you can realize the good state deterministically following the procedure in "Quantum Amplitude Amplification and Estimation" (arXiv:quant-ph/0005055).
  2. If you don't know p_succ, we can use fixed point amplitude amplification (the Workbench Algorithms implementation follows "Fixed-point quantum search with an optimal number of queries" (arXiv:1409.3305) along with a lower bound on the success probability as p_succ. Unlike vanilla AA, fixed point AA is guaranteed to succeed for any number of iterations greater than some threshold (calculated from the lower bound on the success probability). Thus, while it may use more resources than necessary, it is useful for when we can't determine p_succ exactly.
Note

The reflections that are passed to this Qubrick are entirely general - they may have additional parameters that need to be passed to them. These parameters can be passed through the kwargs as if the AmpAmp Qubrick has those parameters. For example, if you have a block encoding unitary which takes be_ancilla_reg as an argument, you can do AmpAmp(init_refl, good_refl).compute(sys_reg, p_succ, be_ancilla_reg=be_ancilla_reg).

Parameters:

Name Type Description Default
init_refl Qubrick

Reflection about the initial state.

required
good_refl Qubrick

Reflection about the good (target) state.

required
fixed_point bool

Whether to use fixed point amplitude amplification rather than vanilla amplitude amplification. Defaults to False (vanilla).

False
eps float

Desired error \(\epsilon\) such that \(|\langle\psi_{f}|\psi_{targ}\rangle|^2 \geq 1 - \epsilon\). Needed to calculate the fixed point rotation angles; not necessary if you use vanilla amplitude amplification. Defaults to 1e-3.

0.001
use_radians bool

(Deprecated) True if angles in Radians

False
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(
    sys_reg: Qubits,
    p_succ: float,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the amplitude amplification.

Parameters:

Name Type Description Default
sys_reg Qubits

Main register the computation is performed on.

required
p_succ float

The initial probability of obtaining the "good" state. If fixed_point is set in the initalizer, this can be a lower bound on the success probability, if not it must be the exact success probability.

required
ctrl int | Qubits

Register the amplitude amplification is controlled on. Defaults to 0.

0
**kwargs dict[str, Any]

Optional arguments that may be passed on to the reflection qubricks.

{}

Other Parameters:

Name Type Description
be_ancilla_reg Qubrick

Block encoding register.

data PauliSum or List[int]

Data for select qubricks.

GoodReflectionBlockEncoding

GoodReflectionBlockEncoding(**kwargs)

Bases: Qubrick

Reflection about a block encoded good state (i.e., all block encoding auxiliary qubits in \(\ket{0}\)).

Implements the reflection

\((I - (1 - e^{i\phi})|0^m\rangle\langle 0^m|)\)

Note

See references "Quantum Amplitude Amplification and Estimation" (arXiv:quant-ph/0005055) and "Fixed-point quantum search with an optimal number of queries" (arXiv:1409.3305) for details.

compute

compute(
    sys_reg: Qubits,
    ancillae: Qubits,
    angle: float = 180,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the reflection.

Parameters:

Name Type Description Default
sys_reg Qubits

Qubits register defining the system. Included to maintain compatibility with other Qubricks.

required
ancillae Qubits

Auxiliary qubits used to block encode the matrix.

required
angle float

Angle about which the generalized reflection is performed.

180
ctrl int | Qubits

Qubits to control the reflection on. Defaults to 0.

0
**kwargs dict[str, Any]

Additional keyword arguments included to maintain compatibility with other reflections.

{}

InitReflectionFromUnitary

InitReflectionFromUnitary(unitary, **kwargs)

Bases: Qubrick

Reflection about the initial state given a unitary that prepares that state.

Parameters:

Name Type Description Default
unitary Qubrick

Qubrick implementing the unitary that prepares the state to reflect about.

required
**kwargs dict[str, Any]

Other key word arguments to pass to the Qubrick constructor.

{}

compute

compute(
    sys_reg: Qubits,
    angle: float = 180,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the reflection.

Parameters:

Name Type Description Default
sys_reg Qubits

Register on which the state is prepared.

required
angle float

Angle about which the generalized reflection is performed, in degrees.

180
ctrl int | Qubits

Qubits to control the reflection on. Defaults to 0.

0
**kwargs dict[str, Any]

Additional keyword arguments included to maintain compatibility with other reflections.

{}

InitReflectionBlockEncoding

InitReflectionBlockEncoding(unitary, **kwargs)

Bases: Qubrick

Reflection about the initial state given a unitary that prepares that state.

Parameters:

Name Type Description Default
unitary Qubrick

Qubrick implementing the unitary to reflect about.

required
**kwargs dict[str, Any]

Other key word arguments to pass to the Qubrick constructor.

{}

compute

compute(
    sys_reg: Qubits,
    angle: float = 180,
    ancillae: int | Qubits = 0,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the reflection.

Parameters:

Name Type Description Default
sys_reg Qubits

Register on which the state is prepared.

required
angle float

Angle about which the generalized reflection is performed, in degrees.

180
ancillae int | Qubits

Ancillae used to facillitate the implementation of the state. Defaults to 0.

0
ctrl int | Qubits

Qubits to control the reflection on. Defaults to 0.

0
**kwargs dict[str, Any]

Additional keyword arguments included to maintain compatibility with other reflections.

{}

GroverDiffuser

GroverDiffuser(**kwargs)

Bases: Qubrick

Qubrick for Grover diffuser (reflection about the mean).

compute

compute(
    sys_reg: Qubits,
    angle: float = 180,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the reflection.

Parameters:

Name Type Description Default
sys_reg Qubits

Register on which the state is prepared.

required
angle float

Angle about which the generalized reflection is performed, in degrees.

180
ctrl int | Qubits

Qubits to control the reflection on. Defaults to 0.

0
**kwargs dict[str, Any]

Additional keyword arguments included to maintain compatibility with other reflections.

{}

GoodReflectionGrover

GoodReflectionGrover(good_state: str, **kwargs)

Bases: Qubrick

Qubrick for reflecting about a good state in Grover.

Parameters:

Name Type Description Default
good_state str

Binary representation of the good state as the basis state, e.g. '101'

required
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(
    sys_reg: Qubits,
    angle: float,
    ctrl: int | Qubits = 0,
    **kwargs,
)

Compute the reflection.

Parameters:

Name Type Description Default
sys_reg Qubits

Register on which the state is prepared.

required
angle float

Angle about which the generalized reflection is performed, in degrees.

required
ctrl int | Qubits

Qubits to control the reflection on. Defaults to 0.

0
**kwargs dict[str, Any]

Additional keyword arguments included to maintain compatibility with other reflections.

{}