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, A2C, TRPO, DQN) are included; environment design and fitness evaluation remain the caller's job.
Install
Python 3.10+. Install PyTorch first, from the wheel index that matches what you want, then TorchNEAT:
# CPU only (any OS; on Linux this avoids the multi-GB CUDA wheels)
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install torchneat
# NVIDIA GPU: use your driver's CUDA version from `nvidia-smi` (cu132 = CUDA 13.2), required on Windows
pip install torch --index-url https://download.pytorch.org/whl/cu132
pip install "torchneat[gpu]"
pip install "torchneat[logging]" # + runlytics logging for the RL trainers
pip install torchneat alone takes whatever PyTorch PyPI serves: the CUDA build on Linux, the CPU build on Windows
and macOS. [gpu] adds the numba/cupy/CUDA libraries pinned to the CUDA version of your NVIDIA driver, but never
changes your PyTorch build. torchneat-install detects the system and sets up PyTorch and the CUDA libraries for you
(--cpu to force CPU). See Installation and Troubleshooting.
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 NEAT backend with torchneat.set_device("cuda") or the TORCHNEAT_DEVICE environment
variable; torchneat.cuda_is_available() tells whether the GPU backend is usable. set_device does not move your
model: create the NeatParameters / NeatModules on the same device (device="cuda") so the backend can use the
weights in place. The numba CUDA occupancy warnings are hidden; set TORCHNEAT_PERF_WARNINGS=1 or use
with torchneat.perf_warnings(): to show them.
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
- Documentation site
- Installation: PyTorch wheel indexes, the
gpuextra,torchneat-install, memory model. - Troubleshooting: install, CUDA and performance problems.
- Benchmarking: CPU versus GPU backend benchmark script.
- 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.3.0
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.3.0.tar.gz | 199.8 kB | With provenance | Details for torchneat-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torchneat-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for torchneat-0.3.0-py3-none-any.whl |
Total release size: 436.6 kB
Release files / torchneat-0.3.0.tar.gz
| Download URL | torchneat-0.3.0.tar.gz |
|---|---|
| Size | 199.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4cfd9e14c21c788ffcd045e9315f915199d745d2ba9d55c9c18b6210266f49d4
|
|
BLAKE2b-256 checksum How to use checksums |
bd6a3684b1c9c6a39dd307e2ca031c677a587602dea673112b8ed12658c71558
|
| 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 26, 2026.
Transparency logRelease files / torchneat-0.3.0-py3-none-any.whl
| Download URL | torchneat-0.3.0-py3-none-any.whl |
|---|---|
| Size | 236.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bde388152b199db6cee36bc2b02f7f72cd30b231cb2afa76fc4e556bfd1dd94
|
|
BLAKE2b-256 checksum How to use checksums |
0b7b627aaed07a39a75f2f7666f01f338bf6e25b35aa21d95cc60f087d4bd4e0
|
| 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 26, 2026.
Transparency logSecurity for torchneat 0.3.0
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.3.0.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 26, 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.