workbench_algorithms.subroutines.uniform_state_prep
Qubricks for uniform state preparation.
USP
Bases: Qubrick
Qubrick for performing Uniform State Preparation.
From Fig. 12 in "Encoding Electronic Spectra in Quantum Circuits with Linear T Complexity" (arXiv:1805.03662).
compute
Prepare a uniformly distributed state.
Conceptually, starts by factoring \(d = 2^k L\), although this explicit calculation has been replaced by
the num_trailing_zeros and highest_bit functions for better performance.
Just applying Hadamard gates creates the desired equal superposition over k of the qubits.
For the remaining qubits we need to also perform amplitude amplification to keep only basis states with value < d.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
int
|
Desired number of uniform terms. |
required |
target_qreg
|
Qubits
|
The register to operate on. |
required |
error_param
|
float
|
Parameter determining the accuracy of truncated rotation
angles. If |
None
|
ctrl
|
Qubits or int
|
Register to control the USP on. Defaults to |
0
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the compute. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the register passed in is too small. |
Note
The effect of setting various default args has not been tested. Creates desired state up to global phase.
ZeroAncillaUSP
Bases: Qubrick
Qubrick for performing Uniform State Preparation without auxiliary qubits.
Adapted from "An efficient quantum algorithm for preparation of uniform quantum superposition states" (arxiv:2306.11747).
compute
Prepare a uniformly distributed state.
Utilizes binary decomposition of \(d\), controlled Ry and Hadamard gates to avoid auxiliary qubit usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
int
|
Desired number of uniform terms. |
required |
target_qreg
|
Qubits
|
The register to operate on. |
required |
ctrl
|
Qubits or int
|
Register to control the USP on. Defaults to |
0
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the compute. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the register passed in is too small. |
RealUSP
Bases: Qubrick
Qubrick for performing Uniform State Preparation.
From "Even more efficient quantum computations of chemistry through tensor hypercontraction" (arxiv:2011.03494).
Note
- This is the version based on the instructions (steps 1-7) under Eq. A15 of Appendix A.
- A circuit diagram showing a similar implementation (but over two target registers) is shown in Fig. (3).
compute
compute(
d,
target_qreg,
rotator=None,
succ_reg=None,
error_param=None,
ctrl: int = 0,
**kwargs,
) -> None
Prepare a uniformly distributed state.
Conceptually, starts by factoring \(d = 2^k L\), although this explicit calculation has been replaced by
the num_trailing_zeros and highest_bit functions for better performance.
Just applying Hadamard gates creates the desired equal superposition over k of the qubits.
For the remaining qubits we need to also perform amplitude amplification to keep only basis states with value < d.
Utilizes one auxiliary qubit, the 'rotator', such that CZ gates perform the required reflections.
This routine uses RY rotations, resulting in only real amplitudes.
If no error_param is provided, the rotations are treated as ideal and the probability of success is 1.0.
If an error_param is provided, the probability of success will be <=1.0 and a flag qubit will store the result via a comparator.
This qubit can be optionally provided via succ_reg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
int
|
The number of nonzero terms required. |
required |
target_qreg
|
Qubits
|
The register to operate on. |
required |
rotator
|
Qubits
|
Register to perform rotation on. Defaults to |
None
|
succ_reg
|
Qubits
|
Qubit to herald success. Defaults to |
None
|
error_param
|
float
|
Parameter determining the accuracy of truncated rotation
angles. If |
None
|
ctrl
|
Qubits or int
|
Register to control the USP on. Defaults to |
0
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the compute. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the register passed in is too small. |
Note
The effect of setting various default args has not been tested.