Skip to main content

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

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchneat 0.2.0
File Size Uploaded Provenance Actions
torchneat-0.2.0.tar.gz 183.6 kB With provenance Details for torchneat-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torchneat 0.2.0
File Interpreter ABI Platform Actions
torchneat-0.2.0-py3-none-any.whl Python 3 none any Details for torchneat-0.2.0-py3-none-any.whl

Total release size: 403.1 kB

Release files / torchneat-0.2.0.tar.gz

Download URL torchneat-0.2.0.tar.gz
Size 183.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f83bf61e68d602080feda9069c9f45d8b88794a7029e7fede56109be1463dfe9
BLAKE2b-256 checksum
How to use checksums
e15799dd50f8072e8eeb3d9277f48bc1239d669aed4d461e2a4a369656ef3ea4
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 17, 2026.

Transparency log

Release files / torchneat-0.2.0-py3-none-any.whl

Download URL torchneat-0.2.0-py3-none-any.whl
Size 219.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12a3bcd99aec136bb6e9849e7426b35887c39a817ab73f31972084b3cd261636
BLAKE2b-256 checksum
How to use checksums
c2c54f38ceae2612347810645ff30b566291b216d0fd3f820dde9c16d0ebbb41
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 17, 2026.

Transparency log

Security for torchneat 0.2.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.

Select from 2 files

Attestation for torchneat-0.2.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 17, 2026.

Transparency log

A 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.

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