Foundation models and utilities for NetKet
Project description
NetKet Foundation
NetKet Foundation is an extension for NetKet to train and evaluate foundation neural quantum states over families of Hamiltonians parameterized by couplings or disorder realizations.
The library builds on top of NetKet's concepts (samplers, operators, logging, drivers) and introduces foundational workflows where one model is optimized across many parameter points at once.
Installation
You can install netket-foundation with pip or uv using one of the two commands below. We strongly recomend against using conda.
uv add netket-foundation
pip install --upgrade nektet-foundation
With GPU support (Linux only):
uv add netket-foundation 'netket[cuda]'
Development version:
uv add git+https://github.com/NeuralQXLab/netket_foundation.git
For detailed installation instructions of NetKet, including GPU setup, we refer to its installation guide.
Getting Started
To get started with NetKet Foundation, we recommend you give a look at our tutorials, by running them on your computer or on Google Colaboratory. There are also several example scripts that you can download, run and edit that showcase some use-cases of NetKet Foundation, although they are not commented.
If you want to get in touch with us, feel free to open an issue or a discussion here on GitHub, or to join the MLQuantum slack group where several people involved with NetKet hang out. The link is on NetKet's website.
New concepts:
Compared to base NetKet, this package introduces:
ParameterSpace: a Hilbert-space-like class describing the space where hamiltonian parameters live.FoundationalQuantumState: a variational state that samples physical configurations together with parameter replicas.ParametrizedOperator: operators whose matrix elements are generated from per-sample parameters.
Minimal Usage
1) Define a foundational state over a parameter range
import jax.numpy as jnp
import netket as nk
import netket_foundation as nkf
from netket_foundation._src.model.vit import ViTFNQS
hi = nk.hilbert.Spin(0.5, 10)
ps = nkf.ParameterSpace(N=1, min=0.8, max=1.2)
model = ViTFNQS(
num_layers=2,
d_model=12,
heads=4,
L_eff=hi.size // 2,
n_coups=ps.size,
b=2,
complex=False,
disorder=False,
transl_invariant=True,
two_dimensional=False,
)
sampler = nk.sampler.MetropolisLocal(hi, n_chains=2048)
vstate = nkf.FoundationalQuantumState(sampler, model, ps, n_replicas=8, seed=1)
# Define the coupling used during training
vstate.parameter_array = jnp.linspace(0.8, 1.2, vstate.n_replicas).reshape(-1, 1)
2) Build a parameter-dependent operator
import netket_foundation as nkf
def create_operator(params):
h = params[0]
ha_x = sum(nkf.operator.sigmax(hi, i) for i in range(hi.size))
ha_zz = sum(
nkf.operator.sigmaz(hi, i) @ nkf.operator.sigmaz(hi, (i + 1) % hi.size)
for i in range(hi.size)
)
return -h * ha_x - ha_zz
ham = nkf.operator.ParametrizedOperator(hi, ps, create_operator)
3) Optimize with foundational natural-gradient VMC
import optax
import netket_foundation as nkf
optimizer = optax.sgd(5e-3)
driver = nkf.VMC_SR(ham, optimizer, variational_state=vstate, diag_shift=1e-4)
driver.run(100)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netket_foundation-0.1.1.tar.gz.
File metadata
- Download URL: netket_foundation-0.1.1.tar.gz
- Upload date:
- Size: 76.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7ff4ccc14e84369ab18ea85d4ce1ea42e7a20f65f1c76dc5fccf6771dbc7236
|
|
| MD5 |
d8455da06256e71011e73be995fe5020
|
|
| BLAKE2b-256 |
9ad8e415ce90cc169cc2a5e07fd92a1182804e5f866670a2d02f2d6563ec6c60
|
Provenance
The following attestation bundles were made for netket_foundation-0.1.1.tar.gz:
Publisher:
release.yml on NeuralQXLab/netket_foundation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netket_foundation-0.1.1.tar.gz -
Subject digest:
d7ff4ccc14e84369ab18ea85d4ce1ea42e7a20f65f1c76dc5fccf6771dbc7236 - Sigstore transparency entry: 1789864262
- Sigstore integration time:
-
Permalink:
NeuralQXLab/netket_foundation@68511f9a25c6f4678801224416be1bb45e3643d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NeuralQXLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@68511f9a25c6f4678801224416be1bb45e3643d3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file netket_foundation-0.1.1-py3-none-any.whl.
File metadata
- Download URL: netket_foundation-0.1.1-py3-none-any.whl
- Upload date:
- Size: 99.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
979d5ac61bca00f086db45b406095abcc2d7e15e295d601473ff43fc76d70f03
|
|
| MD5 |
080945dedc485e0a0fe4830537e38e46
|
|
| BLAKE2b-256 |
40fa00445c2a9c7dc4bd794302fca55c77c6ea8b5cd9f78b0fe125515c08d567
|
Provenance
The following attestation bundles were made for netket_foundation-0.1.1-py3-none-any.whl:
Publisher:
release.yml on NeuralQXLab/netket_foundation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netket_foundation-0.1.1-py3-none-any.whl -
Subject digest:
979d5ac61bca00f086db45b406095abcc2d7e15e295d601473ff43fc76d70f03 - Sigstore transparency entry: 1789864357
- Sigstore integration time:
-
Permalink:
NeuralQXLab/netket_foundation@68511f9a25c6f4678801224416be1bb45e3643d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NeuralQXLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@68511f9a25c6f4678801224416be1bb45e3643d3 -
Trigger Event:
workflow_dispatch
-
Statement type: