qp.alias_sampling_wires¶
- alias_sampling_wires(n_states, mu)[source]¶
Compute the size of the three registers that
AliasSamplingacts on.The three registers differ in what they hold and in whether they are restored, so their sizes are reported separately:
target_wirescarry the prepared state,temp_wiresare left entangled with it, andwork_wiresare returned to \(|0\rangle\) and can be reused.- Parameters:
n_states (int) – the number of coefficients \(L\) of the state to be prepared
mu (int) – number of bits of precision used for the
keepandsigmaregisters
- Returns:
{"target_wires": n_target, "temp_wires": n_temp, "work_wires": n_work}.target_wires(ceil(log2 L)): the output index register \(|\ell \rangle\)temp_wires(3*mu + ceil(log2 L)): sigma + alt + keep + flag + comparator scratch (mu - 1wires that the comparator leaves dirty); left entangled with \(|\ell \rangle\) and uncomputed by \(prepare^{\dagger}\).work_wires(ceil(log2 L) - k, wherekis the number of trailing zero bits ofL): minimum clean scratch, returned to \(|0\rangle\). Only the odd partL / 2**kneeds amplitude amplification, so this is zero wheneverLis a power of two.
- Return type:
dict
Note
The reported
work_wiresis the minimum required byAliasSampling. More work_wires can be added to be forwarded to the internalQROM, which uses them for aSelectSwapdecomposition that lowers the T-gate count at the cost of the additional qubits. At exactly the minimum,QROMuses its unary decomposition (more T-gates, fewer qubits).target_wiresandtemp_wiresare exact and must be matched exactly.