`QubitizationWalkOperator` with `StatePreparationAliasSampling` is not a qubitized walk (reflection ignores `sigma_mu`)

Abierto
#1,984 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with reflection_using_prepare.py, then trace how QubitizationWalkOperator and SelectBlockEncoding compose in their named files. Reproduce the supplied minimal example and inspect the reflection tensor and Chebyshev residual with the junk registers carried. Done means the walk is unitary and satisfies the stated qubitization relation, or rejects PREPARE oracles whose junk is not returned to zero.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

(disclaimer: AI slop below)

QubitizationWalkOperator(SelectBlockEncoding(SelectPauliLCU, StatePreparationAliasSampling)) is not a qubitized walk. ReflectionUsingPrepare reflects only on the selection register and frees PREPARE's junk registers (sigma_mu, alt, keep, less_than_equal) while they are not in |0> (sigma_mu is still in uniform superposition). The block encoding itself is exact, but the walk does not keep span{v, Wv} invariant, and the walk's tensor_contract() is not unitary. Reflecting about zero on selection + sigma_mu (with the other junk registers carried) gives an exactly qubitized walk. That costs mu more Toffolis per step (reflection_around_zero((s,)) vs ((s, mu)): n_ccz 1 vs 3 for s=2, mu=2), so current Qualtran Toffoli counts for this walk are low by mu per step.

Minimal example

L=3 Pauli terms on 2 qubits, mu=2. W = R . SELECT is built from tensor_contract() of PREPARE and SELECT with PREPARE's registers kept explicit; R = PREPARE (2|0><0| - I) PREPARE^dagger, the zero being taken on selection only (what Qualtran does) or on selection + sigma_mu. v = PREPARE|0> (x) psi_k with psi_k eigenvectors of the encoded H~ = lambda sum_l p~_l U_l. For a qubitized walk, W^2 v - 2(E/lambda) W v + v = 0.

import numpy as np, cirq
from qualtran import Register, BQUInt
from qualtran.bloqs.state_preparation import StatePreparationAliasSampling
from qualtran.bloqs.multiplexers.select_pauli_lcu import SelectPauliLCU
from qualtran.bloqs.reflections.reflection_using_prepare import ReflectionUsingPrepare
from qualtran.linalg.lcu_util import preprocess_probabilities_for_reversible_sampling as pre

terms = [(0.5, "ZI"), (0.3, "XX"), (-0.15, "IY")]; L, s, mu, n = 3, 2, 2, 2
alt, keep, mu = pre([abs(c) for c, _ in terms], sub_bit_precision=mu)
prep = StatePreparationAliasSampling(selection_registers=Register("selection", BQUInt(s, L)),
    alt=np.array(alt), keep=np.array(keep), mu=mu, sum_of_unnormalized_probabilities=0.95)
sel = SelectPauliLCU(s, n, [cirq.DensePauliString(p, coefficient=int(np.sign(c))) for c, p in terms])
print("sv of ReflectionUsingPrepare(prep):", np.round(np.linalg.svd(
    ReflectionUsingPrepare(prep, global_phase=-1).tensor_contract(), compute_uv=False), 4))

P, S = prep.tensor_contract(), sel.tensor_contract().reshape(4, 4, 4, 4)  # P order: selection, sigma_mu, alt, keep, flag
dJ = P.shape[0] // 4; D = P.shape[0]; g = P[:, 0]
idx = np.arange(D); sig = (idx // (D // 4 // 2**mu)) % 2**mu       # sigma_mu value of each basis state
def walk(x, mask):                                 # x: (D, 4 system); W = R . SELECT, junk carried
    x = np.einsum("asbt,bjt->ajs", S, x.reshape(4, dJ, 4)).reshape(D, 4)
    return P @ (np.where(mask, 1, -1)[:, None] * (P.conj().T @ x))   # R = P (2|0><0| - I) P^dag
pm = {"I": np.eye(2), "X": [[0, 1], [1, 0]], "Y": [[0, -1j], [1j, 0]], "Z": np.diag([1, -1])}
p = np.array(keep, float); np.add.at(p, alt, 2.0**mu - np.array(keep)); p /= 2.0**mu * L
Ht = sum(0.95 * p[l] * np.sign(c) * np.kron(pm[a], pm[b]) for l, (c, (a, b)) in enumerate(terms))
E, V = np.linalg.eigh(Ht)
for name, mask in [("selection only      ", idx // dJ == 0), ("selection + sigma_mu ", (idx // dJ == 0) & (sig == 0))]:
    res = []
    for k in range(4):
        v = np.outer(g, V[:, k]); w1 = walk(v, mask); w2 = walk(w1, mask)
        res.append(np.linalg.norm(w2 - 2 * E[k] / 0.95 * w1 + v))   # 0 iff qubitized: W^2 - 2(E/lam)W + 1
    print(name, "max ||W^2 v - 2(E/lam) W v + v|| =", f"{max(res):.2e}")

Output (qualtran 0.7.0, cirq 1.7.0, python -I):

sv of ReflectionUsingPrepare(prep): [1.     0.3333 0.3333 0.3333]
selection only       max ||W^2 v - 2(E/lam) W v + v|| = 6.67e-01
selection + sigma_mu  max ||W^2 v - 2(E/lam) W v + v|| = 2.72e-15

Expected vs actual

  • Expected: the walk is unitary and acts on span{|L>|psi_k>, W|L>|psi_k>} with eigenphases +-arccos(E_k/lambda); or ReflectionUsingPrepare / the walk refuses PREPARE oracles whose junk is not returned to |0>.
  • Actual: ReflectionUsingPrepare(prep).tensor_contract() has singular values (1, 1/3, 1/3, 1/3), i.e. it is not unitary (the same holds for the full walk's tensor); with junk carried the Chebyshev residual is 0.67 for selection-only vs 3e-15 with sigma_mu included.

Versions: qualtran 0.7.0 (latest release on PyPI), cirq-core 1.7.0, numpy 2.5.3, Python 3.13.15, macOS (arm64).

The code is unchanged on main: these three files at the current head,
c58703d, are byte-identical to qualtran 0.7.0:

Related issues:

  • #1266 "QubitizationWalkOperator should be a block encoding?"
  • #1236 "LinearCombination block encoding may be leaving resource register dirty": the same kind of problem (reflecting on the ancilla register alone is not enough), for a different block encoding.
Lenguaje dominante
Python
Estrellas
397
Forks
127
Merge medio
2 d 19 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quantumlib/Qualtran

Todos los issues de quantumlib/Qualtran

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.