Skip to content

workbench_algorithms.subroutines.naive_state_prep

Functions for naïve state preparation.

EfficientMultiplexedRotations

EfficientMultiplexedRotations(
    gate=None, angles=None, **kwargs
)

Bases: Qubrick

Decomposition of uniformly controlled rotations to single qubit rotation + CNOTs.

Corresponds to Figure 2 in arXiv:0407010 .

Parameters:

Name Type Description Default
gate op or None

Rotation gate type to use in multiplexed rotations. Defaults to None.

None
angles list or None

List of angles to supply to rotations. Defaults to None.

None
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(index_reg, tgt, ctrl: int = 0, **kwargs) -> None

Compute the multiplexed rotation.

Parameters:

Name Type Description Default
index_reg Qubits / int

Index qubits.

required
tgt Qubits / int

Target qubit.

required
ctrl (Qubits, int)

A register to control this operation on. Default to 0.

0
**kwargs dict[str, Any]

Other arguments to pass to the compute.

{}

set_gate

set_gate(gate) -> None

Choose which unitary to multiplex (qc.op function).

set_angles

set_angles(angles) -> None

Choose angles for multiplexed unitaries (list).

NaiveMultiplexedRotations

NaiveMultiplexedRotations(gate=None, angles=None, **kwargs)

Bases: Qubrick

Controlled rotations from arXiv:0407010 .

Parameters:

Name Type Description Default
gate op or None

Rotation gate type to use in multiplexed rotations. Defaults to None.

None
angles list or None

List of angles to supply to rotations. Defaults to None

None
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(index_reg, tgt, ctrl: int = 0, **kwargs) -> None

Compute the multiplexed rotation.

Parameters:

Name Type Description Default
index_reg Qubits / int

Index qubits.

required
tgt Qubits / int

Target qubit.

required
ctrl (Qubits, int)

A register to control this operation on. Default to 0.

0
**kwargs dict[str, Any]

Other arguments to pass to the compute.

{}

set_gate

set_gate(gate) -> None

Choose which unitary to multiplex (qc.op function).

set_angles

set_angles(angles) -> None

Choose angles for multiplexed unitaries (list).

ArbitraryStatePrep

ArbitraryStatePrep(amps, multiplexor=None, **kwargs)

Bases: Qubrick

State preparation based on the routine in arXiv:quant-ph/0407010v1 .

Realizes:

\[ \text{PREP}\ket{0} \rightarrow \frac{\sum_i a_i}{\sum_i|a_i|^2}\ket{i} \]
Note

This routine prepares the desired state up to a global phase. When checking the validity of this routine, one should check fidelity rather than exact state vector matching. The other consequence is that controlling this routine will lead to (incorrect) relative phases.

Parameters:

Name Type Description Default
multiplexor (Qubrick, None)

Which multiplexing scheme to use in state prep. Defaults to NaiveMultiplexedRotations().

None
amps list or None

List of amplitudes to load into state.

required
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

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

Compute the arbitrary state preparation circuit.

Parameters:

Name Type Description Default
qbits Qubits

Qubits to operate on.

required
ctrl Qubits or int

Register to control the on. Defaults to 0.

0
**kwargs dict[str, Any]

Other arguments to pass to the compute.

{}

set_angles

set_angles(y_angles, z_angles=None) -> None

Set angles if none computed. Z angles defaults to None.

PrepareNaive

PrepareNaive(coeffs, multiplexor=None, **kwargs)

Bases: Qubrick

State preparation based on the routine in arXiv:quant-ph/0407010v1 .

Realizes:

\[\text{PREP}\ket{0} \rightarrow \frac{\sum_i \sqrt{a_i}}{\sum_i|a_i|}\ket{i}\]
Warning

This function only works for real and positive coefficients

Parameters:

Name Type Description Default
multiplexor Qubrick

Which multiplexing scheme to use in state prep. Defaults to NaiveMultiplexedRotations().

None
coeffs list or None

List of coefficients to load into state.

required
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

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

Compute the state preparation circuit.

Parameters:

Name Type Description Default
qbits Qubits

Qubits to operate on.

required
ctrl (Qubits, int)

A register to control this operation on. Default to 0.

0
**kwargs dict[str, Any]

Other arguments to pass to the compute.

{}

set_angles

set_angles(y_angles) -> None

Set angles if none computed.