TorchNEAT
TorchNEAT is a PyTorch-based neuroevolution library. It evolves the parameters of NeatModule models through
initialization, mutation, speciation and reproduction, on the CPU (numba) or on an NVIDIA GPU (numba.cuda / cupy).
RL trainers (NEAT, PPO) are included; environment design and fitness evaluation remain the caller's job.
TorchNEAT grew out of an earlier private project of the same author. This repository is a clean restructure; the old history is not carried over.
Install
Python 3.11 or newer.
pip install torchneat # CPU backend
pip install "torchneat[gpu]" # + CUDA backend (NVIDIA GPU)
pip install "torchneat[logging]" # + runlytics logging for the RL trainers
Quick start
import torch
import torchneat as neat
from torchneat import nn
class Policy(neat.nn.Model):
def __init__(self, inputs=4, hidden=16, outputs=2):
super().__init__()
self.net = nn.Sequential(
nn.Linear(inputs, hidden), nn.Tanh(), # NEAT-evolvable layer + wrapped PyTorch activation
nn.Linear(hidden, outputs),
)
def forward(self, state, keys=None):
return self.net(state, keys=keys)
config = neat.Config(file_name="demo", directory="demo")
population = neat.Population(100, Policy(), config)
Everything you normally take from torch.nn (activations, dropout, flatten, containers, ...) is re-exported from
torchneat.nn. Parameters that evolve use NeatParameter /
NeatModule; everything else is plain PyTorch.
Package layout
| Package | Contents |
|---|---|
torchneat.core |
Genome, Specie/Species, Stagnation, Reproduction, Population |
torchneat.backends |
device-independent init/reproduce/speciate orchestration, cpu/ and gpu/ kernels, seeding |
torchneat.nn |
NeatParameter, NeatModule, Model; layers, attention/transformer blocks, activations, PyTorch re-exports; legacy/ |
torchneat.rl |
NEAT and PPO trainers, rollout buffers, logger |
torchneat.config |
Config and its sections |
torchneat.optim |
hyper-parameter schedulers |
torchneat.reporting |
reporters and loggers |
torchneat.utils |
storage, console colours, timing, helpers |
Devices
CPU is the default. Choose the device with torchneat.set_device("cuda") or the TORCHNEAT_DEVICE environment
variable; torchneat.cuda_is_available() tells whether the GPU backend is usable.
Saving and loading
population.save(filename="experiment", directory="neat_save")
population.load(filename="experiment", directory="neat_save")
state = population.state_dict()
Checkpoints use pickle; only load files you trust.
Documentation
- Configuration: experiment settings and schedulers.
- Ancestry and GeneBank: lineage tracking and elite parent storage.
- Reinforcement learning: trainers, rollout behaviour and metrics.
Development
pip install -e ".[dev]"
pytest -m "not gpu" # CPU tests
pytest -m gpu # GPU tests (skipped when no CUDA device is usable)
See CONTRIBUTING.md, CHANGELOG.md and TODO.md.
Metadata
Release files for torchneat 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchneat-0.2.1.tar.gz | 184.2 kB | With provenance | Details for torchneat-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torchneat-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for torchneat-0.2.1-py3-none-any.whl |
Total release size: 404.1 kB
Release files / torchneat-0.2.1.tar.gz
| Download URL | torchneat-0.2.1.tar.gz |
|---|---|
| Size | 184.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbc9536ca2d651f9c9b69d5ead279074c60ed1a0ee324c85c3656a1043127b2c
|
|
BLAKE2b-256 checksum How to use checksums |
1fe7427dddff4d01875224bd0450ca6830a52add7dfde1f6d7d7dad0273bc2ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 18, 2026.
Transparency logRelease files / torchneat-0.2.1-py3-none-any.whl
| Download URL | torchneat-0.2.1-py3-none-any.whl |
|---|---|
| Size | 219.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9a5bc61d892e66895e2b8fa05937a917a6cda26e41af7f7c1b86b9e407cf39e
|
|
BLAKE2b-256 checksum How to use checksums |
c4eeb88db788c285d0ce3f2d93c60f85f593d81ad989e8b179c70d5b9a79d31d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 18, 2026.
Transparency logSecurity for torchneat 0.2.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for torchneat-0.2.1.tar.gz
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 Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.