KoopmanGraph
Graph Neural Networks with Koopman operator theory for spatiotemporal graph dynamics
Documentation | Tutorials | API | Contributing | Citation
KoopmanGraph is an open-source PyTorch library that combines Graph Neural Networks with Koopman operator theory to model spatiotemporal dynamics on graphs. Topology-aware encoders lift node features into a latent space, a learned linear Koopman operator advances latent states, and a matching decoder reconstructs physical node features.
It is a topology-aware alternative to vector-based Koopman methods, aimed at researchers working on smart grids, traffic networks, epidemic contact graphs, and related networked dynamical systems.
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 encoders and decoders, delay embeddings, dynamic topology, and edge weights
- Flexible dynamics — discrete, continuous-time, and networked (
koopman="graph") operators, with soft or structural stability modes - Forecasting stack — multi-step rollout, consistency losses, temporal evaluation metrics, and checkpointing
- Spectral analysis — eigendecomposition, mode shapes, dynamical similarity, and anomaly helpers
- Control and adaptation — additive/bilinear control, online RLS adaptation, Kalman observation, and a Gymnasium RL wrapper
- Research tooling — classical DMD-family baselines, lightweight GNN teaching baselines, and reproducible graph benchmarks
Full inventory: Capabilities · Architecture
Installation
Requires Python 3.10+, PyTorch, and PyTorch Geometric. Install those first, then:
pip install koopman-graph
See the installation guide for editable installs, 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()}")
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 vs in-repo STGCN / DCRNN / Graph WaveNet teaching baselines (not dedicated-library SOTA) from examples/22_gnn_forecaster_comparison.ipynb.
Featured tutorials: 01 synthetic · 03 traffic · 06 epidemic · 22 GNN baselines · full gallery
Learn more
- Quickstart — train / predict walkthrough
- Capabilities — feature inventory and datasets
- Architecture — public vs power-user API layers
- FAQ / troubleshooting — install, imports, checkpoints
- Installation — dependencies and install paths
- What’s new in 0.5.0: see CHANGELOG.md.
Related software
- PyKoopman and DLKoopman target vector-valued Koopman / deep-Koopman 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: Graph Neural Networks with Koopman Operator Theory},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.21420623},
url = {https://github.com/tjkessler/KoopmanGraph},
version = {0.4.0},
}
License
KoopmanGraph is released under the Apache License 2.0.
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 koopman_graph-0.5.0.tar.gz.
File metadata
- Download URL: koopman_graph-0.5.0.tar.gz
- Upload date:
- Size: 360.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c29ae4c34724490ce83a97f584f1713c940f8fc050a6981ee923e9d059c3ef0d
|
|
| MD5 |
ae45953574a05ee6e28351eac91479d9
|
|
| BLAKE2b-256 |
536c226154519acf9e9b1213ae901e20e062f2ddf6e60c88b36f1e30b3258f86
|
Provenance
The following attestation bundles were made for koopman_graph-0.5.0.tar.gz:
Publisher:
release.yml on tjkessler/KoopmanGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
koopman_graph-0.5.0.tar.gz -
Subject digest:
c29ae4c34724490ce83a97f584f1713c940f8fc050a6981ee923e9d059c3ef0d - Sigstore transparency entry: 2210719372
- Sigstore integration time:
-
Permalink:
tjkessler/KoopmanGraph@5e98df52e612a7ab2bf24ed313a242dc5bb31fbb -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/tjkessler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e98df52e612a7ab2bf24ed313a242dc5bb31fbb -
Trigger Event:
release
-
Statement type:
File details
Details for the file koopman_graph-0.5.0-py3-none-any.whl.
File metadata
- Download URL: koopman_graph-0.5.0-py3-none-any.whl
- Upload date:
- Size: 303.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fffd9d694bf5e6e09cc2506e0bfd20b93ef1f54e633042c10c93a11eb5bb3b4d
|
|
| MD5 |
27b5e0a0a83ca54169f6694e30ec028d
|
|
| BLAKE2b-256 |
e8d7cf1e49fea472ba222c3199876168b9b9f86c8704f54b56241e87430acf8a
|
Provenance
The following attestation bundles were made for koopman_graph-0.5.0-py3-none-any.whl:
Publisher:
release.yml on tjkessler/KoopmanGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
koopman_graph-0.5.0-py3-none-any.whl -
Subject digest:
fffd9d694bf5e6e09cc2506e0bfd20b93ef1f54e633042c10c93a11eb5bb3b4d - Sigstore transparency entry: 2210719386
- Sigstore integration time:
-
Permalink:
tjkessler/KoopmanGraph@5e98df52e612a7ab2bf24ed313a242dc5bb31fbb -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/tjkessler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e98df52e612a7ab2bf24ed313a242dc5bb31fbb -
Trigger Event:
release
-
Statement type: