pub struct RolloutBuffer { /* private fields */ }Expand description
Stateful fixed-capacity owner for one categorical on-policy rollout.
Appends, validity reset, and final GAE are recorded on the owning runtime; host observation remains the explicit submit-and-wait boundary. Storage is allocated once and overwritten in place across completed collection cycles.
Implementations§
Source§impl RolloutBuffer
impl RolloutBuffer
Sourcepub fn new(runtime: &Runtime, config: RolloutConfig) -> Result<Self>
pub fn new(runtime: &Runtime, config: RolloutConfig) -> Result<Self>
Allocate one empty fixed-capacity rollout on runtime.
§Errors
Returns an error unless time and environment counts are nonzero, the
observation rank is in 1..=6, every observation extent is positive,
all GPU-indexed counts fit u32, and every matrix allocation succeeds.
Sourcepub fn append(&mut self, transition: &RolloutTransition) -> Result<()>
pub fn append(&mut self, transition: &RolloutTransition) -> Result<()>
Record one fused device-side append into the current time step.
§Errors
Returns an error after finalization, at capacity, when any transition field violates the configured shape/dtype/runtime contract or aliases retained rollout storage, or when GPU recording fails.
Sourcepub fn finalize(&mut self, config: GaeConfig) -> Result<()>
pub fn finalize(&mut self, config: GaeConfig) -> Result<()>
Record generalized advantage estimation into the retained batch.
Calling this again after successful finalization is an idempotent no-op.
§Errors
Returns an error until the rollout is full or when GAE validation or GPU recording fails.
Sourcepub fn reset(&mut self) -> Result<()>
pub fn reset(&mut self) -> Result<()>
Begin a new collection cycle and clear the validity mask on the device.
Previously allocated matrices are retained and overwritten by later appends. Pending work remains ordered by the runtime’s execution session.
§Errors
Returns an error when GPU recording fails.
Sourcepub const fn is_finalized(&self) -> bool
pub const fn is_finalized(&self) -> bool
Return whether final GAE has been recorded for this cycle.
Sourcepub const fn config(&self) -> &RolloutConfig
pub const fn config(&self) -> &RolloutConfig
Return the validated rollout configuration.
Sourcepub const fn batch(&self) -> &RolloutBatch
pub const fn batch(&self) -> &RolloutBatch
Return the retained time-major batch matrices.