quantax 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantax-0.1.1/LICENSE +21 -0
- quantax-0.1.1/PKG-INFO +15 -0
- quantax-0.1.1/README.md +14 -0
- quantax-0.1.1/docs/source/conf.py +39 -0
- quantax-0.1.1/pyproject.toml +24 -0
- quantax-0.1.1/quantax/__init__.py +22 -0
- quantax-0.1.1/quantax/global_defs.py +131 -0
- quantax-0.1.1/quantax/model/__init__.py +11 -0
- quantax-0.1.1/quantax/model/fermion_mf.py +588 -0
- quantax-0.1.1/quantax/model/neural_fermion.py +615 -0
- quantax-0.1.1/quantax/model/prod_nets.py +328 -0
- quantax-0.1.1/quantax/model/sign_nets.py +146 -0
- quantax-0.1.1/quantax/model/sum_nets.py +325 -0
- quantax-0.1.1/quantax/model/transformer.py +258 -0
- quantax-0.1.1/quantax/model/triangular_nets.py +200 -0
- quantax-0.1.1/quantax/nn/__init__.py +39 -0
- quantax-0.1.1/quantax/nn/activation.py +204 -0
- quantax-0.1.1/quantax/nn/initializers.py +110 -0
- quantax-0.1.1/quantax/nn/modules.py +212 -0
- quantax-0.1.1/quantax/nn/nqs_layers.py +201 -0
- quantax-0.1.1/quantax/operator/__init__.py +23 -0
- quantax-0.1.1/quantax/operator/common_operators.py +190 -0
- quantax-0.1.1/quantax/operator/operator.py +538 -0
- quantax-0.1.1/quantax/operator/site_operator.py +299 -0
- quantax-0.1.1/quantax/optimizer/__init__.py +18 -0
- quantax-0.1.1/quantax/optimizer/driver.py +98 -0
- quantax-0.1.1/quantax/optimizer/exact.py +41 -0
- quantax-0.1.1/quantax/optimizer/minsr.py +255 -0
- quantax-0.1.1/quantax/optimizer/solver.py +242 -0
- quantax-0.1.1/quantax/optimizer/supervised.py +111 -0
- quantax-0.1.1/quantax/optimizer/tdvp.py +404 -0
- quantax-0.1.1/quantax/sampler/__init__.py +10 -0
- quantax-0.1.1/quantax/sampler/metropolis.py +649 -0
- quantax-0.1.1/quantax/sampler/sampler.py +154 -0
- quantax-0.1.1/quantax/sampler/samples.py +97 -0
- quantax-0.1.1/quantax/sites/__init__.py +13 -0
- quantax-0.1.1/quantax/sites/cluster.py +70 -0
- quantax-0.1.1/quantax/sites/common_lattices.py +138 -0
- quantax-0.1.1/quantax/sites/lattice.py +221 -0
- quantax-0.1.1/quantax/sites/sites.py +324 -0
- quantax-0.1.1/quantax/state/__init__.py +4 -0
- quantax-0.1.1/quantax/state/fermion_mf.py +437 -0
- quantax-0.1.1/quantax/state/lanczos.py +52 -0
- quantax-0.1.1/quantax/state/state.py +275 -0
- quantax-0.1.1/quantax/state/variational.py +570 -0
- quantax-0.1.1/quantax/symmetry/__init__.py +17 -0
- quantax-0.1.1/quantax/symmetry/common_symmetries.py +321 -0
- quantax-0.1.1/quantax/symmetry/symmetry.py +422 -0
- quantax-0.1.1/quantax/utils/__init__.py +29 -0
- quantax-0.1.1/quantax/utils/array.py +161 -0
- quantax-0.1.1/quantax/utils/data.py +145 -0
- quantax-0.1.1/quantax/utils/function.py +213 -0
- quantax-0.1.1/quantax/utils/linalg.py +354 -0
- quantax-0.1.1/quantax/utils/measure.py +28 -0
- quantax-0.1.1/quantax/utils/sharding.py +22 -0
- quantax-0.1.1/quantax/utils/spins.py +182 -0
- quantax-0.1.1/quantax/utils/tree.py +105 -0
- quantax-0.1.1/quantax.egg-info/PKG-INFO +15 -0
- quantax-0.1.1/quantax.egg-info/SOURCES.txt +61 -0
- quantax-0.1.1/quantax.egg-info/dependency_links.txt +1 -0
- quantax-0.1.1/quantax.egg-info/requires.txt +6 -0
- quantax-0.1.1/quantax.egg-info/top_level.txt +5 -0
- quantax-0.1.1/setup.cfg +4 -0
quantax-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Chen Ao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
quantax-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantax
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Flexible neural quantum states based on QuSpin, JAX, and Equinox
|
|
5
|
+
Author: Christopher Roth
|
|
6
|
+
Author-email: Ao Chen <chenao.phys@gmail.com>
|
|
7
|
+
Requires-Python: <=3.13,>=3.10
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: numpy>=2.0.0
|
|
10
|
+
Requires-Dist: quspin>=1.0.0
|
|
11
|
+
Requires-Dist: matplotlib>=3.8.0
|
|
12
|
+
Requires-Dist: ml_dtypes>=0.4.0
|
|
13
|
+
Requires-Dist: jax>=0.4.34
|
|
14
|
+
Requires-Dist: equinox>=0.11.4
|
|
15
|
+
Dynamic: license-file
|
quantax-0.1.1/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<h1 align='center'>quantax</h1>
|
|
2
|
+
|
|
3
|
+
Flexible neural quantum states based on [QuSpin](https://github.com/QuSpin/QuSpin/tree/dev_0.3.8), [JAX](https://github.com/google/jax), and [Equinox](https://github.com/patrick-kidger/equinox).
|
|
4
|
+
|
|
5
|
+
[Documentation](https://chenao-phys.github.io/quantax)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Requires Python 3.10+, JAX 0.4.34+
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
git clone https://github.com/ChenAo-Phys/quantax.git
|
|
13
|
+
pip install ./quantax
|
|
14
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
import pathlib
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
|
|
10
|
+
|
|
11
|
+
# -- Project information -----------------------------------------------------
|
|
12
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
13
|
+
|
|
14
|
+
project = "Quantax"
|
|
15
|
+
copyright = "2024, Ao Chen"
|
|
16
|
+
author = "Ao Chen, Christopher Roth"
|
|
17
|
+
release = "0.1.1"
|
|
18
|
+
|
|
19
|
+
# -- General configuration ---------------------------------------------------
|
|
20
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
21
|
+
|
|
22
|
+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary"]
|
|
23
|
+
|
|
24
|
+
templates_path = ["_templates"]
|
|
25
|
+
exclude_patterns = []
|
|
26
|
+
|
|
27
|
+
autodoc_member_order = "bysource"
|
|
28
|
+
autosummary_generate = True
|
|
29
|
+
autosummary_generate_overwrite = False
|
|
30
|
+
default_role = "py:obj"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# -- Options for HTML output -------------------------------------------------
|
|
34
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
35
|
+
|
|
36
|
+
html_theme = "pydata_sphinx_theme"
|
|
37
|
+
#html_static_path = ["_static"]
|
|
38
|
+
html_use_relative_urls = True
|
|
39
|
+
html_baseurl = 'https://chenao-phys.github.io/quantax/'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quantax"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Flexible neural quantum states based on QuSpin, JAX, and Equinox"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Ao Chen", email = "chenao.phys@gmail.com" },
|
|
11
|
+
{ name = "Christopher Roth" }
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.10,<=3.13"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"numpy>=2.0.0",
|
|
16
|
+
"quspin>=1.0.0",
|
|
17
|
+
"matplotlib>=3.8.0",
|
|
18
|
+
"ml_dtypes>=0.4.0",
|
|
19
|
+
"jax>=0.4.34",
|
|
20
|
+
"equinox>=0.11.4"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["."]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from .global_defs import (
|
|
2
|
+
set_random_seed,
|
|
3
|
+
set_default_dtype,
|
|
4
|
+
get_default_dtype,
|
|
5
|
+
get_real_dtype,
|
|
6
|
+
get_subkeys,
|
|
7
|
+
PARTICLE_TYPE,
|
|
8
|
+
get_sites,
|
|
9
|
+
get_lattice,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from . import (
|
|
13
|
+
sites,
|
|
14
|
+
symmetry,
|
|
15
|
+
operator,
|
|
16
|
+
nn,
|
|
17
|
+
model,
|
|
18
|
+
state,
|
|
19
|
+
sampler,
|
|
20
|
+
optimizer,
|
|
21
|
+
utils,
|
|
22
|
+
)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from typing import Optional, Tuple
|
|
2
|
+
from functools import partial
|
|
3
|
+
import jax
|
|
4
|
+
import jax.numpy as jnp
|
|
5
|
+
import jax.random as jr
|
|
6
|
+
import equinox as eqx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
jax.config.update("jax_enable_x64", True)
|
|
10
|
+
jax.config.update("jax_default_matmul_precision", "float32")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
DTYPE = jnp.float64
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def set_default_dtype(dtype: jnp.dtype) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Set the default data type for the computation in quantax.
|
|
19
|
+
Recommended to be ``jnp.float64`` or ``jnp.complex128``. Default to ``jnp.float64``.
|
|
20
|
+
|
|
21
|
+
.. note::
|
|
22
|
+
This doesn't alter the computation inside `quantax.model`.
|
|
23
|
+
"""
|
|
24
|
+
if not (
|
|
25
|
+
jnp.issubdtype(dtype, jnp.floating)
|
|
26
|
+
or jnp.issubdtype(dtype, jnp.complexfloating)
|
|
27
|
+
):
|
|
28
|
+
raise ValueError("'dtype' should be float or complex types")
|
|
29
|
+
global DTYPE
|
|
30
|
+
DTYPE = dtype
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_default_dtype() -> jnp.dtype:
|
|
34
|
+
"""Return the default data type for the computation in quantax."""
|
|
35
|
+
return DTYPE
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_real_dtype() -> jnp.dtype:
|
|
39
|
+
"""Return the default real data type for the computation in quantax."""
|
|
40
|
+
return jnp.finfo(DTYPE).dtype
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def is_default_cpl() -> bool:
|
|
44
|
+
"""Return whether the default data type is complex."""
|
|
45
|
+
return jnp.issubdtype(DTYPE, jnp.complexfloating)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
KEY = None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def set_random_seed(seed: int) -> None:
|
|
52
|
+
"""
|
|
53
|
+
Set the initial random seed for the computation in jax.
|
|
54
|
+
Default to be a random number generated by numpy.
|
|
55
|
+
"""
|
|
56
|
+
global KEY
|
|
57
|
+
KEY = jr.key(seed)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@partial(jax.jit, static_argnums=1)
|
|
61
|
+
def _gen_keys(key, num: Optional[int] = None) -> Tuple[jax.Array, jax.Array]:
|
|
62
|
+
nkeys = 2 if num is None else num + 1
|
|
63
|
+
new_keys = jr.split(key, nkeys)
|
|
64
|
+
key = new_keys[0]
|
|
65
|
+
new_keys = new_keys[1] if num is None else new_keys[1:]
|
|
66
|
+
return key, new_keys
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_subkeys(num: Optional[int] = None) -> jax.Array:
|
|
70
|
+
"""
|
|
71
|
+
Get a certain number of jax PRNG keys as an array.
|
|
72
|
+
|
|
73
|
+
:param num:
|
|
74
|
+
The number of returned keys.
|
|
75
|
+
If ``num is None`` (default), then return only 1 key instead of an array of keys.
|
|
76
|
+
|
|
77
|
+
.. warning::
|
|
78
|
+
This function is not jittable, because it reads and writes the global key
|
|
79
|
+
stored in quantax.
|
|
80
|
+
"""
|
|
81
|
+
global KEY
|
|
82
|
+
if KEY is None:
|
|
83
|
+
set_random_seed(0)
|
|
84
|
+
KEY, new_keys = _gen_keys(KEY, num)
|
|
85
|
+
return new_keys
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class PARTICLE_TYPE(eqx.Enumeration):
|
|
89
|
+
r"""
|
|
90
|
+
The enums to distinguish different particle types.
|
|
91
|
+
|
|
92
|
+
0: spin
|
|
93
|
+
|
|
94
|
+
1: spinful_fermion
|
|
95
|
+
|
|
96
|
+
2: spinless_fermion
|
|
97
|
+
|
|
98
|
+
(Not implemented) 3: boson
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
spin = 0
|
|
102
|
+
spinful_fermion = 1
|
|
103
|
+
spinless_fermion = 2
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
from .sites import Sites, Lattice
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def get_sites() -> Sites:
|
|
110
|
+
"""
|
|
111
|
+
Get the `quantax.sites.Sites` used in the current program.
|
|
112
|
+
|
|
113
|
+
.. warning::
|
|
114
|
+
Unlike other NQS packages, in quantax the geometry graph and the hilbert space
|
|
115
|
+
is defined as a global constant which shouldn't be changed within a single program.
|
|
116
|
+
"""
|
|
117
|
+
sites = Sites._SITES
|
|
118
|
+
if sites is None:
|
|
119
|
+
raise RuntimeError("The `Sites` hasn't been defined.")
|
|
120
|
+
return sites
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def get_lattice() -> Lattice:
|
|
124
|
+
"""
|
|
125
|
+
Get the `quantax.sites.Lattice` used in the current program. This is similar to `get_sites`,
|
|
126
|
+
but will raise an error if the defined `Sites` is not a `Lattice`.
|
|
127
|
+
"""
|
|
128
|
+
sites = get_sites()
|
|
129
|
+
if not isinstance(sites, Lattice):
|
|
130
|
+
raise RuntimeError("Require a `Lattice`, but got a general `Sites`")
|
|
131
|
+
return sites
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .prod_nets import SingleDense, RBM_Dense, SingleConv, RBM_Conv, ResProd, SchmittNet
|
|
2
|
+
from .sum_nets import ResSum, ResSumGconv
|
|
3
|
+
from .transformer import ConvTransformer
|
|
4
|
+
from .sign_nets import SgnNet, MarshallSign, StripeSign, Neel120
|
|
5
|
+
from .triangular_nets import Triangular_Neighbor_Conv, Triangular_ResSum
|
|
6
|
+
from .fermion_mf import (
|
|
7
|
+
Determinant,
|
|
8
|
+
Pfaffian,
|
|
9
|
+
PairProduct,
|
|
10
|
+
)
|
|
11
|
+
from .neural_fermion import NeuralJastrow, HiddenPfaffian
|