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 + 1aleph (int) – the number of bits used to encode the
PREPAREkeep-probabilitiesbeth (int) – bits of precision per Givens angle in
SELECTnum_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, theN/2spin-down spatial orbitals followed by theN/2spin-up onesindex_wires(2 * ceil(log2(M + 1))): the LCU index \(\mu\) followed by \(\nu\), i.e. the registerPREPAREwrites the coefficient amplitudes on andSELECTreads to pick which \(V\) to applyprep_garbage_wires: not a state preparation register. These are the wiresPREPAREleaves entangled with the index and that therefore have to be reflected along with it, laid out as theSuperpositionTHCwork register, then whateverAliasSamplingTHCgarbage 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 becauseindex_wiresis sized exactly2 nbyselect_thc_wires(). Exact: the reflection acts onindex_wires + prep_garbage_wires, so a spare wire here changes the walk operatorgradient_wires(beth + 1): the phase gradient register, which must be prepared by the caller and is left unchangedwork_wires: the shared clean pool, returned to \(\lvert 0 \rangle\). This is a minimum; extra wires are forwarded toSELECT, toPREPARE’sQROMand 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_wireswell below the sum of the sub-template registers:SuperpositionTHCreturns all but three of its3 n + 5work wires to \(\lvert 0 \rangle\) (the exceptions are its indices0,3and6), so those3 n + 2wires are recycled asAliasSamplingTHCgarbageof
AliasSamplingTHC’s work register, onlyn_d + 2 n + 2 aleph + 3wires stay entangled; the rest (its inequality-test flag, the comparator scratch and theQROMscratch) are restored, so they are taken fromwork_wiresinstead ofprep_garbage_wires. This both saves qubits and removes controls from the reflectionwork_wiresis idle duringPREPAREand clean again duringSELECT, so the same pool servesPREPARE’s comparator andQROM,SELECT, and the reflection’s multi-controlled \(Z\)
The remaining
prep_garbage_wiresare 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 ofindex_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}