KoopmanGraph
Topology-aware Koopman autoencoders for forecasting and analyzing networked dynamics
Documentation | Tutorials | API | Contributing | Citation
KoopmanGraph is an open-source PyTorch Geometric library for learning topology-aware Koopman autoencoders on graphs. GNN encoders lift node features into a latent space, a learned linear operator advances those states, and a matching decoder reconstructs physical node features for multi-step forecasting and spectral analysis.
It is aimed at researchers studying networked dynamical systems—smart grids, traffic networks, epidemic contact graphs, and similar domains—who want an inspectable linear latent operator instead of a flat-vector Koopman model or a purely nonlinear GNN forecaster.
Why KoopmanGraph?
Koopman theory maps nonlinear dynamics into a linear latent domain where multi-step forecasting and spectral analysis are natural. Existing deep Koopman packages typically ignore graph structure, while spatiotemporal GNN forecasters usually lack an explicit linear latent operator.
KoopmanGraph bridges that gap with GNN lifting/decoding, an inspectable Koopman matrix K, row-state latent advance $z \leftarrow z K^{\top}$, and a PyTorch Geometric-native fit / predict workflow.
The library sits in the consistent Koopman autoencoder lineage and is not claimed as a new theoretical contribution; it packages topology-aware lifting, linear latent evolution, and analysis tooling for networked dynamical systems.
Highlights
- Topology-aware learning — GCN/GAT/hypergraph encoders and decoders, delay embeddings, dynamic topology, optional self-adaptive edges, sheaf / cell / simplicial lifts, and a predicted-topology head (distinct from static AdaptiveAdjacency)
- Flexible dynamics — discrete, continuous-time, networked (
koopman="graph"), hypergraph, multiplex hetero, global/local, Hodge-structured, switched, and mixture operators, with soft, structural, stochastic, or symplectic parameterizations - Forecasting stack — multi-step rollout, consistency losses, temporal evaluation metrics, checkpointing, and restricted
torch.export/ TorchScript (fixed-topology homogeneous MVP) - Spectral analysis — eigendecomposition, mode shapes, finite ResDMD on
evaluate, optionalSpectralDiagnostics(Nyquist $1/(2\Delta t)$ in cycles per unit time, $\kappa(V)$, aliasing flags), Kronecker dispersion, dynamical similarity, anomaly helpers, and optional 0-d TDA extras - Identification (opt-in) — closed-form ridge / TLS / constrained least squares for discrete dense per-node $K$; default
fitremains Adam; residual-aware dictionary gating and a frozen-encoding rank grid (not Ray Tune forlatent_dim) - Identity-bound benchmarks — frozen manifests and
koopman-graph benchmark run/verifyon hashed smoke fixtures; the runner does not train a model or invent MAE / RMSE, and it is not a LibCity / BasicTS host - Control and adaptation — additive/bilinear control, iterated-QP Koopman-MPC (
[mpc]), residual-tube tightening, online RLS adaptation, Kalman observation, and a Gymnasium RL wrapper - Research tooling — classical DMD-family baselines, teaching GNN ports plus LibCity/BasicTS protocol adapters, GraphVAMP / alanine-dipeptide teaching fetch, conformal UQ, and a $K^2$ VAE MVP
- Optional distributed trainers — native DDP /
torchrun, Lightning Fabric, Ray ensemble helpers, opt-in multi-node Ray recipe (KOOPMAN_GRAPH_MULTINODE=1), and in-tree FedAvg ([federated])
Full inventory: Capabilities · Architecture
Scope. KoopmanGraph targets topology-aware Koopman autoencoders on graphs and hypergraphs. Leaderboard adapters follow named protocols; they are not dedicated-library SOTA. Sheaf / cell / Hodge / TopologicX-bridge paths keep a linear Koopman head. GraphVAMP and the alanine-dipeptide fetch are teaching / diagnostic — not Folding@home-scale MD. Measured limits (finite ResDMD, restricted export, federated-not-DP, conservation on $K$ not decoded $x$) are consolidated in Scope and limitations.
Installation
Requires Python 3.10+, PyTorch, and PyTorch Geometric. Install those first, then:
pip install koopman-graph
# or: uv pip install koopman-graph
See the installation guide for editable installs, uv workflows, docs builds, and platform-specific wheels. Release notes: CHANGELOG.md.
Quickstart
import torch
from koopman_graph import GNNDecoder, GNNEncoder, GraphKoopmanModel
from koopman_graph.datasets import SyntheticDynamicGraphBenchmark
data_sequence = SyntheticDynamicGraphBenchmark.generate(
num_nodes=20,
num_timesteps=30,
in_channels=3,
seed=42,
noise_std=0.01,
)
encoder = GNNEncoder(3, 64, 64)
decoder = GNNDecoder(64, 64, 3)
model = GraphKoopmanModel(
encoder=encoder,
decoder=decoder,
latent_dim=64,
time_step=0.1,
)
torch.manual_seed(0)
history = model.fit(data_sequence, epochs=20, lr=1e-3)
future_graphs = model.predict(data_sequence[0], steps=5)
spectrum = model.spectrum()
print(f"Final loss: {history.loss[-1]:.6f}")
print(f"Predicted {len(future_graphs)} snapshots, shape: {future_graphs[0].x.shape}")
print(f"K eigenvalues: {tuple(spectrum.eigenvalues.shape)}")
print(f"Top |λ|: {spectrum.magnitudes[:3].tolist()}")
The constructor factory-builds a discrete per-node KoopmanOperator. Pass koopman="graph" when edge_index should enter the linear step (defaults are otherwise unchanged):
graph_model = GraphKoopmanModel(
encoder=encoder,
decoder=decoder,
latent_dim=64,
time_step=0.1,
koopman="graph",
)
Expected output:
Final loss: <float>
Predicted 5 snapshots, shape: torch.Size([20, 3])
K eigenvalues: (64,)
Top |λ|: [<float>, <float>, <float>]
More detail: Quickstart guide · API reference
See it in action
SIR epidemic on a ring: truth vs forecast from examples/06_epidemic_ring.ipynb.
METR-LA aggregate RMSE: GraphKoopman leads (0.6551 vs 0.7076 / 1.0754 / 0.9036) against in-repo STGCN / DCRNN / Graph WaveNet teaching baselines (unequal budgets; not dedicated-library SOTA) from examples/22_gnn_forecaster_comparison.ipynb.
Featured tutorials: 01 synthetic · 03 traffic · 06 epidemic · 22 GNN baselines · 37 topology transfer · 39 hetero RelGraph · 42 teaching baselines · 47 benchmark manifests · 48 identification · full gallery
Learn more
- Quickstart — train / predict walkthrough
- Capabilities — feature inventory and datasets
- Scope and limitations — when not to use; measured boundaries
- Architecture — public vs power-user API layers
- Benchmarks — identity-bound manifests (not trained scores)
- Identification — opt-in closed-form $K$ versus Adam
- FAQ / troubleshooting — install, imports, checkpoints
- Installation — dependencies, install paths, and CI platforms
- CLI —
koopman-graph train/predict/benchmarkconfig workflow - SECURITY.md — supported versions and checkpoint trust boundaries
- What’s new in 0.16.0: mass-action reaction-network datasets
(
ReactionNetworkBenchmark,koopman_graph.datasets.reaction) with oracle equilibria, conservation laws, and kinetic timescales; optional[reaction](SciPy stiff solvers) and[cantera]extras — defaults unchanged vs 0.15.0; see CHANGELOG.md.
Related software
- PyKoopman, PyDMD, kooplearn, and DLKoopman target vector-valued Koopman / DMD / operator-learning workflows; they treat the state as a flat vector rather than propagating information along graph edges.
- PyTorch Geometric provides mature GNN infrastructure on irregular graphs; KoopmanGraph adds an explicit linear latent operator, consistency losses, and a documented
fit/predictforecasting stack on that substrate. - Spatiotemporal GNN forecasters such as STGCN, DCRNN, and Graph WaveNet typically learn nonlinear convolutional or recurrent maps on graphs; KoopmanGraph instead advances an inspectable linear Koopman matrix K (see in-repo teaching baselines in examples/22).
Community and citation
- Contribute, report issues, or seek support: CONTRIBUTING.md · Support · Code of Conduct
- Install / runtime troubleshooting: FAQ
- Security vulnerabilities (private): SECURITY.md
- Development checks and release process: CONTRIBUTING.md
If you use KoopmanGraph in research, please cite:
@software{koopmangraph2026,
author = {Travis Kessler},
title = {KoopmanGraph: Topology-Aware Koopman Autoencoders for Networked Dynamics},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.22045904},
url = {https://github.com/tjkessler/KoopmanGraph},
version = {0.16.0},
}
License
KoopmanGraph is released under the Apache License 2.0.
Metadata
Release files for koopman-graph 0.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| koopman_graph-0.16.0.tar.gz | 863.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| koopman_graph-0.16.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.9 MB
Release files / koopman_graph-0.16.0.tar.gz
| Download URL | koopman_graph-0.16.0.tar.gz |
|---|---|
| Size | 863.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d5ab6ca84f811f4246e9ce589ab206446759bd7ddc35cca2eed1937fcab28ab
|
|
BLAKE2b-256 checksum How to use checksums |
8ba21eec585f72ee656180ebe8e3e6b8e07696aa3d80a755c119fbf6d3049115
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / koopman_graph-0.16.0-py3-none-any.whl
| Download URL | koopman_graph-0.16.0-py3-none-any.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc1359c909285ae9b2d3adf287e9420e68b645e7884d624c52214fd3a552dc36
|
|
BLAKE2b-256 checksum How to use checksums |
bd884cbba783bae462047f294c4fc45640abb5261e5949eaa781a85d59bf6941
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log