qp.alias_sampling_wires

alias_sampling_wires(n_states, mu)[source]

Compute the size of the three registers that AliasSampling acts on.

The three registers differ in what they hold and in whether they are restored, so their sizes are reported separately: target_wires carry the prepared state, temp_wires are left entangled with it, and work_wires are 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 keep and sigma registers

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 - 1 wires that the comparator leaves dirty); left entangled with \(|\ell \rangle\) and uncomputed by \(prepare^{\dagger}\).

  • work_wires (ceil(log2 L) - k, where k is the number of trailing zero bits of L): minimum clean scratch, returned to \(|0\rangle\). Only the odd part L / 2**k needs amplitude amplification, so this is zero whenever L is a power of two.

Return type:

dict

Note

The reported work_wires is the minimum required by AliasSampling. More work_wires can be added to be forwarded to the internal QROM, which uses them for a SelectSwap decomposition that lowers the T-gate count at the cost of the additional qubits. At exactly the minimum, QROM uses its unary decomposition (more T-gates, fewer qubits). target_wires and temp_wires are exact and must be matched exactly.

Contents

Using PennyLane

Release news

Development

API

Internals