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

オープン
#1,984 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

(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.
主要言語
Python
スター
397
フォーク
127
平均マージ
2日 19時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quantumlib/Qualtran のほかの issue

quantumlib/Qualtran の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。