Skip to main content

A fast distributed replay buffer for reinforcement learning.

Project description

echo

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.

📖 Documentation

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

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.0.tar.gz (202.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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (507.6 kB view details)

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

id_echo-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (501.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

id_echo-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (447.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

id_echo-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (451.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: id_echo-0.1.0.tar.gz
  • Upload date:
  • Size: 202.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.0.tar.gz
Algorithm Hash digest
SHA256 6a28121950414cdde4058f5f059b6e3dfe0df85697691d4ea5925e9e81305dfd
MD5 ea74240209caabe97364be12093b09c9
BLAKE2b-256 72b0f2cdb8122ad90da37a79b75e2fecbfa1a0f8b63c6ba618ac5d6e75875c61

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.0.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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 832a146d6c527f3b94f39e6f0bf3aab48b33a3e08a42935c87c592256481b35b
MD5 311ce754038ff794e8a4b270ce0b2564
BLAKE2b-256 f2fdf3820b00976629a22016f4b1b38df206364787c1803f225f4273278a65b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.0-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.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a363b39500b211155b966a3499fcee41830b6d3b223561036a3a3babf702b0c5
MD5 dea270a147f4525c037a239d214615c4
BLAKE2b-256 b4a79d5ae8f504b4bc2da53bc0fd9e19d3b20bc42e4c484dbbe849bdd911359d

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.0-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.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 265a27d9f00e8a0b9e0ea4d6614c8bf7e2df19a20076592fc45474ae6c78e527
MD5 0fe5c33338dc78e8839fa7fbae1542fc
BLAKE2b-256 2273fa526de08aab750fda0e9f7b648fe9bc1ce5e965d8cdb5328646fdf512b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.0-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.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for id_echo-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b05cf0a092f5901b97420e25c00c3dc1ae375d063b69d30c259f796a455bab90
MD5 969550ce925f55bb8d32d1f7b17df797
BLAKE2b-256 de34aaecb74fad2f92cf92fd77bf850a9b1c17ac99c8398e87c56637e42d0f9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for id_echo-0.1.0-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