Skip to main content

Animated reinfors logo

High-throughput reinforcement-learning search and sampling in Rust, with caller-owned Python networks and training.

Reinfors runs game dynamics, search, episode orchestration, and batch assembly in a parallel Rust backend. Your inference callback is the boundary: it receives pooled NumPy observations and returns model outputs, so the network, framework, optimizer, replay, hardware placement, and distributed topology remain yours.

Benchmarked against OpenSpiel's all-C++ libtorch AlphaZero on a matched chess training workload — two-hour rounds at each stack's best measured configuration, then head-to-head play between the resulting models — reinfors sustained 9.9% higher training throughput, and its trained networks scored 0.605 ± 0.020 against OpenSpiel's over 300 paired games (+74 Elo). Protocol, evidence, and full results: reinfors-benchmarks.

Reinfors is not designed to maximize throughput at any cost or to outperform a bespoke, fully fused JAX/XLA pipeline on the fixed workload it specializes for. It targets a practical balance: native simulation, search, and batching, while games, algorithms, networks, and deployment remain modular enough for broad experimentation.

import numpy as np
import reinfors as rf

game = rf.games.Connect4()
engine = rf.Engine(
    game=game,
    reward=rf.Reward(win=1.0, loss=-1.0),
    policy=rf.policies.Minimax(depth=4),
    learner=rf.learners.TreeStrap(),
    n_games=32,  # parallel episode slots
    seed=0,
)

actions = game.action_space().n

def infer(obs: np.ndarray) -> np.ndarray:
    # The network is the search's evaluation function: it scores every frontier leaf,
    # pooled across games. Replace with PyTorch, JAX, an accelerator service, or any
    # other backend; TreeStrap's targets train it toward its own deeper search results.
    return np.zeros((len(obs), 1, actions), dtype=np.float32)

batch = engine.collect(n_records=1024, infer=infer)
print(batch.obs.shape, batch.targets.shape, batch.telemetry)

Why reinfors?

  • Search and sampling are native, multithreaded, and batch network requests across games and search leaves.
  • collect supports a simple synchronous loop; collect_stream runs parallel Rust search concurrently with Python training, with configurable queueing and bounded backpressure.
  • Networks are injectable per player and are not tied to a framework or device topology.
  • Arena runs paired evaluation matches across concurrent slots, pooling native search while subprocess-backed external agents compute on bounded worker lanes.
  • Composable Rust traits make new games and algorithms straightforward to add, with safer, simpler native extension than comparable C++ infrastructure.
  • Game semantics cover single- and multi-agent, zero-sum, cooperative, and general-sum tasks; one-shot and multi-step environments; turn-taking or simultaneous decisions; explicit chance; and perfect or imperfect information.
  • Algorithms span policy-driven value learning, search-guided learning, and standalone game-theoretic solving; see the algorithm catalogue for current implementations.
  • Resolved configurations, snapshots, structured batches, and telemetry support reproducible experiments.

Install

pip install reinfors

Optional adapters and training dependencies are separate:

pip install "reinfors[gym]"   # Gymnasium and PettingZoo adapters
pip install "reinfors[train]" # PyTorch examples

Contributing or building from source? Start with the contributing guide and the development setup guide.

Where next?

Stability

reinfors is pre-1.0: any 0.x release may change any API, behavior, or serialized format (including snapshot and config layouts) without deprecation. Pin an exact version (reinfors==0.x.y) and read release notes when upgrading. What does hold at every version: constructors validate their inputs, and no public Python input reaches a Rust panic — both enforced by adversarial test sweeps in CI.

Citation

If you use reinfors in your research, cite it via the repository's CITATION.cff (GitHub's "Cite this repository" button renders it as BibTeX/APA). What reinfors itself builds on is catalogued in References.

License

Licensed under either of MIT or Apache-2.0, at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work shall be dual-licensed as above, without any additional terms or conditions.

Metadata

Release files for reinfors 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 reinfors 0.1.0
File Size Uploaded
reinfors-0.1.0.tar.gz 282.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for reinfors 0.1.0
File
reinfors-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
reinfors-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
reinfors-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
reinfors-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
reinfors-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 14.6 MB

Release files / reinfors-0.1.0.tar.gz

Download URL reinfors-0.1.0.tar.gz
Size 282.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4eb84f4794701ab59f8cbda9d374eb1068e68eb1c465ed20b34c9c66879e32b5
BLAKE2b-256 checksum
How to use checksums
d7f8123628c78e7278948bded4be198ea2de1e2336e00cceb7ac83e498ca9d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release files / reinfors-0.1.0-cp310-abi3-win_amd64.whl

Download URL reinfors-0.1.0-cp310-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7410c7597bf2001e96391afbfe62e770ae9554832f6b6a9e208e55c1de916df6
BLAKE2b-256 checksum
How to use checksums
08a06204d296bb8883a45cd005dc786c5c4488adc25667c48359ca14901be1c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release files / reinfors-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL reinfors-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1eaa34ccb7c23409c8ab8e1052d8ad218ff6b195e4ad44ec7d29d8f752ceb07c
BLAKE2b-256 checksum
How to use checksums
56da2043f1d81494c94775173b89fe7a6fd942421ee48d77e28c915c09c53a2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release files / reinfors-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL reinfors-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
90352d070cfebd150e11b774ada8b077366bad4fba1b86aa7e4bb75dd433e435
BLAKE2b-256 checksum
How to use checksums
162aaf8341a9ab807faf6f1194f3899f27d20c877cf6aaa650dbc4586104db2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release files / reinfors-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL reinfors-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
43ecbb72a5c5191b63d9479cc3b54f65300ab9c9e2001e6a7281689d6060ba82
BLAKE2b-256 checksum
How to use checksums
bc06eda95d9107742b1309f2f4ef8dc40c76aa5fd11556f0c2be4e0d06a4999f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release files / reinfors-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL reinfors-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.9 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
33b05689d910a7e7ae3f6de381ed59f718e522f0a9543abd8724df75c93efcdd
BLAKE2b-256 checksum
How to use checksums
0b1a7c7c8348b12404c87ae829b154dbad32198488d8f441a8d0ae2ec70942de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Aug 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

6 release files

0.3.0

6 release files

0.2.0

6 release files

This release

0.1.0 This release

6 release files

0.0.1

2 release files

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