qp.qubitization_thc_wires

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

Return the wire counts required by QubitizationTHC.

Parameters:
  • M (int) – the THC rank

  • N (int) – the number of spin orbitals. Requires N // 2 <= M + 1

  • aleph (int) – the number of bits used to encode the PREPARE keep-probabilities

  • beth (int) – bits of precision per Givens angle in SELECT

  • num_batches (int) – the number of batches the Givens angles are loaded in

Returns:

{"system_wires": N, "index_wires": 2 * n, "prep_garbage_wires": n_prep, "gradient_wires": beth + 1, "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))): the LCU index \(\mu\) followed by \(\nu\), i.e. the register PREPARE writes the coefficient amplitudes on and SELECT reads to pick which \(V\) to apply

  • prep_garbage_wires: not a state preparation register. These are the wires PREPARE leaves entangled with the index and that therefore have to be reflected along with it, laid out as the SuperpositionTHC work register, then whatever AliasSamplingTHC garbage it cannot supply, then the two spin flags. The spin flags are the exception to the name: they are genuine LCU index wires, placed here because index_wires is sized exactly 2 n by select_thc_wires(). Exact: the reflection acts on index_wires + prep_garbage_wires, so a spare wire here changes the walk operator

  • gradient_wires (beth + 1): the phase gradient register, which must be prepared by the caller and is left unchanged

  • work_wires: the shared clean pool, returned to \(\lvert 0 \rangle\). This is a minimum; extra wires are forwarded to SELECT, to PREPARE’s QROM and to the multi-controlled \(Z\) of the reflection to lower their T counts

Return type:

dict

Note

Every zeroed auxiliary wire is shared rather than duplicated, which is what keeps prep_garbage_wires well below the sum of the sub-template registers:

  • SuperpositionTHC returns all but three of its 3 n + 5 work wires to \(\lvert 0 \rangle\) (the exceptions are its indices 0, 3 and 6), so those 3 n + 2 wires are recycled as AliasSamplingTHC garbage

  • of AliasSamplingTHC’s work register, only n_d + 2 n + 2 aleph + 3 wires stay entangled; the rest (its inequality-test flag, the comparator scratch and the QROM scratch) are restored, so they are taken from work_wires instead of prep_garbage_wires. This both saves qubits and removes controls from the reflection

  • work_wires is idle during PREPARE and clean again during SELECT, so the same pool serves PREPARE’s comparator and QROM, SELECT, and the reflection’s multi-controlled \(Z\)

The remaining prep_garbage_wires are genuine garbage and must stay inside the reflection. Note that dropping them from it does not change the \(\lvert 0 \rangle\) block: for any reflection whose fixed subspace contains \(\lvert 0 \rangle\), \(\langle 0 \rvert \mathcal{R} = \langle 0 \rvert\), so a single walk looks correct either way. What breaks is the Chebyshev property \(\langle 0 \rvert W^k \lvert 0 \rangle = T_k(H / \lambda)\) from \(k = 2\) on, since

\[\langle 0 \rvert U \Pi U \lvert 0 \rangle = B^2 \quad \text{but} \quad \langle 0 \rvert U \Pi_{\text{idx}} U \lvert 0 \rangle = B^2 + \sum_{g \neq 0} \langle 0 \rvert U \lvert 0, g \rangle \langle 0, g \rvert U \lvert 0 \rangle\]

with \(U =\) PREPARE\(^\dagger \cdot\) SELECT \(\cdot\) PREPARE, \(B = \langle 0 \rvert U \lvert 0 \rangle\) and \(\Pi\) the projector onto \(\lvert 0 \rangle\) on all of index_wires + prep_garbage_wires. The extra terms are the branches that are \(\lvert 0 \rangle\) on the index but not on the garbage; reflecting only the index gives them \(+1\) instead of \(-1\). The failure is therefore silent until phase estimation.

Example

>>> import pennylane as qp
>>> qp.qubitization_thc_wires(M=2, N=2, aleph=1, beth=1)
{'system_wires': 2, 'index_wires': 4, 'prep_garbage_wires': 17, 'gradient_wires': 2, 'work_wires': 2}

Contents

Using PennyLane

Release news

Development

API

Internals