guppyalgos.algorithms.select

SELECT algorithms for applying many operators controlled on index registers.

Functions

build_cntrl_select_unary_from_data(...[, ...])

Construct a unary iteration over unitaries constructed from Python data.

build_select_unary_from_data(data_input, ...)

Construct a unary iteration over unitaries constructed from Python data.

get_index_bools(n_index_qubits, ...)

Return the index boolean list.

select_unary_iteration(controlled_ops, ...)

Unary iteration select function.

Classes

SelectRotator()

Generic U_mu^dagger P U_mu selection around a QROM rotation.

class guppyalgos.algorithms.select.SelectRotator

Generic U_mu^dagger P U_mu selection around a QROM rotation.

The forward and inverse operations are supplied as two fully configured QROMRotations instances. Any shared quantum resource belongs to RotationRegs rather than either rotator, so the same register can be borrowed sequentially by both operations. The central Pauli action receives only the target stored in GivensCascadeRegs, making it independent of any resource used by the cascades.

pauli_action supplies the central operation on the selection controls and rotation target.

The index, QROM target, rotation, and control registers must own disjoint qubits. In particular, a controlled QROM flag belongs to IndexRegs, while the controls for the central Pauli action are passed separately. These controls must therefore be distinct for each configured selection operation.

Parameters:
  • qrom_rotations_compute – Fully configured QROM rotation that loads the selected data and applies the forward rotator.

  • pauli_action – Central controlled-Z or doubly-controlled-Z operation acting on the Pauli controls and the first rotation target.

  • qrom_rotations_uncompute – Fully configured inverse QROM rotation.

compose(index_regs, data_qregs, control_regs, rotation_regs)

Apply the configured QROM cascade, Pauli action, and inverse cascade.

Parameters:
  • index_regs – Registers used to address and optionally control the QROM.

  • data_qregs – QROM target registers holding the loaded rotation data.

  • control_regs – One or two qubits controlling the central Pauli action.

  • rotation_regs – Registers used by both rotators and the central Pauli action. These may include a shared phase-gradient resource.

pauli_action: Callable[[TypeVar(ControlRegs), TypeVar(RotationTargetRegs)], None]
qrom_rotations: QROMRotations[TypeVar(IndexRegs), TypeVar(TargetRegs), TypeVar(RotationTargetRegs), TypeVar(ComputeRotator, bound= Rotator[TypeVar(TargetRegs), TypeVar(RotationTargetRegs)])]
guppyalgos.algorithms.select.build_cntrl_select_unary_from_data(data_input, data_to_ctrl_op, comp_and_op=<function temp_and_compute>, uncomp_and_op=<function temp_and_uncompute>)

Construct a unary iteration over unitaries constructed from Python data.

Parameters:
Returns:

The unary iteration applying the select using unitaries constructed from the given data.

Return type:

GuppyFunctionDefinition

guppyalgos.algorithms.select.build_select_unary_from_data(data_input, data_to_ctrl_op, comp_and_op=<function temp_and_compute>, uncomp_and_op=<function temp_and_uncompute>)

Construct a unary iteration over unitaries constructed from Python data.

Parameters:
Returns:

The unary iteration applying the select using unitaries constructed from the given data.

Return type:

GuppyFunctionDefinition

guppyalgos.algorithms.select.get_index_bools(n_index_qubits, n_index_elements, index_fn)

Return the index boolean list.

Parameters:
  • n_index_qubits (int) – The number of index qubits.

  • n_index_elements (int) – The number of index elements.

  • index_fn (Callable[[int, int], list[bool]]) – The indexing function. Unary iteration passes int_to_bits(), so position 0 is the least-significant bit.

Returns:

A list of boolean values for indexing.

Return type:

list[list[bool]]

guppyalgos.algorithms.select.select_unary_iteration(controlled_ops, comp_and_op, uncomp_and_op, index_qreg, state_qreg)

Unary iteration select function.

This function performs the unary iteration select operation. The index register is little-endian: index_qreg[0] is the least-significant qubit, and integer index i selects controlled_ops[i]. There is also freedom to choose the compute and uncompute AND operations. However it is up to the user to ensure that the AND operations are correct.

Algorithmic workflow:

  1. Compute the index boolean values and most-significant differing bits.

  2. Iterate over each index element:

    1. Compute a little-endian AND cascade generating the work qubits at each step in the recursion.

    2. Apply the corresponding controlled operation to the state register.

    3. For subsequent index elements, perform adjacent AND operations if the most-significant differing bit is not the last index.

    4. Finally, uncompute the little-endian AND cascade to the most-significant differing bit between i and i + 1.

  3. Discard the work qubit register.

Parameters:
  • controlled_ops – The array of controlled operations.

  • comp_and_op – The compute AND operation.

  • uncomp_and_op – The uncompute AND operation.

  • index_qreg – The index qubit register.

  • state_qreg – The state qubit register.