Skip to content

ReplayWriter ​

python
ReplayWriter(replay_buffer: ReplayBuffer, stop_event: Event, max_queue_size: int) -> None

Dedicated replay-buffer insertion stage for DQN.

Actor threads enqueue owned replay batches here; the replay writer serializes replay_buffer.add(...) calls onto a single thread to keep replay insertion off the actor hot path.

Initialize the replay writer.

Parameters:

  • replay_buffer (ReplayBuffer) – Replay buffer receiving inserted transitions.
  • stop_event (Event) – Shared experiment stop event.
  • max_queue_size (int) – Maximum number of replay batches that may be queued.

Source

Properties ​

queue_depth ​

python
queue_depth: int

Get the current replay queue depth.

Returns:

  • int – The number of queued replay batches.

Source

replay_buffer ​

python
replay_buffer: ReplayBuffer

Get the replay buffer currently owned by the writer.

Returns:

  • ReplayBuffer – The replay buffer.

Source

Methods ​

drain ​

python
drain() -> None

Wait for all queued replay work to be inserted.

Source

enqueue ​

python
enqueue(batch: ReplayBatch) -> None

Enqueue a replay batch for insertion.

Blocks when the bounded queue is full.

Parameters:

  • batch (ReplayBatch) – Replay batch to insert.

Source

replace_replay_buffer ​

python
replace_replay_buffer(replay_buffer: ReplayBuffer) -> None

Replace the replay buffer target.

Parameters:

  • replay_buffer (ReplayBuffer) – The new replay buffer.

Source

run ​

python
run() -> None

Process queued replay batches until stop is requested and the queue is drained.

Source