TransitionPipeline
TransitionPipeline(reward_shaping: RewardShapingPipeline, transition_accumulator: TransitionAccumulator, replay_writer: ReplayWriter, submission_lock: RLock, *, initial_steps: int = 0) -> NoneTurns environment step results into shaped, accumulated transitions submitted to the replay buffer, and owns the environment-step counter that advances on every processed step.
Every method that touches shared staging state (the n-step buffer, the transition accumulator, the step counter) runs under a single submission lock, which is also handed to the trainer's TrajectoryEpisodeCoordinator -- holding it (via freeze) blocks both replay submission and trajectory-store writes, which is what makes a DQN checkpoint save consistent with the actor thread still running.
Initialize the pipeline.
Parameters:
reward_shaping(RewardShapingPipeline) – The actor-side reward-shaping pipeline.transition_accumulator(TransitionAccumulator) – Accumulates n-step transitions into replay batches.replay_writer(ReplayWriter) – Dedicated replay-writer runtime for replay inserts.submission_lock(RLock) – Lock shared with the trainer's trajectory runtime.initial_steps(int) – The step count to resume from (for example after a checkpoint restore).
Properties
replay_queue_depth
replay_queue_depth: intGet the number of replay batches waiting to be inserted.
Returns:
int– The replay queue depth.
staged_transition_count
staged_transition_count: intGet the number of transitions currently staged, not yet submitted to the replay buffer.
Returns:
int– The number of locally buffered transitions.
steps
steps: intGet the total number of environment steps processed.
Returns:
int– The total step count.
Methods
flush
flush() -> NoneFlush any buffered transitions to the replay buffer.
freeze
freeze() -> Generator[None]Freeze replay submission, flush actor-side staging, and drain the replay writer.
Returns:
Generator[None]– A context manager that keeps replay submission frozen for the duration of the block.
process_step_result
process_step_result(result: MultiEnvResult, env_state: EnvironmentState) -> boolShape the step's reward, accumulate/submit the resulting transitions, and advance state.
Parameters:
result(MultiEnvResult) – The environment step result.env_state(EnvironmentState) – The state for this environment.
Returns:
bool–Trueif the episode is now done (terminated or truncated).
replace_replay_buffer
replace_replay_buffer(replay_buffer: ReplayBuffer) -> NoneRebind the replay writer to a new replay buffer.
Parameters:
replay_buffer(ReplayBuffer) – The new replay buffer.
restore_steps
restore_steps(steps: int) -> NoneRestore the step counter from a checkpoint.
Parameters:
steps(int) – The step count to resume from.