`QubitizationWalkOperator` with `StatePreparationAliasSampling` is not a qubitized walk (reflection ignores `sigma_mu`)
メンテナーはふだん 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 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:
- 主要言語
- Python
- スター
- 397
- フォーク
- 127
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quantumlib/Qualtran のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
quantumlib/Qualtran#2007 ·
メンテナーはふだん 3 日以内に返信
-
Addition call_graph inconsistent with decomposition for registers with unequal bitsizes再び着手できるかも @rupasri118 が 56 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンkind/bug-report
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
quantumlib/Qualtran#1818 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
quantumlib/Qualtran#2008 ·
メンテナーはふだん 3 日以内に返信
-
kickmix: `Circuit.reaction_depth()` materialises every op (≈ 135–170 B/op transient), limiting verifiable circuit size対応中かも @manwithacat が 27 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
quantumlib/Qualtran#1993 ·
メンテナーはふだん 3 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
quantumlib/Qualtran#1991 ·
メンテナーはふだん 3 日以内に返信
quantumlib/Qualtran の issue をすべて見る
似ている issue
-
Triage-Needed
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pulp/pulp-oci-images#875 ·
-
intake mcp-intake needs-human-review priority:high type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Ikalus1988/MisakaNet#5718 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
facebookresearch/autoform-bot#872 ·
メンテナーはふだん 1 日以内に返信
-
Dataset.to_json() writes "Value": [] for an empty sequence対応中かも @DG47 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
area: docs area: providers/oci priority: p3 size: S type: documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
finos/open-resource-broker#933 ·
メンテナーはふだん 1 日以内に返信