Skip to main content

Boltzmann Generators in PyTorch: flows, energies, losses, and sampling utilities.

Project description

boltzmann-generators

CI PyPI version Python 3.11+ License: MIT

PyTorch tools for Boltzmann Generators: invertible flows, benchmark energy functions, BG losses, and reweighting diagnostics (ESS and free-energy differences). The project is designed for reproducible experiments on toy molecular systems and as a base for transferable BG research.

References

  1. Noé, Olsson, Köhler, Wu, Boltzmann Generators: Sampling Equilibrium States of Many-Body Systems with Deep Learning (Science, 2019): https://arxiv.org/abs/1812.01729
  2. Klein, Noé, Transferable Boltzmann Generators (NeurIPS, 2024): https://openreview.net/forum?id=AYq6GxxrrY
  3. Original reference implementation: https://github.com/noegroup/paper_boltzmann_generators

Installation

pip install boltzmann-generators

For notebooks and plots:

pip install "boltzmann-generators[notebook]"

For development:

pip install "boltzmann-generators[dev]"

For higher-accuracy CNF ODE integration:

pip install "boltzmann-generators[ode]"

Quickstart

import torch
from boltzmann_generators.energies import DoubleWell2D
from boltzmann_generators.flows import FlowModel, GaussianPrior, RealNVP
from boltzmann_generators.training import TrainConfig, Trainer

device = "cuda" if torch.cuda.is_available() else "cpu"

energy = DoubleWell2D()
prior = GaussianPrior(dim=2).to(device)
flow = RealNVP(dim=2, num_layers=8, hidden_dim=64, mask="halves").to(device)
model = FlowModel(prior, flow).to(device)

config = TrainConfig(n_epochs=200, batch_size=256, lr=1e-3, w_ml=0.0, w_kl=1.0)
trainer = Trainer(model, energy, config, device=device)
history = trainer.fit(x_data=None)
print("Final loss:", history[-1]["loss"])

Project layout

src/boltzmann_generators/
  base/                # EnergyModel and BaseDensityModel ABCs
  training/            # Trainer and loss strategy classes
  services/            # SamplingEngine, AnalysisSuite, CheckpointManager
  energies/            # double-well, Muller-Brown, Ramachandran-like energy
  flows/               # base flow API, RealNVP, CNF
  losses.py            # KL_x, KL_z, mixed loss (function wrappers)
  sampling.py          # weighted samples, ESS, free-energy difference
  mcmc.py              # Metropolis baseline sampler
  train.py             # deprecated train_bg wrapper
  analysis.py          # basin and population utilities

examples/notebooks/    # curated runnable examples
notebooks/             # end-to-end reproductions (02-07)

Reproduced results

Notebook System Metric Value
02 4-mode Gaussian mixture Final NLL 2.23 nats (target entropy: 2.13)
03 Double-well 2D (4 kT barrier) ESS / DeltaF 98% / +0.004 kT (target 0)
04 Muller-Brown (3 basins) ESS / populations 96% / target [80.37, 7.74, 11.89]%, BG [80.23, 7.71, 12.05]%
05 Double-well paper comparison ESS 92%
06 Gaussian mixture (CFM) Visual mode coverage All 4 modes recovered
07 Synthetic Ramachandran Visual + basin populations Reweighted BG close to ground truth

Documentation

If you need the original Noé group reference repository locally, clone it into:

git clone --depth 1 https://github.com/noegroup/paper_boltzmann_generators.git references/paper_boltzmann_generators

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boltzmann_generators-0.2.1.tar.gz (226.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boltzmann_generators-0.2.1-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file boltzmann_generators-0.2.1.tar.gz.

File metadata

  • Download URL: boltzmann_generators-0.2.1.tar.gz
  • Upload date:
  • Size: 226.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for boltzmann_generators-0.2.1.tar.gz
Algorithm Hash digest
SHA256 dd7a42d1402a96593fa8850b8ab8edae46b949288a0f3df032c4a8b42cc58657
MD5 ad4b32af0fa83742f3a1012b4175ef0a
BLAKE2b-256 0fd27175f0b06fdda731153510ab6e0bf7801469700dd71bf8136f5af1c56b77

See more details on using hashes here.

File details

Details for the file boltzmann_generators-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for boltzmann_generators-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19eaa4cebcd957c64868a06505935075548a83a85acee84b347942a4331943a6
MD5 725d957d61689f633126714bdeb9f1cb
BLAKE2b-256 7f8b75e94c59df3bd9ca1e79ed6f05030cf6e7482e3bcb1418ce05d3e4fba498

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page