workbench_algorithms.experimental.subroutines.state_preparation
Subpackage for experimental state prep qubricks.
AliasSampling
Bases: Qubrick
Qubrick for implementing alias sampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qrom
|
QROM
|
Data lookup instance. |
required |
usp
|
UniformStatePreparation
|
Uniform state preparation instance. |
required |
lambda_val
|
int
|
SEL-SWAP tunable parameter for QROM, default to None where optimal lambda (based on Toffoli counts) is calculated |
None
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the init. |
{}
|
compute
compute(
psi: Qubits,
data: StatePrepDataInterface,
ctrl: Qubits | int = 0,
*,
usp_rotator: Qubits | None = None,
coin_toss_reg: Qubits | None = None,
)
State preparation by alias sampling.
Note
Uses the circuit in Fig. 11 of arXiv:1805.03662 <https://arxiv.org/abs/1805.03662>_.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
Qubits
|
Register to prepare coefficients onto. |
required |
data
|
StatePrepDataInterface
|
a data storage interface that hold all the classical precomputation numbers |
required |
ctrl
|
Qubits | int
|
Control register. |
0
|
usp_rotator
|
Qubits | None
|
Qubit to rotate as part of USP. Needs to be supplied if this Qubrick is used with a coherent uncomputation (such as in LCU), but will be allocated on the fly if not supplied. |
None
|
coin_toss_reg
|
Qubits | None
|
Qubits register used to load the coin toss state (uniform state) in for the alias sampling protocol. Needs to be supplied if this Qubrick is used with a coherent uncomputation (such as in LCU), but will be allocated on the fly if not supplied. |
None
|
ArbitraryStatePrep
ArbitraryStatePrep(
amplitude_prep: AmplitudePreparation,
phase_prep: PhasePreparation | None = None,
**kwargs,
)
Bases: Qubrick
Qubrick for preparing states with arbitrary coefficients.
The strategy used is straightforward: first we prepare the amplitudes for the state such that the probabilities for each basis state are correct, then we prepare the phases to get the full state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amplitude_prep
|
AmplitudePreparation
|
Qubrick to prepare the amplitudes for the state. |
required |
phase_prep
|
PhasePreparation | None
|
Qubrick to prepare the phases given the amplitudes have already been prepared. |
None
|
kwargs
|
dict[str, Any]
|
Other key word arguments to pass to the constructor. |
{}
|
compute
Compute the arbitrary state prep.
Note
This Qubrick makes no assumptions about how the amplitudes and phases are prepared and so all data processing is delegated to those Qubricks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
Qubits
|
Register to prepare the state on. |
required |
data
|
StatePrepDataInterface
|
Dataclass encoding the specification of the state. |
required |
ctrl
|
Qubits | int
|
Register to control the state preparation. |
0
|
FlattenedRotArray
Bases: Qubrick
Implements a state sub-preparation using a single set of multiplexed rotations.
Note
- This only works with PHASE ops, so can only be used for a phase fixup, and can't be used with the Gray code multiplexor, which relies on the structure of RZ gates to work.
- There is no global phase correction to do with this Qubrick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mplxr
|
MultiplexedRotations
|
The Qubrick that will implement the individual multiplexed rotations |
required |
kwargs
|
dict[str, Any]
|
Other key word arguments to pass to the constructor. |
{}
|
compute
Compute the multiplexor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
Qubits
|
The qubits to apply the rotations onto. |
required |
data
|
StatePrepDataInterface
|
A dataclass encoding the rotation data |
required |
ctrl
|
Qubits | int
|
Qubits to control the operation on. |
0
|
MultiplexedRotationData
dataclass
MultiplexedRotationData(
opcode: str,
angles: Iterable[float],
epsilon: float,
bits_of_precision: int | None = None,
)
Data class for handling data for multiplexed rotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opcode
|
str
|
Encodes the type of rotation op to be applied, one of |
required |
angles
|
Iterable[float]
|
The list of rotation angles to be applied. |
required |
epsilon
|
float
|
The accuracy that the multiplexed rotations are to be applied to. |
required |
bits_of_precision
|
int | None
|
For QROM-based multiplexors, the number of bits of precision to be used in the rotations. |
None
|
ProgrammableRotArray
Bases: Qubrick
Implements a state sub-preparation using a cascade of uniformly controlled rotations.
Essentially, it is a data storage "terminology" coined by this microsoft paper (see appendix VII, section B, subsection 1) where we need a 2D array of angles (each row of size 1, 2, 4, 8, ...), similar to the multiplexed Givens rotation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op
|
SupportedOps
|
Encodes the type of rotation op to be applied, one of |
required |
mplxr
|
MultiplexedRotations
|
The Qubrick that will implement the individual multiplexed rotations |
required |
fix_global_phase
|
bool
|
Whether to fix up the global phase (for statevector validation) or prepare the state up to global phase. This correction is always applied when the Qubrick is controlled. |
False
|
kwargs
|
dict[str, Any]
|
Other key word arguments to pass to the constructor. |
{}
|
ProgrammableRotArrayData
dataclass
ProgrammableRotArrayData(
opcode: str,
coefficients: Iterable[float],
epsilon: float,
_bits_of_precision: int | None = None,
)
Data class for handling data for multiplexed rotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opcode
|
str
|
Encodes the type of rotation op to be applied, one of |
required |
coefficients
|
Iterable[float]
|
The coefficients of the state to be loaded. |
required |
epsilon
|
float
|
The accuracy that the multiplexed rotations are to be applied to. |
required |
_bits_of_precision
|
int | None
|
Override the default bits of precision argument with a custom value. NOTE: this may result in loss of fidelity if the value is not chosen carefully - users are recommended to leave this unset unless they know what they are doing. |
None
|