-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
146 lines (113 loc) · 5.02 KB
/
Copy pathapp.py
File metadata and controls
146 lines (113 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import startup ## this has to be the first import
import os
import streamlit as st
st.set_page_config(
page_title="Welcome - NQS Tutorial",
layout="centered",
initial_sidebar_state="expanded",
)
st.markdown('<link href="static/css/styles.css" rel="stylesheet">', unsafe_allow_html=True)
st.title("Neural Networks for Wave Functions Parameterization")
cwd = os.getcwd()
image_path = os.path.join(cwd, "static", "nn_models.png")
# training_image = os.path.join(cwd, "static", "training.png")
st.image(image_path)
# Body Section
st.markdown(
r"""
## Welcome
This app allows you to explore the parameterization of wave functions using neural networks. This tutorial will introduce
you to the idea of using Neural Networks for parameterizing wave functions. In our scenario, we combine variational
monte carlo approach with a neural quantum state to search for the ground state of a 2D lattice of Rydberg atoms.
## Acknowledgements
- The above image and other images in other pages were taken from [Sprague and Czischek](https://www.nature.com/articles/s42005-024-01584-y/figures/1).
- The following resources were consulted for this tutorial
- [Sprague and Czischek, 2024](https://www.nature.com/articles/s42005-024-01584-y)
- [Zhang and Ventra, 2023](https://physics.paperswithcode.com/paper/transformer-quantum-state-a-multi-purpose)
- [Czischek et. al., 2022](https://arxiv.org/pdf/2203.04988)
- [Hibat-Allah et. al., 2020](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.2.023358)
- [Deep Learning Tutorial](https://uvadlc-notebooks.readthedocs.io/en/latest/tutorial_notebooks/JAX/tutorial6/Transformers_and_MHAttention.html)
- [QuCumber](https://github.com/PIQuIL/QuCumber)
- With permission, code in the following repository was used for the transformer:
- https://github.com/APRIQuOt/VMC_with_LPTF
### Physics of the Problem
Let us consider the physics of the problem.
- We are looking at a 2D lattice of Rydberg atoms
- We are assuming all-to-all interaction among lattice sites
- The Hamiltonian is as follows
$$
\begin{equation}
\tilde{H} = - \frac{\Omega}{2} \sum_{i = 1}^N \left( \hat{\sigma}_i^x \right) - \delta \sum_{i = 1}^N \left ( \hat{n}_i \right ) + \sum_{i,j} \left ( V_{ij} \hat{n}_i \hat{n}_j \right )
\end{equation}
$$
where $V_{ij} = \frac{\Omega R_b^6}{| \textbf{r}_i - \textbf{r}_j |^6}$ and $R_b$ is the Rydberg blockade radius.
- $\Omega$ is the Rabi frequency
- $\delta$ is the detuning
- $\hat{\sigma}_i^x$ is the Pauli-X matrix
- $\hat{n}_i$ is the number operator
- Atoms at positions $\textbf{r}_i$ and $\textbf{r}_j$ interact through the van der Waals potential, $V_{ij}$
- $N$ is the number of lattice sites
Note that we set $\Omega = \delta = 1$ and $R_b = 7^{\frac{1}{2}}$. This is to put the system in the vicinity of transition between the ordered
and striated phase.
### A Bird's Eyeview of the Approach
- Step 1: Take some arbitrary parameterized wave function (neural network)
- Step 2: Sample from it
- Step 3: Compute the expectation value of the energy
- Step 4: Vary your parameters using some optimization function
- Repeat Steps 2-4 until you reach the ground state
- Our training metric is the energy density of the system
"""
)
# Next Pages
# st.image(training_image)
st.markdown(
r"""
---
There are two parts of this exercise
- Train a model to search for the ground state energy. To get started, click the button below.
- Sample from a trained network and compute observables. To complete this exercise, visit the `notebook` folder in
the root directory and consult the notebook, `off_diagonals.ipynb`
HAVE FUN!
"""
)
# Initialize Session State
if "model_config" not in st.session_state:
st.session_state.model_config = None
if "model_type" not in st.session_state:
st.session_state.model_type = None
if "vmc_config" not in st.session_state:
st.session_state.vmc_config = None
# Footer Navigation
# Add vertical space
for _ in range(5):
st.write("")
_, _, _, _, _, _, _, col1 = st.columns(8)
# go to home page if clicked
with col1:
st.page_link("pages/configuration.py", label="Get Started", icon=":material/arrow_forward:")
footer="""<style>
a:link , a:visited{
color: blue;
background-color: transparent;
text-decoration: underline;
}
a:hover, a:active {
color: red;
background-color: transparent;
text-decoration: underline;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: white;
color: black;
text-align: center;
}
</style>
<div class="footer">
<p><a style='display: block; text-align: center;' href="#" target="_blank">Neural Network Parameterization of Wave Functions</a></p>
</div>
"""
# st.markdown(footer,unsafe_allow_html=True)