qp.select_thc_wires

select_thc_wires(M, N, beth, num_batches=1)[source]

Return the wire counts required by SelectTHC.

Parameters:
  • M (int) – the THC rank.

  • N (int) – the number of spin orbitals.

  • beth (int) – bits of precision per Givens angle. The realised grid is the odd multiples of \(\pi / 2^{\mathrm{beth}}\), so the spacing is \(2\pi / 2^{\mathrm{beth}}\).

  • num_batches (int) – the number of batches the Givens angles are loaded in. The default of 1 loads all of them at once. See the note below.

Returns:

{"system_wires": n_system, "index_wires": n_index, "flag_wires": n_flag, "gradient_wires": n_gradient, "work_wires": n_work}.

  • system_wires (N): the spin orbitals, the N/2 spin-down spatial orbitals followed by the N/2 spin-up ones.

  • index_wires (2 * ceil(log2(M + 1))): \(\mu\) followed by \(\nu\), as produced by PREPARE. The + 1 inside the logarithm leaves room for the one-body sentinel value \(\nu = M\).

  • flag_wires (5): the success flag, the one-body sentinel flag (\(\nu = M\)), the qubit that controls the \(\mu \leftrightarrow \nu\) swap, and the two spin flags.

  • gradient_wires (beth + 1): the phase gradient register. See the note below.

  • work_wires (ceil((N/2 - 1) / num_batches) * beth + max(ceil(log2(M + 1)), beth)): the minimum clean scratch, returned to \(\lvert 0 \rangle\). Zero when N/2 == 1, where the sandwich is a lone \(Z_1\) and no angles are loaded.

Return type:

dict

Raises:

ValueError – if M, N, beth or num_batches is not a positive integer, if N is odd, or if the one-body block does not fit the index register.

Note

Only work_wires is a minimum; the other four are exact and must be matched. Extra work wires are forwarded to the internal QROM, which splits them between the unary iteration of its Select and the SelectSwap space-time trade-off. Which split it picks depends on M, N and beth, so extra wires do not necessarily lower the gate count.

Note

gradient_wires must be prepared by the caller in the phase gradient state

\[\lvert \phi \rangle = \frac{1}{\sqrt{2^{\mathrm{beth}+1}}} \sum_{k=0}^{2^{\mathrm{beth}+1} - 1} e^{-2 \pi i k / 2^{\mathrm{beth}+1}} \lvert k \rangle ,\]

which can be done with PhaseGradientStatePrep. The SELECT oracle leaves it unchanged, so it is deliberately not allocated internally: one register is prepared once and shared by PREPARE and SELECT.

Example

>>> import pennylane as qp
>>> qp.select_thc_wires(M=3, N=4, beth=4)
{'system_wires': 4, 'index_wires': 4, 'flag_wires': 5, 'gradient_wires': 5, 'work_wires': 8}

Contents

Using PennyLane

Release news

Development

API

Internals