Skip to content

AtelierArith/GomalizingFlow.jl

Repository files navigation

GomalizingFlow.jl: A Julia package for Flow-based sampling algorithm

Abstract

GomalizingFlow.jl is a package to generate configurations using the flow based sampling algorithm in Julia programming language. This software serves two main purposes: to acceralate research works of lattice QCD with machine learning with easy prototyping, and to provide an independent implimentation to an existing code in Python/PyTorch. GomalizingFlow.jl implements, the flow based sampling algorithm, namely, RealNVP and Metropolis-Hastings test for two dimension and three dimensional scalar field, which can be switched by a parameter file. HMC for that theory also implemented for comparison. This code works not only on CPU but also on NVIDIA GPU.

Usage (TL; DR)

$ git clone https://github.com/AtelierArith/GomalizingFlow.jl && cd GomalizingFlow.jl
$ # Install Docker and GNU Make command:
$ make
$ docker compose run --rm shell julia begin_training.jl cfgs/example2d.toml

Usage (detailed description)

If you're familiar with how to use Julia especially deep learning with GPU, you can setup an environment by yourself via:

julia> using Pkg; Pkg.instantiate()
julia> using GomalizingFlow
julia> hp = GomalizingFlow.load_hyperparams("cfgs/example2d.toml"; device_id=0, pretrained=nothing, result="result")
julia> GomalizingFlow.train(hp)

Otherwise, we recommend to create one using Docker container (see the following instructions from Step1 to Step4).

Step1: Setup environment (using Docker)

Install Docker, more precisely NVIDIA Container Toolkit and GNU Make.

Below shows author's development environment (Linux/Ubuntu 22.04).

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
$ make  make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ docker --version
Docker version 23.0.1, build a5ee5b1
$ nvidia-smi
Fri Mar 24 23:34:16 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.05    Driver Version: 525.85.05    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:03:00.0 Off |                  N/A |
|  0%   33C    P8     9W / 280W |      6MiB / 11264MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  NVIDIA GeForce ...  Off  | 00000000:04:00.0 Off |                  N/A |
|  0%   36C    P8    11W / 280W |    179MiB / 11264MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
$ cat /etc/docker/daemon.json
{
    "default-runtime": "nvidia",
    "runtimes": {
        "nvidia": {
            "args": [],
            "path": "nvidia-container-runtime"
        }
    }
}

Step2: Build a Docker image

Just do:

$ make

It will create a Docker image named gomalizingflowjl.

Tips

If nvidia-smi shows CUDA Version: 11.7, you may want to run instead:

CUDA_VERSION=11.7.0 make

Step3: Start training (using Docker)

Syntax

In general, you can train a model via:

$ docker compose run --rm shell julia begin_training.jl <path/to/config.toml>

For example:

$ docker compose run --rm shell julia begin_training.jl cfgs/example2d.toml # You can run in a realistic time without using GPU accelerator.

It will generate some artifacts in results/example2d/:

$ ls result/example2d/
Manifest.toml               evaluations.csv             src
Project.toml                history.bson                trained_model.bson
config.toml                 history_best_ess.bson       trained_model_best_ess.bson

You'll see a trained model (trained_model.bson), a training log (evaluations.csv) or configurations generated by flow based sampling algorithm (history.bson).

Tips

For those who are interested in training for 3D field theory. Just run:

$ docker compose run --rm shell julia begin_training.jl cfgs/example3d.toml

You may need run julia -e 'using Pkg; Pkg.instantiate()' before running begin_training.jl

$ docker compose run --rm shell bash -c "julia -e 'using Pkg; Pkg.instantiate()' && julia begin_training.jl cfgs/example3d.toml"

For 3D field theory parameter, you may want to use GPU for training. Make sure nvidia-smi command can be found from the container of gomalizingflowjl

$ docker compose run --rm shell bash -c "nvidia-smi"

Some environments will produce the result below:

bash: line 1: nvidia-smi: command not found

In this case, try docker compose run --rm shell-gpu bash -c "nvidia-smi" instead. Note that julia-gpu refers the service name which can be found at docker-compose.yml.

  julia-gpu:
    image: gomalizingflowjl
    runtime: nvidia
    container_name: gomalizingflowjl-julia-gpu
    volumes:
      - ./:/work
    working_dir: /work
    command: julia --project=/work

Step3-1: Watch evaluations.csv during training

During training, you can watch the value of ess for each epoch.

  • Run training script as usual:
$ docker compose run --rm shell julia begin_training.jl </path/to/config.toml>
  • Open another terminal, and run the following:
$ docker compose run --rm shell julia watch.jl </path/to/config.toml>

It will display a plot in your terminal something like:

$ docker compose run --rm shell julia watch.jl cfgs/example2d.toml
Creating gomalizingflowjl_julia_run ... done
[ Info: serving ~/work/atelier_arith/GomalizingFlow.jl/result/example2d
[ Info: evaluations.csv is updated
           β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €Evaluationβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       0.8 β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ ess
           β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β €β €β €β €β €β €β €β €β €β €β €β €β’ β‘„β €β €β €β €β €β €β €β €β”‚
           │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⒀⠀⠀⠀⑀⣴⠀⠀⠀Ⓒ⑇⠀⣷⣄⣀⠀⒀⠀⑄│
           │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑀⠀⠀⣿⠀⒠⠀⣼⠀⑇⣸⑇⣿⠀⠀⠀Ⓒ⣷⒰⣿⑇⣿⒀⣸⣰⑇│
           │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑄⠀⠀⑆⑀⠀⒀⣴⑄⠀⑇⣴⑄⣿⑀⣾⠀⣿⣧⒳⣿⣧⣿⑀⠀⠀⣼⣿⣿⑏⠃⣿⣾⣿⣿⑇│
           │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑄⠀⠀⠀⠀⠀⣴⑇⠀⑄⑇⣧⠀Ⓒ⑏⑇⠀⑇⣿⑇⑿⑇⣿⠀⣿⣿Ⓒ⣿⣿⣿Ⓙ⑇⠀⑏Ⓕ⑿⠁⠀⣿⑏⣿⣿⣷│
           β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘‡β’°β‘€β’€β‘†β£΄β£Ώβ’£β €β£§β£§β£Ώβ£¦β Ώβ ƒβ’Έβ €β£·β’Ήβ£§β‘‡β’£β£Ώβ‘„β£Ώβ£Ώβ ˜β‘‡β£Ώβ£Ώβ’Έβ‘‡β‘žβ ƒβ’Έβ‘‡β €β €β£Ώβ‘‡β£Ώβ’Ώβ£Ώβ”‚
   ess     β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β£§β£Έβ‘‡β£Ώβ£Ώβ‘β£Ώβ’Έβ£ β’»β‘Ώβ ‰β’»β €β €β’Έβ£Όβ£Ώβ’Έβ£Ώβ‘‡β’Έβ£Ώβ’»β’»β£Ώβ €β €β’Ήβ‘Ÿβ Έβ£·β‘‡β €β’Έβ‘‡β €β €β£Ώβ‘‡β£Ώβ €β‘Ώβ”‚
           β”‚β €β €β €β €β €β €β €β €β’ β €β €β£‡β €β €β €β’€β’Έβ’Έβ£Ώβ£‡β‘‡β’Ήβ‘‡β£Ώβ €β£Ώβ Έβ ‡β €β’Έβ €β €β’Έβ£Ώβ£Ώβ’Έβ‘Ώβ €β ˆβ ‹β’Έβ’Έβ£Ώβ €β €β’Έβ‘‡β €β Έβ‘‡β €β Έβ‘‡β €β €β£Ώβ β‘β €β β”‚
           β”‚β €β €β €β €β €β €β €β €β’Έβ €β’°β£Ώβ‘€β’€β‘€β‘Έβ£Ύβ’Έβ£Ώβ£Ώβ‘‡β’Έβ‘‡β‘Ώβ €β£Ώβ €β €β €β ˜β €β €β’Έβ‘β£Ώβ’Έβ‘‡β €β €β €β’Έβ’Έβ‘Ÿβ €β €β’Έβ‘‡β €β €β‘‡β €β €β‘‡β €β €β£Ώβ €β‘‡β €β €β”‚
           β”‚β €β €β €β €β €β €β €β €β‘Έβ‘„β£Ύβ£Ώβ£‡β£Όβ£‡β‘‡β’Ώβ’Έβ’Ώβ£Ώβ‘‡β’Έβ €β‘‡β €β£Ώβ €β €β €β €β €β €β ˆβ β£Ώβ €β β €β €β €β ˜β ˆβ ƒβ €β €β’Έβ β €β €β €β €β €β ƒβ €β €β£Ώβ €β‘‡β €β €β”‚
           β”‚β €β €β‘„β‘€β €β €β£§β €β‘‡β£§β£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ‘‡β ˜β ˜β’Έβ£Ώβ‘‡β Έβ €β‘‡β €β£Ώβ €β €β €β €β €β €β €β €β£Ώβ €β €β €β €β €β €β €β €β €β €β Έβ €β €β €β €β €β €β €β €β €β£Ώβ €β‘‡β €β €β”‚
           │⑀⠀⣧⣇Ⓒ⠀⣿Ⓒ⠁⠀⑇⠻⣿⠛⠻⠇⠀⠀⠀⣿⑇⠀⠀⠀⠀⠿⠀⠀⠀⠀⠀⠀⠀⠀⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⑇⠀⠀│
           β”‚β’£β£Άβ£Ώβ’Ήβ‘œβ‘„β‘β‘Ύβ €β €β €β €β ˜β €β €β €β €β €β €β ›β β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ‰β €β €β €β €β”‚
         0 β”‚β ˆβ Έβ ‰β €β ‡β ‹β β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β €0β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €200β €
           β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €epochβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €

We also support showing acceptance_rate by adding --item acceptance_rate:

$ docker compose run --rm shell julia watch.jl cfgs/example2d_E1.toml --item acceptance_rate
Creating gomalizingflowjl_julia_run ... done
[ Info: serving /work/result/example2d_E1
[ Info: evaluations.csv is updated
                      β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €Evaluationβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   60 β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ acceptance_rate
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘€β €β£€β£€β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β£„β €β’€β£€β’°β ’β’’β‘ β €β œβ ˆβ£§β ƒβ ˆβ Šβ €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘€β €β‘€β‘°β “β’„β –β ’β ’β šβ €β ™β‘Όβ’Έβ’Έβ €β €β β €β €β €β ˜β €β €β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘€β’€β£ β ‹β šβ ‰β β €β €β €β €β €β €β €β €β β ˆβ‘žβ €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘€β €β‘€β ”β œβ ˆβ β ‰β €β €β €β €β €β €β €β €β €β €β €β €β €β €β β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β’„β£°β ™β Žβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
   acceptance_rate    β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β ΄β ’β ‰β žβ ‰β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β‘ β ƒβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⑔⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
                      β”‚β €β €β €β €β €β €β €β €β €β €β €β£€β’€β ƒβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β €β €β €β €β €β €β €β‘ β‘„β‘”β šβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β €β €β‘ β ”β ‰β ‰β ‰β €β ˆβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β”‚β ˆβ “β ƒβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                    0 β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β €0β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €90β €
                      β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €epochβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €

Step4: Analyse results

After training in Step3, you can load a trained model you specify and calculate zero-momentum two point functions.

using CUDA, Flux, ParameterSchedulers # require to call restore function
using GomalizingFlow, Plots, ProgressMeter
backend = unicodeplots() # select backend
# You can also call `gr()`
# backend = gr()

r = "result/example2d"
# r = "result/example3d"

trained_model, history = GomalizingFlow.restore(r);

hp = GomalizingFlow.load_hyperparams(joinpath(r, "config.toml"))

lattice_shape = hp.pp.lattice_shape
cfgs = Flux.MLUtils.batch(history[:x][2000:end]);
T = eltype(cfgs)

y_values = T[]
@showprogress for t in 0:hp.pp.L
    y = GomalizingFlow.mfGc(cfgs, t)
    push!(y_values, y)
end
plot(0:hp.pp.L, y_values, label="AffineCouplingLayer")

The result should be:

julia> plot(0:hp.pp.L, y_values, label="AffineCouplingLayer")
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     0.0366151 │⠀⑇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⒰⠀│ AffineCouplingLayer
               β”‚β €β‘Ώβ‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β ‡β €β”‚
               │⠀⑇⒇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑸⠀⠀│
               β”‚β €β‘‡β ˜β‘„β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’ β ƒβ €β €β”‚
               β”‚β €β‘‡β €β’£β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘œβ €β €β €β”‚
               β”‚β €β‘‡β €β ˆβ‘†β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’°β β €β €β €β”‚
               │⠀⑇⠀⠀Ⓒ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑇⠀⠀⠀⠀│
               │⠀⑇⠀⠀⠀⒇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⑸⠀⠀⠀⠀⠀│
               β”‚β €β‘‡β €β €β €β ˜β‘„β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β ‡β €β €β €β €β €β”‚
               β”‚β €β‘‡β €β €β €β €β ˆβ’†β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘ β ƒβ €β €β €β €β €β €β”‚
               β”‚β €β‘‡β €β €β €β €β €β ˆβ’’β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘°β β €β €β €β €β €β €β €β”‚
               β”‚β €β‘‡β €β €β €β €β €β €β €β ±β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β‘œβ €β €β €β €β €β €β €β €β €β”‚
               β”‚β €β‘‡β €β €β €β €β €β €β €β €β ‘β ’β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β €β Šβ €β €β €β €β €β €β €β €β €β €β”‚
               β”‚β €β‘‡β €β €β €β €β €β €β €β €β €β €β ˆβ ‘β €β‘€β €β €β €β €β €β €β €β €β’€β‘ β ’β β €β €β €β €β €β €β €β €β €β €β €β €β”‚
   0.000588591 β”‚β €β‘‡β €β €β €β €β €β €β €β €β €β €β €β €β €β ˆβ ‰β ‘β ’β ’β €β ’β ’β ‰β ‰β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β €-0.24β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €8.24β €

See playground/notebook/julia/analysis_tool.md or playground/notebook/julia/hmc.md to get more examples.

Directory structure

Below is the directory structure of our project:

$ tree -d
.
β”œβ”€β”€ cfgs
β”œβ”€β”€ playground # The process of trial and error is documented.
β”‚Β Β  β”œβ”€β”€ notebook
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ julia
β”‚Β Β  β”‚Β Β  └── python
β”‚Β Β  └── pluto
β”œβ”€β”€ src # contains training script etc...
└── test # `make test` runs the package's test/runtests.jl file
    β”œβ”€β”€ assets
    └── pymod

Playground

There are lots of jupyter notebooks in playground/notebook/julia regarding our project. Readers can learn about the trial and error process that led to the release of the software. You can run Jupyter Lab server locally as usual via:

$ docker compose up lab
Creating gomalizingflowjl-lab ... done
Attaching to gomalizingflowjl-lab
# Some stuff happen
gomalizingflowjl-lab |
gomalizingflowjl-lab |     To access the server, open this file in a browser:
gomalizingflowjl-lab |         file:///home/jovyan/.local/share/jupyter/runtime/jpserver-1-open.html
gomalizingflowjl-lab |     Or copy and paste one of these URLs:
gomalizingflowjl-lab |         http://gomagomakyukkyu:8888/lab?token=xxxxxxxxxx
gomalizingflowjl-lab |      or http://127.0.0.1:8888/lab?token=xxxxxxxxxx # Click this link in your terminal

We track Jupyter Notebooks as .md with the power of jupytext rather than .ipynb.

Citation

Bibtex item can be obtained from iNSPIRE-HEP:

@article{Tomiya:2022meu,
    author = "Tomiya, Akio and Terasaki, Satoshi",
    title = "{GomalizingFlow.jl: A Julia package for Flow-based sampling algorithm for lattice field theory}",
    eprint = "2208.08903",
    archivePrefix = "arXiv",
    primaryClass = "hep-lat",
    month = "8",
    year = "2022"
}

Appendix