Skip to main content
KoopmanGraph logo

KoopmanGraph

Topology-aware Koopman autoencoders for forecasting and analyzing networked dynamics

Tests DOI PyPI version codecov Documentation Status License

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.

Encode → linear Koopman advance → decode architecture

Highlights

  • Topology-aware learning — GCN/GAT/hypergraph encoders and decoders, delay embeddings, dynamic topology, optional self-adaptive edges, and edge weights
  • Flexible dynamics — discrete, continuous-time, networked (koopman="graph"), hypergraph, global/local, and continuous-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, anomaly helpers, SINDy, and spectral clustering
  • Control and adaptation — additive/bilinear control, Koopman-MPC ([mpc]), online RLS adaptation, Kalman observation, and a Gymnasium RL wrapper
  • Research tooling — classical DMD-family baselines, lightweight GNN teaching baselines, conformal UQ, 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
# 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()}")

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

Epidemic truth versus KoopmanGraph forecast on a ring graph

SIR epidemic on a ring: truth vs forecast from examples/06_epidemic_ring.ipynb.

METR-LA aggregate RMSE for GraphKoopman versus STGCN, DCRNN, and Graph WaveNet teaching baselines

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

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 / predict forecasting 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

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.21468449},
  url          = {https://github.com/tjkessler/KoopmanGraph},
  version      = {0.6.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

koopman_graph-0.6.0.tar.gz (492.4 kB view details)

Uploaded Source

Built Distribution

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

koopman_graph-0.6.0-py3-none-any.whl (397.5 kB view details)

Uploaded Python 3

File details

Details for the file koopman_graph-0.6.0.tar.gz.

File metadata

  • Download URL: koopman_graph-0.6.0.tar.gz
  • Upload date:
  • Size: 492.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for koopman_graph-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d99dcb1698d062b9865c73181efccbc6ab607464655e30fd59201580e3ae224c
MD5 b24797b4307fa97eb2ade977f987e45e
BLAKE2b-256 1917b6b12fb5190132a6d780251c9e1eedfb6b94114d28abefc65626125591e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for koopman_graph-0.6.0.tar.gz:

Publisher: release.yml on tjkessler/KoopmanGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file koopman_graph-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: koopman_graph-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 397.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for koopman_graph-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73ae5f32a9600e1d2e0f8ff1c34eb92594562476ca42e7792cc2218623dd53cc
MD5 dd4fd45fdaab2b338469319956c45047
BLAKE2b-256 a5611255302321c4f25dd8b6d43f6155f1a513861a86bd786d99697cecab6642

See more details on using hashes here.

Provenance

The following attestation bundles were made for koopman_graph-0.6.0-py3-none-any.whl:

Publisher: release.yml on tjkessler/KoopmanGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page