Skip to content

Commit fcf4ddc

Browse files
authored
Move hubbard_model.py to chemistry/hubbard_model/qubitization/ (#1005)
* Move hubbard model * Select Hubbard * Prepare Hubbard * Walk operator * Octopus split and refactor * Update references, regenerate notebooks * Regenerate * Fix mypy and notebook reference
1 parent e5690dd commit fcf4ddc

21 files changed

Lines changed: 383 additions & 354 deletions

dev_tools/autogenerate-bloqs-notebooks-v2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import qualtran.bloqs.block_encoding.lcu_block_encoding
6262
import qualtran.bloqs.block_encoding.lcu_select_and_prepare
6363
import qualtran.bloqs.chemistry.df.double_factorization
64+
import qualtran.bloqs.chemistry.hubbard_model.qubitization
6465
import qualtran.bloqs.chemistry.pbc.first_quantization.prepare_t
6566
import qualtran.bloqs.chemistry.pbc.first_quantization.prepare_uv
6667
import qualtran.bloqs.chemistry.pbc.first_quantization.projectile.select_and_prepare
@@ -83,7 +84,6 @@
8384
import qualtran.bloqs.factoring.ecc
8485
import qualtran.bloqs.factoring.mod_exp
8586
import qualtran.bloqs.hamiltonian_simulation.hamiltonian_simulation_by_gqsp
86-
import qualtran.bloqs.hubbard_model
8787
import qualtran.bloqs.mcmt.and_bloq
8888
import qualtran.bloqs.mod_arithmetic.mod_addition
8989
import qualtran.bloqs.multiplexers.apply_gate_to_lth_target
@@ -491,10 +491,11 @@
491491
),
492492
NotebookSpecV2(
493493
title='Qubitized Hubbard Model',
494-
module=qualtran.bloqs.hubbard_model,
494+
module=qualtran.bloqs.chemistry.hubbard_model.qubitization,
495+
path_stem='hubbard_model',
495496
bloq_specs=[
496-
qualtran.bloqs.hubbard_model._SELECT_HUBBARD,
497-
qualtran.bloqs.hubbard_model._PREPARE_HUBBARD,
497+
qualtran.bloqs.chemistry.hubbard_model.qubitization.select_hubbard._SELECT_HUBBARD,
498+
qualtran.bloqs.chemistry.hubbard_model.qubitization.prepare_hubbard._PREPARE_HUBBARD,
498499
],
499500
),
500501
NotebookSpecV2(

docs/bloqs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Bloqs Library
9393
:caption: Other:
9494

9595
state_preparation/prepare_uniform_superposition.ipynb
96-
hubbard_model.ipynb
96+
chemistry/hubbard_model/qubitization/hubbard_model.ipynb
9797
multiplexers/apply_gate_to_lth_target.ipynb
9898
data_loading/qrom.ipynb
9999
data_loading/select_swap_qrom.ipynb

qualtran/bloqs/basic_gates/identity.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"source": [
3838
"## `Identity`\n",
39-
"The identity gate\n",
39+
"The identity gate on one qubit.\n",
4040
"\n",
4141
"#### Registers\n",
4242
" - `q`: The qubit\n"

qualtran/bloqs/block_encoding/block_encoding.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
},
177177
"outputs": [],
178178
"source": [
179-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
179+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
180180
"\n",
181181
"# 3x3 hubbard model U/t = 4\n",
182182
"dim = 3\n",
@@ -199,7 +199,7 @@
199199
"outputs": [],
200200
"source": [
201201
"from qualtran.bloqs.block_encoding import BlackBoxPrepare, BlackBoxSelect\n",
202-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
202+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
203203
"\n",
204204
"# 3x3 hubbard model U/t = 4\n",
205205
"dim = 3\n",
@@ -347,7 +347,7 @@
347347
},
348348
"outputs": [],
349349
"source": [
350-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
350+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
351351
"\n",
352352
"# 3x3 hubbard model U/t = 4\n",
353353
"dim = 3\n",
@@ -372,7 +372,7 @@
372372
"outputs": [],
373373
"source": [
374374
"from qualtran.bloqs.block_encoding import BlackBoxPrepare, BlackBoxSelect\n",
375-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
375+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
376376
"\n",
377377
"# 3x3 hubbard model U/t = 4\n",
378378
"dim = 3\n",
@@ -502,7 +502,7 @@
502502
"outputs": [],
503503
"source": [
504504
"from qualtran.bloqs.block_encoding import LCUBlockEncodingZeroState\n",
505-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
505+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
506506
"\n",
507507
"dim = 3\n",
508508
"select = SelectHubbard(x_dim=dim, y_dim=dim)\n",
@@ -531,7 +531,7 @@
531531
" BlackBoxSelect,\n",
532532
" LCUBlockEncodingZeroState,\n",
533533
")\n",
534-
"from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard\n",
534+
"from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard\n",
535535
"\n",
536536
"dim = 3\n",
537537
"select = SelectHubbard(x_dim=dim, y_dim=dim)\n",

qualtran/bloqs/block_encoding/chebyshev_polynomial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def build_call_graph(self, ssa: 'SympySymbolAllocator') -> Set['BloqCountT']:
112112
@bloq_example
113113
def _chebyshev_poly() -> ChebyshevPolynomial:
114114
from qualtran.bloqs.block_encoding import LCUBlockEncodingZeroState
115-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
115+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
116116

117117
dim = 3
118118
select = SelectHubbard(x_dim=dim, y_dim=dim)
@@ -135,7 +135,7 @@ def _black_box_chebyshev_poly() -> ChebyshevPolynomial:
135135
BlackBoxSelect,
136136
LCUBlockEncodingZeroState,
137137
)
138-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
138+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
139139

140140
dim = 3
141141
select = SelectHubbard(x_dim=dim, y_dim=dim)

qualtran/bloqs/block_encoding/lcu_block_encoding.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def _extract_soqs(bloq: Bloq) -> Dict[str, 'SoquetT']:
363363

364364
@bloq_example
365365
def _black_box_prepare() -> BlackBoxPrepare:
366-
from qualtran.bloqs.hubbard_model import PrepareHubbard
366+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard
367367

368368
prepare = PrepareHubbard(2, 2, 1, 4)
369369
black_box_prepare = BlackBoxPrepare(prepare=prepare)
@@ -372,7 +372,7 @@ def _black_box_prepare() -> BlackBoxPrepare:
372372

373373
@bloq_example
374374
def _black_box_select() -> BlackBoxSelect:
375-
from qualtran.bloqs.hubbard_model import SelectHubbard
375+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import SelectHubbard
376376

377377
select = SelectHubbard(2, 2)
378378
black_box_select = BlackBoxSelect(select=select)
@@ -381,7 +381,7 @@ def _black_box_select() -> BlackBoxSelect:
381381

382382
@bloq_example
383383
def _lcu_block() -> LCUBlockEncoding:
384-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
384+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
385385

386386
# 3x3 hubbard model U/t = 4
387387
dim = 3
@@ -398,7 +398,7 @@ def _lcu_block() -> LCUBlockEncoding:
398398
@bloq_example
399399
def _black_box_lcu_block() -> LCUBlockEncoding:
400400
from qualtran.bloqs.block_encoding import BlackBoxPrepare, BlackBoxSelect
401-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
401+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
402402

403403
# 3x3 hubbard model U/t = 4
404404
dim = 3
@@ -416,7 +416,7 @@ def _black_box_lcu_block() -> LCUBlockEncoding:
416416

417417
@bloq_example
418418
def _lcu_zero_state_block() -> LCUBlockEncodingZeroState:
419-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
419+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
420420

421421
# 3x3 hubbard model U/t = 4
422422
dim = 3
@@ -435,7 +435,7 @@ def _lcu_zero_state_block() -> LCUBlockEncodingZeroState:
435435
@bloq_example
436436
def _black_box_lcu_zero_state_block() -> LCUBlockEncodingZeroState:
437437
from qualtran.bloqs.block_encoding import BlackBoxPrepare, BlackBoxSelect
438-
from qualtran.bloqs.hubbard_model import PrepareHubbard, SelectHubbard
438+
from qualtran.bloqs.chemistry.hubbard_model.qubitization import PrepareHubbard, SelectHubbard
439439

440440
# 3x3 hubbard model U/t = 4
441441
dim = 3

qualtran/bloqs/chemistry/hubbard_model/__init__.py

Whitespace-only changes.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2023 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+
r"""Simulating the Hubbard model Hamiltonian using qubitization.
15+
16+
This module follows section V. of Encoding Electronic Spectra in Quantum Circuits with Linear T
17+
Complexity. Babbush et. al. 2018. [arxiv:1805.03662](https://arxiv.org/abs/1805.03662).
18+
19+
The 2D Hubbard model is a special case of the electronic structure Hamiltonian
20+
restricted to spins on a planar grid.
21+
22+
$$
23+
H = -t \sum_{\langle p,q \rangle, \sigma} a_{p,\sigma}^\dagger a_{q,\sigma}
24+
+ \frac{u}{2} \sum_{p,\alpha\ne\beta} n_{p, \alpha} n_{p, \beta}
25+
$$
26+
27+
Under the Jordan-Wigner transformation to Pauli operators, this is
28+
29+
$$
30+
\def\Zvec{\overrightarrow{Z}}
31+
\def\hop#1{#1_{p,\sigma} \Zvec #1_{q,\sigma}}
32+
H = -\frac{t}{2} \sum_{\langle p,q \rangle, \sigma} (\hop{X} + \hop{Y})
33+
+ \frac{u}{8} \sum_{p,\alpha\ne\beta} Z_{p,\alpha}Z_{p,\beta}
34+
- \frac{u}{4} \sum_{p,\sigma} Z_{p,\sigma} + \frac{uN}{4}\mathbb{1}
35+
$$
36+
37+
This can be simulated using a qubitization circuit, which consists of PREPARE and SELECT
38+
operations. This module contains `SelectHubbard` and `PrepareHubbard`, with particular
39+
compilation optimizations for the Hubbard model. For more insight into how Select and Prepare
40+
operations can be combined into a quantum walk, please see
41+
[Qubitization Walk Operator](./qubitization_walk_operator.ipynb).
42+
43+
With these operators, our selection register has indices
44+
for $p$, $\alpha$, $q$, and $\beta$ as well as two indicator bits $U$ and $V$. There are four cases
45+
considered in both the PREPARE and SELECT operations corresponding to the terms in the Hamiltonian:
46+
47+
- $U=1$, single-body Z
48+
- $V=1$, spin-spin ZZ term
49+
- $p<q$, XZX term
50+
- $p>q$, YZY term.
51+
"""
52+
from .prepare_hubbard import PrepareHubbard
53+
from .select_hubbard import SelectHubbard
54+
from .walk_operator import get_walk_operator_for_hubbard_model

0 commit comments

Comments
 (0)