guppyalgos.primitives.subroutines.fanout¶
Quantum fanout implementations.
Functions
|
Apply basic fanout to one flat data register. |
|
Build a single- or multi-register fanout from a flat Guppy operation. |
|
Apply log depth fanout to one flat data register. |
|
Fan out a target qubit into a supplied zero-state register. |
Return the peak qubit count required by fanout compute. |
|
|
Apply parity-based measurement-assisted fanout to a target register. |
Return the qubit count required by parity-based measurement fanout. |
|
|
Uncompute a fanout copy register back to zero in place. |
- guppyalgos.primitives.subroutines.fanout.fanout_basic(control, data_qs)¶
Apply basic fanout to one flat data register.
- guppyalgos.primitives.subroutines.fanout.fanout_from_data(data, fan_out_flat_fn)¶
Build a single- or multi-register fanout from a flat Guppy operation.
The
Trueentries indataidentify selected data qubits. For nested data, selected qubits from every target register are gathered into one flat array beforefan_out_flat_fnis called. The operation is invoked exactly once, rather than once per target register, and the qubits are then returned to their original locations.This is useful for measurement-based fanout, where the flat operation can be implemented with a single measurement and feed-forward correction, rather than one measurement per target register, leading to constant depth.
- Parameters:
- Return type:
- Returns:
A Guppy function accepting a control and target register shape matching
data.- Raises:
TypeError – If
datais not a non-empty boolean list or nested list.ValueError – If nested target masks have unequal lengths.
- guppyalgos.primitives.subroutines.fanout.fanout_log(control, data_qs)¶
Apply log depth fanout to one flat data register.
- guppyalgos.primitives.subroutines.fanout.fanout_measurement_compute(q_target, qs_target_copies)¶
Fan out a target qubit into a supplied zero-state register.
The circuit implements
|y>|0>|0> -> |y>|y>|y>using measurement-assisted computation and feed-forward.For fewer than three copies, sequential controlled operations are used. Larger registers use measurement-assisted fanout with
n_state_qubits - 2ancillas.It is up to the user to generate the copy register.
- Parameters:
q_target – Qubit whose computational-basis value is copied.
qs_target_copies – Caller-provided target register initialized to zero.
- guppyalgos.primitives.subroutines.fanout.fanout_measurement_compute_total_qubits(n_state_qubits)¶
Return the peak qubit count required by fanout compute.
The count includes one control qubit,
n_state_qubitssupplied target qubits, andn_state_qubits - 2equal-check ancillas when at least three copies are requested.
- guppyalgos.primitives.subroutines.fanout.fanout_measurement_parity(q_target, qs_inputs)¶
Apply parity-based measurement-assisted fanout to a target register.
Hadamard conjugation reverses the direction of the CNOTs represented by the parity circuit. The operation therefore maps
|c>|x_0, ..., x_n-1>to|c>|x_0 XOR c, ..., x_n-1 XOR c>. This operation acts on an arbitrary input state. For four or more targets, the underlying LAQCC parity circuit allocates two ancilla registers, each containingn_state_qubits - 3qubits. Smaller registers use no ancillas.- Parameters:
q_target – Control qubit whose value is fanned out.
qs_inputs – Target register. Its length determines the circuit and ancilla sizes at compile time.
Examples
With control
|1>and three targets in|0, 0, 0>, the output targets are|1, 1, 1>and the control remains|1>.
- guppyalgos.primitives.subroutines.fanout.fanout_measurement_parity_total_qubits(n_state_qubits)¶
Return the qubit count required by parity-based measurement fanout.
The count includes one control qubit,
n_state_qubitstarget qubits, and two LAQCC ancilla registers of sizen_state_qubits - 3when the target register contains at least four qubits.
- guppyalgos.primitives.subroutines.fanout.fanout_measurement_uncompute(q_target, qs_copies)¶
Uncompute a fanout copy register back to zero in place.
The circuit implements
|y>|y>|y> -> |y>|0>|0>using measurement-assisted computation and feed-forward.This is the inverse cleanup operation for
fanout_measurement_compute(). It non-destructively measures the copy register, corrects the target using the measurement parity, and resets the supplied copies to zero.It is up to the user to discard the copy register after this operation.
- Parameters:
q_target – Original target qubit used to create the copies.
qs_copies – Caller-owned copy register to restore to zero.