Neural Quantum States (NQS) is a method to find the ground state (lowest energy
state) of a quantum system. NQS uses a neural network (here, a restricted
Boltzmann machine, RBM) to represent the quantum many-body wavefunction
A key step in NQS is computing the local energy
In variational Monte Carlo, a trial wavefunction
which, after applying the Marshall sign rule, contributes a diagonal piece plus one off-diagonal term per bond where the two spins differ:
where eloc_naive/eloc_lookup_table implement in eloc.py.
More about the derivation of the local energy in NQS is in Eloc in NQS and more about Neural Quantum States is in Neural Quantum States.
The RBM wavefunction is
with
-
Naive (
eloc_naive): recompute$\theta'$ from scratch, i.e. a full$s' \cdot W$ matrix-vector product. Cost:$O(N_\text{bonds} \cdot N_\text{spins} \cdot M)$ . -
Lookup table (
eloc_lookup_table):$\theta$ for the unflipped$s$ is computed once; a bond flip only changes two spins, so $\theta'h = \theta_h - 2 W{ih} s_i - 2 W_{jh} s_j$ updates every hidden unit in$O(M)$ instead of$O(N_\text{spins} \cdot M)$ . Cost:$O(N_\text{bonds} \cdot M)$ total.
The lookup-table method is the implementation of choice because of the improved scaling win.
- Initialize
$\theta_h$ . - Calculate
$\log\psi(s)$ from$\theta_h$ by$\log\psi(s) = \gamma \sum_{h=1}^{M} \log\big(2\cosh(\theta_h)\big)$ . -
$E_\text{loc} = 0$ . - Loop over all bonds
$(i,j)$ , and if$s_i \neq s_j$ :- Flip the two spins
$s_i$ and$s_j$ , which gives $\theta'h = \theta_h - 2 W{ih} s_i - 2 W_{jh} s_j$. - Calculate
$\log\psi(s') = \gamma \sum_{h=1}^{M} \log\big(2\cosh(\theta'_h)\big)$ . -
$E_\text{loc} = E_\text{loc} -2 \exp\big(\log\psi(s') - \log\psi(s)\big)$ .
- Flip the two spins
- Calculate the diagonal part: loop over all bonds
$(i,j)$ ,$E_\text{loc} = E_\text{loc} + s_i \cdot s_j$ .
Note that we use
Install required python libraries:
pip install -r requirements.txtGenerating random RBM and States:
python auxiliary/generate_RBM.py <alpha> <L> <#runs> <seed>
python auxiliary/generate_states.py <alpha> <L> <#runs> <seed>python eloc.py <alpha> <>Running sac multi-threaded using
sac2c -tmt_pth eloc.sac
./a.out <alpha> <L> <#runs> <gamma> -mt kAdd `` <#runs>'' on seperate rows in runs.txt.
Then, run:
sbatch benchmark_python.sh #For python
sbatch benchmark_sac.sh #For sac
sbatch benchmark_cuda.sh #For cudaIn benchmark_eloc.jl, modify ALPHAS, LS and N_SAMPLES. Running the Julia version of Eloc requires access to a private repository.
sbatch benchmark_julia.sh