Skip to content
ludogiorgiPublic

About

Stationary-score stochastic reduced-order models for quasi-geostrophic turbulence, with GFDT mobility calibration.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

QG-ROM

Train a stationary score neural network and a GFDT-calibrated stochastic reduced model from quasi-geostrophic turbulence trajectories.

QG Fourier trajectories → normalization → stationary score → equilibrium samples
                                                              ↓
                        ROM trajectories ← mobility M = D + R

The score is trained at one small noise level. A bounded neural correction to a Gaussian log density gives a conservative, confining score. The mobility has a positive symmetric diffusion and an antisymmetric current, calibrated with generalized fluctuation–dissipation identities. Julia or another solver can supply the data through the file interface; training and calibration use Python/PyTorch.

This repository provides a data-to-model training workflow and the selected hyperparameters for the K16 QG case. Supply your own stationary QG trajectories; training starts from a Gaussian model fitted to those data. The scope is model construction and validation, rather than reproducing individual paper figures.

The method is described in Ludovico Theo Giorgini's Score-based stochastic reduced-order models of barotropic quasi-geostrophic turbulence (2026).

Install

Python 3.10 or newer. For the CPU example on Linux:

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install 'torch>=2.5,<3' --index-url https://download.pytorch.org/whl/cpu
python -m pip install -e .
qgrom --help

For another platform or CUDA, replace the PyTorch installation command with the one from the PyTorch installation selector for your machine before installing this package. Each compute command accepts --device cuda. On a shared multi-GPU machine, select a GPU by UUID through CUDA_VISIBLE_DEVICES; the command prints the device name and UUID. CPU is the default.

A small working example

The example generates synthetic rotating Ornstein–Uhlenbeck trajectories in the same coordinate layout as QG data. It exercises the software on a CPU in seconds; its short training and sampling budgets are intended for a software example. Run these commands from the repository root:

python examples/make_demo_data.py --output data/demo
qgrom prepare data/demo/manifest.json --config configs/demo.yaml --output outputs/demo/prepared
qgrom train-score outputs/demo/prepared --config configs/demo.yaml --output outputs/demo/score
qgrom sample outputs/demo/score/score.pt --config configs/demo.yaml --output outputs/demo/equilibrium
qgrom fit-mobility outputs/demo/prepared outputs/demo/score/score.pt outputs/demo/equilibrium/states.npy --config configs/demo.yaml --output outputs/demo/mobility
qgrom simulate outputs/demo/score/score.pt outputs/demo/mobility/mobility.npz --initial outputs/demo/equilibrium/states.npy --config configs/demo.yaml --output outputs/demo/rom
qgrom diagnose outputs/demo/prepared outputs/demo/score/score.pt outputs/demo/rom --output outputs/demo/diagnostics

Each output directory must be new. Reuse an earlier stage by passing its artifacts to the next command; choose a new output directory when changing settings.

Train on QG data

  1. Export stationary trajectories as independent .npy files and a JSON manifest, following the data contract. The small export example accepts compact complex Fourier coefficients from an existing simulation.
  2. Replace the demo manifest and configuration in the commands above with your data and configs/qg_k16.yaml. Adjust sampling and training budgets for the available trajectories and hardware.
  3. Inspect the validation DSM loss, HMC diagnostics, optimizer convergence, and selected mobility penalties. The diagnose command opens the held-out test trajectories only when explicitly requested.

The best-found settings are a parameter record. Use the runnable qg_k16.yaml as CLI input. The selected score used successive fine-tuning stages; the parameter record includes that training history. Starting from scratch follows a different optimization path, so validate the resulting model independently.

The physical energy-injection constraint is optional in the general configuration. Set it from the forcing statistics of the supplied QG dataset. The numerical bounds recorded for the reference case are specific to its units and forcing.

Repository map

Location Purpose
src/qgrom/data.py Data validation, trajectory splits, normalization
src/qgrom/score.py, train.py Conservative periodic U-Net and fixed-noise DSM
src/qgrom/sampling.py Replica-exchange HMC for equilibrium moments
src/qgrom/features.py, calibration.py GFDT moments, diffusion fit, current fit
src/qgrom/mobility.py, simulation.py Analytic mobility and split ROM integrator
configs/ Runnable examples and selected reference settings
docs/ Data, method, configuration, development
tests/ Independent algebra checks and a complete CLI example

Development and validation

Install the development tools and run the checks:

python -m pip install -e '.[dev]'
python -m pytest -q
ruff check src tests examples
ruff format --check src tests examples
python -m build

Tests check Fourier normalization, the conservative score, diffusion positivity, energy tangency, analytic divergence and Stratonovich corrections, GFDT matrix orientation, Galerkin moments, checkpoint serialization, data separation, and the complete data-to-ROM workflow. They establish implementation consistency. HMC mixing, physical PDFs and correlations, and timestep convergence must be assessed for each fitted QG model.

The validation note describes numerical comparisons, independent installation checks, and a short QG training run with its accuracy limitations. The pilot configuration exercises the full K16 architecture with a small computational budget.

For maintenance and extensions, see Contributing and the development guide.

Data, checkpoints, and outputs belong outside version control.

Citation

If you use this software in your research, please cite:

Ludovico Theo Giorgini (2026). Score-based stochastic reduced-order models of barotropic quasi-geostrophic turbulence. arXiv:2609.34028.

@misc{giorgini2026qgrom,
  author        = {Giorgini, Ludovico Theo},
  title         = {Score-based stochastic reduced-order models of barotropic quasi-geostrophic turbulence},
  year          = {2026},
  eprint        = {2609.34028},
  archivePrefix = {arXiv},
  primaryClass  = {nlin.CD},
  doi           = {10.48550/arXiv.2609.34028},
  url           = {https://arxiv.org/abs/2609.34028}
}

CITATION.cff provides the preferred paper citation for GitHub and citation tools.

License

Released under the MIT License.

About

Stationary-score stochastic reduced-order models for quasi-geostrophic turbulence, with GFDT mobility calibration.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages