guppyalgos.algorithms.select¶
SELECT algorithms for applying many operators controlled on index registers.
Functions
|
Construct a unary iteration over unitaries constructed from Python data. |
|
Construct a unary iteration over unitaries constructed from Python data. |
|
Return the index boolean list. |
|
Unary iteration select function. |
Classes
Generic |
- class guppyalgos.algorithms.select.SelectRotator¶
Generic
U_mu^dagger P U_muselection around a QROM rotation.The forward and inverse operations are supplied as two fully configured
QROMRotationsinstances. Any shared quantum resource belongs toRotationRegsrather than either rotator, so the same register can be borrowed sequentially by both operations. The central Pauli action receives only the target stored inGivensCascadeRegs, making it independent of any resource used by the cascades.pauli_actionsupplies 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.
- 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:
data_input (list[Data]) – Classical data to construct controlled unitaries.
data_to_ctrl_op (
Callable[[TypeVar(Data)],GuppyFunctionDefinition[(qubit,TypeVar(TargetRegs)),None]]) – Method to create controlled unitaries from data.comp_and_op (
GuppyFunctionDefinition[(qubit,qubit,qubit),None]) – Function to compute temporary AND operations.uncomp_and_op (
GuppyFunctionDefinition[(qubit,qubit,qubit),None]) – Function to uncompute temporary AND operations.
- 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:
data_input (list[Data]) – Classical data to construct controlled unitaries.
data_to_ctrl_op (
Callable[[TypeVar(Data)],GuppyFunctionDefinition[(qubit,TypeVar(TargetRegs)),None]]) – Method to create controlled unitaries from data.comp_and_op (
GuppyFunctionDefinition[(qubit,qubit,qubit),None]) – Function to compute temporary AND operations.uncomp_and_op (
GuppyFunctionDefinition[(qubit,qubit,qubit),None]) – Function to uncompute temporary AND operations.
- 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:
- Returns:
A list of boolean values for indexing.
- Return type:
- 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 indexiselectscontrolled_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:
Compute the index boolean values and most-significant differing bits.
Iterate over each index element:
Compute a little-endian AND cascade generating the work qubits at each step in the recursion.
Apply the corresponding controlled operation to the state register.
For subsequent index elements, perform adjacent AND operations if the most-significant differing bit is not the last index.
Finally, uncompute the little-endian AND cascade to the most-significant differing bit between
iandi + 1.
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.