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, Species/SpeciesSet, 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.1.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.1.0
File Size Uploaded Provenance Actions
torchneat-0.1.0.tar.gz 172.6 kB With provenance Details for torchneat-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 379.5 kB

Release files / torchneat-0.1.0.tar.gz

Download URL torchneat-0.1.0.tar.gz
Size 172.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4cb7b2c93510809c8f1329cdac73cf36b053c6611229af27d73ca3746744c9e3
BLAKE2b-256 checksum
How to use checksums
29fc85188cb2938dcf7eb19d5f4362441efeddae6c2d8eeff445a1eac19482f0
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.1.0-py3-none-any.whl

Download URL torchneat-0.1.0-py3-none-any.whl
Size 206.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40a3a82b06db74646f06ffb7cc5b7fc31d0c32dc20453710e5e106b2ddb13526
BLAKE2b-256 checksum
How to use checksums
12bbb6c846e0b21d9c846f464890671a72de72e3e33046f2086ff4a7c02f00d9
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.1.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.1.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