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.
collectsupports a simple synchronous loop;collect_streamruns 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.
Arenaruns 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?
- Get started
- Understand sampling and injectable training
- Choose a game, algorithm, or built-in composition
- Run the examples
- Evaluate searched agents with Arena
- Add a Rust game or algorithm
- Read the complete documentation
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.2.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 | |
|---|---|---|---|
| reinfors-0.2.0.tar.gz | 288.8 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| reinfors-0.2.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| reinfors-0.2.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.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| reinfors-0.2.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| reinfors-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 15.7 MB
Release files / reinfors-0.2.0.tar.gz
| Download URL | reinfors-0.2.0.tar.gz |
|---|---|
| Size | 288.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfab3259d3c8406273403cbccca34e7c4a6787ab7dd952ae35ff37494c51c99a
|
|
BLAKE2b-256 checksum How to use checksums |
a14f0c875907bda74ef01b7a87e19629b2cef747fcd244178363696cc30d3707
|
| 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 18, 2026.
Transparency logRelease files / reinfors-0.2.0-cp310-abi3-win_amd64.whl
| Download URL | reinfors-0.2.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c95522434d874f07fc3be7c3d5cf0d8d40734176146f4909c7b7216c76953710
|
|
BLAKE2b-256 checksum How to use checksums |
cb72fd9cb8ca60cc89d750b112f5372317caf60dcc36a712b21c37aa71322ca3
|
| 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 18, 2026.
Transparency logRelease files / reinfors-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | reinfors-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b0896bb041c6d1c94b72544b06119866169673451e7ec4384ae7dade19d955f7
|
|
BLAKE2b-256 checksum How to use checksums |
3702b603973ea97fd5e5d877fbe03821468a69e34c6c0bbac3fedabea1929955
|
| 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 18, 2026.
Transparency logRelease files / reinfors-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | reinfors-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
cacbd5590ca42fde9e827df4f66f513991893229690d2598e41783fa18b149a4
|
|
BLAKE2b-256 checksum How to use checksums |
c38269c3b7ea27552b4b9685875fc6d4171e04f6deae1dffbdd6bac93ad8fee7
|
| 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 18, 2026.
Transparency logRelease files / reinfors-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | reinfors-0.2.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
01600dcc45871b61dc1875173887d9789a77127f50d26aeec21c3a44c6971701
|
|
BLAKE2b-256 checksum How to use checksums |
222d52ae921a6604d11424257f86222d3e2f9c974cf94758f54bce38bb278bdf
|
| 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 18, 2026.
Transparency logRelease files / reinfors-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | reinfors-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e8a2a4c2334fdac4afd02e386fdd7e461fb99f7ee2070e5e944dcab7b674cd04
|
|
BLAKE2b-256 checksum How to use checksums |
e7c7ac635581ace25fe5200e15b8b03a2d53f9da018d115a75d660232c22fe99
|
| 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 18, 2026.
Transparency log