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.1.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.1-py3-none-any.whl (167.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resdag-0.6.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d7e5983625d4cc02b182b8eb94a28c2a89b5d19f8fc7fc872282217466818bc8
MD5 4a9a96c5e7f6f574c239fa50ad93a207
BLAKE2b-256 a7a7139e9118d471bdbc825cf5330cb138e4e862913980ce62533fa752953e79

See more details on using hashes here.

Provenance

The following attestation bundles were made for resdag-0.6.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: resdag-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 167.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53dc01e6dd4e6ac9338d8bb02f40e2264b6ef4ad3e4b67cc5b3d9f7f9b5b5ce4
MD5 0b0340bebc3f9c152d0c9dd2af0983b5
BLAKE2b-256 f897b439866cb6074b5708f0994dd0fe4d9f1da55f143981b13b3f9969784f15

See more details on using hashes here.

Provenance

The following attestation bundles were made for resdag-0.6.1-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