Skip to main content

PyTorch-native reservoir computing library with GPU acceleration

Project description

ResDAG

ResDAG

Reservoir computing for PyTorch.
Compose reservoir models as DAGs, train readouts with a single algebraic solve, run it all on the GPU.

PyPI Python Documentation MIT


ResDAG treats reservoir models — echo state networks and beyond — as ordinary PyTorch layers. Reservoirs, readouts, and transforms are nn.Modules wired together with a functional API; training a readout is one teacher-forced pass and one conjugate-gradient ridge solve, with no epochs. Models move with .to(device), serialize with state_dict(), and embed in larger PyTorch pipelines, optimizers included.

Documentation →

Installation

pip install resdag            # core
pip install "resdag[hpo]"     # + Optuna hyperparameter optimization

Python ≥ 3.11, PyTorch ≥ 2.10.

Try it

A reservoir forecaster on a toy signal, end to end:

import torch
import resdag as rd

t = torch.linspace(0, 60, 3000)
data = torch.sin(t).reshape(1, -1, 1)            # (batch, time, features)

warmup, train, target, f_warmup, val = rd.utils.prepare_esn_data(
    data, warmup_steps=100, train_steps=2000, val_steps=300)

model = rd.models.classic_esn(reservoir_size=300, feedback_size=1, output_size=1)
rd.ESNTrainer(model).fit((warmup,), (train,), targets={"output": target})

prediction = model.forecast(f_warmup, horizon=300)   # autoregressive, (1, 300, 1)

The first forecast walkthrough does the same on the Lorenz attractor, with the math explained.

Compose, don't configure

Architectures are DAGs you wire, not options you toggle. Two reservoirs on different timescales, read out together:

from resdag import CGReadoutLayer, Concatenate, ESNModel, reservoir_input
from resdag.layers import ESNLayer

inp    = reservoir_input(3)
fast   = ESNLayer(64, feedback_size=3, leak_rate=1.0, spectral_radius=0.9)(inp)
slow   = ESNLayer(64, feedback_size=3, leak_rate=0.2, spectral_radius=0.9)(inp)
merged = Concatenate()(fast, slow)
model  = ESNModel(inp, CGReadoutLayer(128, 3, name="output")(merged))

Two parallel reservoirs feeding one readout

Branches, feature augmentations, and multiple readout heads compose the same way — one reservoir, squared-state augmentation, two heads:

Augmented states feeding two readout heads

All heads fit in a single pass, in dependency order. The composition handbook covers the patterns.

Documentation

Start Install, a first trained forecaster, the mental model
Build Layers, readouts, architectures, topologies, initializers
Work Training paths, forecasting with drivers, tuning, GPU
Theory Every equation, stated against the code
Reference The full public API

Ecosystem

Built on pytorch_symbolic for graph composition. Pairs with TSDynamics, a companion library of dynamical systems — it generates the systems, ResDAG forecasts them.

Contributing

See CONTRIBUTING.md — releases are automated from conventional commits, and most component types are one registry decorator away.

License

MIT — © Daniel Estevez-Moya

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

resdag-0.6.0.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

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

resdag-0.6.0-py3-none-any.whl (166.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resdag-0.6.0.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for resdag-0.6.0.tar.gz
Algorithm Hash digest
SHA256 de77181f40637a477b1bfafa9fd178c8830fbf61b93eb4c4e3a339bcc0e10333
MD5 b6e44139d591645ff9bfb5037bee53a1
BLAKE2b-256 dd9b4d19abb516f8bb92e0a95cb5ad80d51c4706157cb7fbe7cbbba6d3020715

See more details on using hashes here.

Provenance

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

Publisher: release.yml on El3ssar/ResDAG

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

File details

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

File metadata

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

File hashes

Hashes for resdag-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b7fcdda3c81bd3bd2d7523c9ddadf80438573571cd87dec75cd35f1afe484e
MD5 64aea7233f9a4649a6fc433248265243
BLAKE2b-256 3aa5e3ca02770069414f0cc8cf92bed980199637f73dc577b273e567c9ce57d1

See more details on using hashes here.

Provenance

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

Publisher: release.yml on El3ssar/ResDAG

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

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