Skip to content

Conversation

casteryh
Copy link
Contributor

@casteryh casteryh commented Aug 28, 2025

Summary:
This diff allows passing in a custom sampler in the ReplayBuffer class. The changes include adding a new sampler class and modifying the ReplayBuffer class to accept a sampler as a parameter. The code changes also include modifying the test_replay_buffer.py file to test the new sampler functionality.

Test Plan:
unit tests (flaky)


Stack created with Sapling. Best reviewed with ReviewStack.

Summary:
Added `BufferView` and `RawBuffer` interface.

A sampler will operate on a BufferView and return the sampled keys.

A ReplayBuffer will own a RawBuffer and operate on that.

Test Plan:
n/a
Summary:
Implement SimpleRawBuffer, a RawBuffer backed by a python dict.

Test Plan:
unit tests
Summary:
This diff adds a new interface called `StatefulSampler` and implements a new class called `RandomStatefulSampler`.

The `RandomStatefulSampler` class is a stateful sampler that uses Python's `random.sample` function for deterministic sampling.

Test Plan:
unit tests

@pytest.mark.asyncio
async def test_setup_accepts_sampler(self, mocker) -> None:
# This test is flaky and only works if it is run on a single machine.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allenwang28 Is there a supported way to test monarch actors?

Summary:
This diff allows passing in a custom sampler in the ReplayBuffer class. The changes include adding a new sampler class and modifying the ReplayBuffer class to accept a sampler as a parameter. The code changes also include modifying the test_replay_buffer.py file to test the new sampler functionality.



Test Plan:
unit tests (flaky)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant