Skip to main content

A fast distributed replay buffer for reinforcement learning.

Project description

echo

CI Docs PyPI Python

A very fast distributed replay buffer for reinforcement learning. The core is a lockfree, pre-allocated Rust ring buffer. Batches come back to Python as zero-copy numpy views, with the GIL released while you wait for the next batch.

Install

pip install id-echo

What it does

Distributed RL training pipelines typically have many hundreds or even thousands of rollout workers producing samples and a small number of learners consuming batches of them. echo exists because I found that data transfer and stacking was often the bottleneck of these systems. echo receives individual samples, assembles them into fixed-size batches, and serves those batches with minimal copying and no Python-side contention.

The core is a lockfree ring buffer written in Rust. Clients push samples into queues over the network, a pool of drainers moves data into the ring buffer, and the consumer pulls full batches out. Pytrees are flattened with optree on the client and unflattened on the python server. Rust itself is pytree-agnostic.

Features

  • Lockfree ring buffer, pre-allocated (no copies after ingress)
  • Extensible transports, ships with a custom TCP protocol (extendible to RDMA, gRPC, etc)
  • Pytree-shaped samples (nested dicts/tuples of numpy arrays) via optree
  • Zero-copy batches: sample() returns numpy views into Rust-owned memory
  • GIL released while waiting for batches
  • FIFO sampling (with more strategies planned)
  • Detailed metrics exposed per batch

Example

A typical setup runs the server on the learner node and clients on rollout workers (separate processes or machines). See more detailed examples in the documentation.

Learner side (one process):

import numpy as np
from echo import Server, TcpTransport

example = {
    "obs": np.zeros((4,), dtype=np.float32),
    "reward": np.zeros((1,), dtype=np.float32),
}

server = Server(example, batch_size=32, transport=TcpTransport(port=50051))
server.start()

for sample in server.dataset_iter():
    batch = sample.batch  # {"obs": (32, 4), "reward": (32, 1)}
    # ... feed to training step

Rollout worker side (one or many processes):

import numpy as np
from echo import TcpClient

example = {
    "obs": np.zeros((4,), dtype=np.float32),
    "reward": np.zeros((1,), dtype=np.float32),
}

client = TcpClient("localhost", 50051, example)
for _ in range(1000):
    client.send({
        "obs": np.random.randn(4).astype(np.float32),
        "reward": np.array([1.0], dtype=np.float32),
    })
client.close()

For in-process use (tests, benchmarks), omit the transport and call server.submit(data) directly.

Development

cargo test                       # Rust tests
uv run pytest python/tests/ -v   # Python tests
just bench                       # Benchmarks
just                             # List all commands

Name

The name is a nod to Reverb, DeepMind's RL replay buffer that inspired this project, an echo being a faster, simpler kind of reverberation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

id_echo-0.1.1.tar.gz (205.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

id_echo-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

id_echo-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (501.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

id_echo-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (448.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

id_echo-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (451.9 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file id_echo-0.1.1.tar.gz.

File metadata

  • Download URL: id_echo-0.1.1.tar.gz
  • Upload date:
  • Size: 205.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for id_echo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d80c7d5364248b9be812662c50973851d1de678d2fd54926be233e3493592993
MD5 8e32c865cac072c8c03eb0381de77490
BLAKE2b-256 2763e52cb1f3685c661002e18cbb7fb479fc512d4f0d4a62818f7d0363ac566c

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.1.tar.gz:

Publisher: release.yml on instadeepai/echo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file id_echo-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 02c375fbd50a25d4800ca976347abb07e0dc203fe7dd2cd403af197f577dbf3b
MD5 a563f18d83c35b498633daccf186ebd2
BLAKE2b-256 9585fd6e057fbc5ba7883914947b7baf213f8db7cad3a038685169b924045fa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on instadeepai/echo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file id_echo-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 58a83f0d88687b0e0304391217afe9e23fbc417fd2fdf4e719ba8f7654a6c072
MD5 cfd05f1c00ebe41bf794d3fb0fbd84a9
BLAKE2b-256 35c8985fd4d88b8e25ecb2b91e020e8bb6faae5d340cfe19061d5f0bb1f054cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on instadeepai/echo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file id_echo-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 993f80c33a56ffe198e9b71ffc20e347994dec2249eda150154c2a073da242bb
MD5 b5ef541bf0917e36da87d29e915e43cd
BLAKE2b-256 96dac4795f4adcd97f71ad4a50ff8393bb9dbfdf28407601f6a9a20964fb1304

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on instadeepai/echo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file id_echo-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ff9f59df2929208e633f61e341afba2eff3ddec9c27a0c3a27772d302727335f
MD5 55ce3da9fa11560184b6f3bd588d5a08
BLAKE2b-256 7599f43d1bd323262954f5262684c40970ac00382d78c0e951179e4e931a30b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on instadeepai/echo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page