`QubitizationWalkOperator` with `StatePreparationAliasSampling` is not a qubitized walk (reflection ignores `sigma_mu`)
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 withsigma_muincluded.
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:
qualtran/bloqs/reflections/reflection_using_prepare.py(ReflectionUsingPrepare: reflects on the selection registers and frees the junk registers)qualtran/bloqs/qubitization/qubitization_walk_operator.py(QubitizationWalkOperator)qualtran/bloqs/block_encoding/lcu_block_encoding.py(SelectBlockEncoding)
Related issues:
- Lenguaje dominante
- Python
- Estrellas
- 397
- Forks
- 127
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de quantumlib/Qualtran
-
`show_bloq` not workingAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
quantumlib/Qualtran#2007 ·
Los mantenedores suelen responder en 3 días
-
Addition call_graph inconsistent with decomposition for registers with unequal bitsizesQuizá libre de nuevo @rupasri118 la tomó hace 56 días y no hay ningún pull request abierto. Abiertokind/bug-report
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
quantumlib/Qualtran#1818 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
quantumlib/Qualtran#2008 ·
Los mantenedores suelen responder en 3 días
-
kickmix: `Circuit.reaction_depth()` materialises every op (≈ 135–170 B/op transient), limiting verifiable circuit sizePosiblemente ocupada @manwithacat la tomó hace 27 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
quantumlib/Qualtran#1993 ·
Los mantenedores suelen responder en 3 días
-
Windows wheel (or source) for kickmix library needed for Kaggle quantum compilation challengeAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
quantumlib/Qualtran#1991 ·
Los mantenedores suelen responder en 3 días
Todos los issues de quantumlib/Qualtran
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
ActivityWatch/docs#223 ·
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier capturePosiblemente ocupada @jianyx1 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
volcengine/OpenViking#8354 ·
Los mantenedores suelen responder en 1 día
-
comp/tools P2 tool/skills type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#159541 ·
Los mantenedores suelen responder en 1 día
-
multilabel_margin_loss returns an unwritten scalar for an empty CPU batch with reduction='sum'Abiertobot-triaged module: correctness (silent) module: cpu module: empty tensor module: loss triage review
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
request-theme
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
LizardByte/ThemerrDB#10167 · 1 comentario ·