Skip to content

Commit 6cab862

Browse files
committed
planted noisy kXOR algorithm
speedup
1 parent 58e6b71 commit 6cab862

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+13444
-18
lines changed

dev_tools/qualtran_dev_tools/notebook_specs.py

+56
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
import qualtran.bloqs.gf_arithmetic.gf2_multiplication
9292
import qualtran.bloqs.gf_arithmetic.gf2_square
9393
import qualtran.bloqs.hamiltonian_simulation.hamiltonian_simulation_by_gqsp
94+
import qualtran.bloqs.max_k_xor_sat
95+
import qualtran.bloqs.max_k_xor_sat.arithmetic
96+
import qualtran.bloqs.max_k_xor_sat.guided_hamiltonian
9497
import qualtran.bloqs.mcmt.and_bloq
9598
import qualtran.bloqs.mcmt.controlled_via_and
9699
import qualtran.bloqs.mcmt.ctrl_spec_and
@@ -878,6 +881,58 @@
878881
),
879882
]
880883

884+
# --------------------------------------------------------------------------
885+
# ----- Quartic Speedups paper ------------------------------------------
886+
# --------------------------------------------------------------------------
887+
ALGO_QUARTIC_SPEEDUPS = [
888+
# ----- Preliminaries ------------------------------------------
889+
NotebookSpecV2(
890+
title='Guided (sparse) Hamiltonian Problem',
891+
module=qualtran.bloqs.max_k_xor_sat.guided_hamiltonian.guided_hamiltonian,
892+
bloq_specs=[
893+
qualtran.bloqs.max_k_xor_sat.guided_hamiltonian.guided_hamiltonian._GUIDED_HAMILTONIAN_DOC,
894+
qualtran.bloqs.max_k_xor_sat.guided_hamiltonian.guided_hamiltonian._GUIDED_HAMILTONIAN_PHASE_ESTIMATION_DOC,
895+
],
896+
),
897+
NotebookSpecV2(
898+
title='Arithmetic Primitives',
899+
module=qualtran.bloqs.max_k_xor_sat.arithmetic,
900+
bloq_specs=[
901+
qualtran.bloqs.max_k_xor_sat.arithmetic.sort_in_place._SORT_IN_PLACE_DOC,
902+
qualtran.bloqs.max_k_xor_sat.arithmetic.symmetric_difference._SYMMETRIC_DIFFERENCE_DOC,
903+
qualtran.bloqs.max_k_xor_sat.arithmetic.has_duplicates._HAS_DUPLICATES_DOC,
904+
],
905+
),
906+
# ----- Algorithm ------------------------------------------
907+
NotebookSpecV2(
908+
title='kXOR: Instance load Oracles',
909+
module=qualtran.bloqs.max_k_xor_sat.load_kxor_instance,
910+
bloq_specs=[qualtran.bloqs.max_k_xor_sat.load_kxor_instance._LOAD_INSTANCE_DOC],
911+
),
912+
NotebookSpecV2(
913+
title='Noisy kXOR: Guiding State',
914+
module=qualtran.bloqs.max_k_xor_sat.guiding_state,
915+
bloq_specs=[
916+
qualtran.bloqs.max_k_xor_sat.guiding_state._SIMPLE_GUIDING_STATE_DOC,
917+
qualtran.bloqs.max_k_xor_sat.guiding_state._GUIDING_STATE_DOC,
918+
],
919+
),
920+
NotebookSpecV2(
921+
title='Noisy kXOR: Block-encoding the Kikuchi Matrix',
922+
module=qualtran.bloqs.max_k_xor_sat.kikuchi_block_encoding,
923+
bloq_specs=[
924+
qualtran.bloqs.max_k_xor_sat.kikuchi_adjacency_matrix._KIKUCHI_MATRIX_ENTRY_DOC,
925+
qualtran.bloqs.max_k_xor_sat.kikuchi_adjacency_list._KIKUCHI_NONZERO_INDEX_DOC,
926+
qualtran.bloqs.max_k_xor_sat.kikuchi_block_encoding._KIKUCHI_HAMILTONIAN_DOC,
927+
],
928+
),
929+
NotebookSpecV2(
930+
title='Algorithm: Planted Noise kXOR',
931+
module=qualtran.bloqs.max_k_xor_sat.planted_noisy_kxor,
932+
bloq_specs=[qualtran.bloqs.max_k_xor_sat.planted_noisy_kxor._PLANTED_NOISY_KXOR_DOC],
933+
),
934+
]
935+
881936
NB_BY_SECTION = [
882937
('Basic Gates', BASIC_GATES),
883938
('Chemistry', CHEMISTRY),
@@ -886,5 +941,6 @@
886941
('GF Arithmetic', GF_ARITHMETIC),
887942
('Rotations', ROT_QFT_PE),
888943
('Block Encoding', BLOCK_ENCODING),
944+
('Paper: Quartic Quantum Speedups for Planted Inference', ALGO_QUARTIC_SPEEDUPS),
889945
('Other', OTHER),
890946
]

docs/bloqs/index.rst

+11
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ Bloqs Library
134134
block_encoding/chebyshev_polynomial.ipynb
135135
block_encoding/lcu_block_encoding.ipynb
136136

137+
.. toctree::
138+
:maxdepth: 2
139+
:caption: Paper: Quartic Quantum Speedups for Planted Inference:
140+
141+
max_k_xor_sat/guided_hamiltonian/guided_hamiltonian.ipynb
142+
max_k_xor_sat/arithmetic/arithmetic.ipynb
143+
max_k_xor_sat/load_kxor_instance.ipynb
144+
max_k_xor_sat/guiding_state.ipynb
145+
max_k_xor_sat/kikuchi_block_encoding.ipynb
146+
max_k_xor_sat/planted_noisy_kxor.ipynb
147+
137148
.. toctree::
138149
:maxdepth: 2
139150
:caption: Other:

qualtran/bloqs/arithmetic/sorting.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
bloq_example,
2424
BloqBuilder,
2525
BloqDocSpec,
26+
DecomposeNotImplementedError,
2627
DecomposeTypeError,
2728
QBit,
2829
QUInt,
@@ -222,8 +223,6 @@ def __attrs_post_init__(self):
222223
k = self.half_length
223224
if not is_symbolic(k):
224225
assert k >= 1, "length of input lists must be positive"
225-
# TODO(#1090) support non-power-of-two input lengths
226-
assert (k & (k - 1)) == 0, "length of input lists must be a power of 2"
227226

228227
@cached_property
229228
def signature(self) -> 'Signature':
@@ -249,14 +248,16 @@ def is_symbolic(self):
249248
def build_composite_bloq(
250249
self, bb: 'BloqBuilder', xs: 'SoquetT', ys: 'SoquetT'
251250
) -> dict[str, 'SoquetT']:
252-
if is_symbolic(self.half_length):
251+
k = self.half_length
252+
if is_symbolic(k):
253253
raise DecomposeTypeError(f"Cannot decompose symbolic {self=}")
254+
if (k & (k - 1)) == 0:
255+
# TODO(#1090) support non-power-of-two input lengths
256+
raise DecomposeNotImplementedError("length of input lists must be a power of 2")
254257

255258
assert isinstance(xs, np.ndarray)
256259
assert isinstance(ys, np.ndarray)
257260

258-
k = self.half_length
259-
260261
first_round_junk = []
261262
for i in range(k):
262263
xs[i], ys[k - 1 - i], anc = bb.add(Comparator(self.bitsize), a=xs[i], b=ys[k - 1 - i])
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from .guiding_state import GuidingState, SimpleGuidingState
15+
from .kikuchi_adjacency_list import KikuchiNonZeroIndex
16+
from .kikuchi_adjacency_matrix import KikuchiMatrixEntry
17+
from .kikuchi_block_encoding import KikuchiHamiltonian, KikuchiMatrixEntry, KikuchiNonZeroIndex
18+
from .kxor_instance import Constraint, KXorInstance
19+
from .planted_noisy_kxor import AliceTheorem, PlantedNoisyKXOR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from .has_duplicates import HasDuplicates
15+
from .sort_in_place import SortInPlace
16+
from .symmetric_difference import SymmetricDifference

0 commit comments

Comments
 (0)