Skip to content

workbench_algorithms.subroutines.qpe_window_functions

Module containing Qubricks for window functions.

RectWindow

RectWindow(**kwargs)

Bases: Qubrick

Rectangular/Dirichlet window. This is the default window function for the textbook QPE.

compute

compute(
    phase_reg: Qubits, ctrl: Qubits | int = 0, **kwargs
)

Executes circuit for implementing rectangular window.

Parameters:

Name Type Description Default
phase_reg Qubits

Phase qubit register

required
ctrl (Optional, int, Qubits)

Control register

0
**kwargs dict[str, Any]

Optional positional arguments. Included to stay consistent with the arguments of window emulators.

{}

CosineWindow

CosineWindow(adder: Adder | None = None, **kwargs)

Bases: Qubrick

Cosine window from arxiv:2110.09590 .

compute

compute(
    phase_reg: Qubits, ctrl: Qubits | int = 0, **kwargs
)

Executes circuit for implementing cosine window.

Parameters:

Name Type Description Default
phase_reg Qubits

Phase qubit register

required
ctrl (Optional, int, Qubits)

Control register

0
**kwargs dict[str, Any]

Optional keyword arguments. Included to stay consistent with the arguments of window emulators.

{}

SineWindow

SineWindow(**kwargs)

Bases: Qubrick

Qubrick for window state with the sine function over the amplitudes.

This window state can be used to achieve an optimal Holevo variance as outlined in Section II B. of arxiv:1805.03662 . See \(\Xi_m\) state.

Note

The state prepared here has a global phase of pi. Additionally, if the user does not care about having purely real or purely imaginary values in the prepared state, the rz gates can be replaced by phase gates in which case the magnitudes will be the same as the expected state, but each amplitude will be rotated by some (global) phase.

compute

compute(
    target_reg,
    flag_reg,
    ctrl: int = 0,
    use_real_amps: bool = False,
    **kwargs,
) -> None

Computes sine window function.

Parameters:

Name Type Description Default
target_reg Qubits

register on which the sine window state is prepared

required
flag_reg Qubits

flag qubit when 0, the sine window state is prepared

required
ctrl Qubits

control qubit

0
use_real_amps bool

If True, prepares real amplitudes

False
**kwargs dict[str, Any]

Optional keyword arguments

{}
Note
  • Needs a round of amplitude amplification.

SineWindowPhaseCatalysis

SineWindowPhaseCatalysis(**kwargs)

Bases: Qubrick

Qubrick for window state with the sine function over the amplitudes.

Prepared via phase catalyst register.

This window state can be used to achieve an optimal Holevo variance as outlined in Section II B. of arxiv:1805.03662 . See \(\Xi_m\) state.

The phase catalyst implementation is outlined in Appendix B of arxiv:1805.03662

Note

The state prepared here will be the same as SineWindow up to a global phase.

compute

compute(
    target_reg: Qubits,
    flag_reg: Qubits,
    ctrl: Qubits | int = 0,
    **kwargs,
)

Computes sine window function via phase catalyst state.

Note
  • Needs a round of amplitude amplification.

SineWindowQubitEfficient

SineWindowQubitEfficient(**kwargs)

Bases: Qubrick

Qubrick for window state with the sine function over the amplitudes using only two active qubits at a time.

This window state can be used to achieve an optimal Holevo variance with the construction of the circuit outlined in Section IV of arxiv:2303.12505.

compute

compute(
    phase_reg: Qubits, ctrl: Qubits | int = 0, **kwargs
)

Computes sine window function.

Parameters:

Name Type Description Default
phase_reg Qubits

phase qubit register

required
ctrl (Optional, int, Qubits)

control register

0
**kwargs dict[str, Any]

optional keyword arguments

{}

WindowStatePrep

WindowStatePrep(amps, state_prep=None, **kwargs)

Bases: Qubrick

General class for simulating window state via state prep.

Parameters:

Name Type Description Default
amps ndarray

Amplitudes for window state.

required
state_prep Qubrick

Qubrick to implement the state preparation for the window function.

None
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(
    phase_reg: Qubits, ctrl: Qubits | int = 0, **kwargs
)

Executes circuit for preparing window state.

Parameters:

Name Type Description Default
phase_reg Qubits

Phase qubit register.

required
ctrl (Optional, int, Qubits)

Control register.

0
**kwargs dict[str, Any]

Optional keyword arguments. Included to stay consistent with the arguments of window emulators.

{}

WindowEmulator

WindowEmulator(
    emulator_func: Callable[Concatenate[int, P], NDArray],
    emulator_function_options: dict[str, Any] | None = None,
    **kwargs,
)

Bases: Qubrick

Constructor for window emulator.

Note
  • Check the window utils module for emulator_func options.
  • Note that this Qubrick does not execute quantum operations; it directly touches the state vector and is not meant to run on a real QPU program.

Parameters:

Name Type Description Default
emulator_func callable

method for computing amplitudes of a window state

required
emulator_function_options dict[str, Any]

Extra keyword arguments for the emulator_func

None
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(phase_reg, psi, ctrl: int = 0, **kwargs) -> None

Compute amplitudes of taper state.

Note

Assumes Qubits in QC are ordered as: (1) Psi (2) Phase Register (3) All other qubits

Parameters:

Name Type Description Default
phase_reg Qubits

Phase qubit register

required
psi Qubits

System register

required
ctrl (Optional, int, Qubits)

Control register

0
**kwargs dict[str, Any]

Optional keyword arguments. Included to stay consistent with the arguments of window emulators.

{}
Note
  • Use emulators for a reasonably small number of phase qubits!
  • The control version is not currently implemented

uncompute

uncompute() -> None

Override the default uncomputation.