pub struct AsyncActorLearnerConfig {
pub num_actors: usize,
pub num_steps: usize,
pub total_env_steps: usize,
pub broadcast_every: usize,
pub max_lead_steps: usize,
pub gamma: f32,
pub gae_lambda: f32,
pub use_vtrace: bool,
pub vtrace_rho_bar: f32,
pub vtrace_c_bar: f32,
pub seed: u64,
}Expand description
Configuration for the single-host asynchronous actor-learner runner.
See the module docs for the architecture and the staleness caveat.
Fields§
§num_actors: usizeNumber of actor threads (each owns one environment instance).
num_steps: usizePer-actor env steps consumed per PPO update. Each update trains on
a [num_steps, num_actors] rollout buffer, i.e.
num_steps * num_actors transitions.
total_env_steps: usizeTotal env-step budget. The learner runs
total_env_steps / (num_steps * num_actors) PPO updates.
broadcast_every: usizeBroadcast updated policy weights to actors after every
broadcast_every learner updates. 1 (the default) keeps actors
as fresh as possible, which is what makes the uncorrected
(no V-trace) PPO update acceptable on simple envs.
max_lead_steps: usizeSoft staleness valve: the maximum number of env steps an actor
may run ahead of the learner’s consumption. Policy version
v proves the learner has consumed v * broadcast_every * num_steps transitions from each actor, so an actor pauses (and
waits for the next crate::multi_agent::PolicyBroadcast) once
its total sent steps reach that mark plus max_lead_steps. This
bounds the learner’s queue depth and the worst-case policy lag
at max_lead_steps — a cumulative budget, unlike a
per-version allowance, which would let production permanently
outpace consumption and grow the backlog (and therefore the
staleness) linearly over the run.
0 selects the default of 2 * broadcast_every * num_steps:
one broadcast cycle of lead for pipeline overlap (actors collect
while the learner trains) plus one cycle in flight. Must be at
least broadcast_every * num_steps or the learner starves. See
AsyncActorLearnerConfig::effective_max_lead_steps.
gamma: f32Discount factor for GAE.
gae_lambda: f32GAE lambda. Ignored when Self::use_vtrace is true (V-trace
has no lambda parameter), but still validated to lie in (0, 1].
use_vtrace: boolIf true, replace GAE with V-trace (Espeholt et al. 2018) for
off-policy correction of stale actor trajectories. The learner
re-evaluates each stored (obs, action) under the current
policy to obtain target log-probs log π(a_t|s_t), and the
importance ratio against the actor’s stored behavior log-probs
log μ(a_t|s_t) corrects for policy lag before PPO sees the
advantages. Defaults to false, preserving the GAE path and all
existing behavior.
vtrace_rho_bar: f32V-trace rho clipping threshold (Espeholt 2018, eq. 1). Ignored
when Self::use_vtrace is false. Typical value: 1.0 (the
IMPALA paper default).
vtrace_c_bar: f32V-trace c clipping threshold (Espeholt 2018, eq. 2). Ignored when
Self::use_vtrace is false. Typical value: 1.0.
seed: u64Base seed. Actor i samples actions with
StdRng::seed_from_u64(seed + 1 + i) when wired through
spawn_actor by the caller.
Implementations§
Source§impl AsyncActorLearnerConfig
impl AsyncActorLearnerConfig
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the configuration.
§Errors
Returns an error when any count is zero, when the step budget is
smaller than a single update’s worth of transitions, when
gamma / gae_lambda fall outside (0, 1], or when the
staleness valve is too tight for the broadcast cadence (which
would deadlock the learner’s fill loop).
Sourcepub fn num_updates(&self) -> usize
pub fn num_updates(&self) -> usize
Number of PPO updates the learner will run for this budget.
Sourcepub fn effective_max_lead_steps(&self) -> usize
pub fn effective_max_lead_steps(&self) -> usize
Resolve the staleness valve: max_lead_steps when nonzero,
otherwise 2 * broadcast_every * num_steps.
Sourcepub fn actor_throttle(&self) -> ActorThrottle
pub fn actor_throttle(&self) -> ActorThrottle
Build the per-actor ActorThrottle for this configuration.
Sourcepub fn use_vtrace(self, enabled: bool) -> Self
pub fn use_vtrace(self, enabled: bool) -> Self
Enable or disable V-trace off-policy correction (builder style).
Sourcepub fn vtrace_rho_bar(self, rho_bar: f32) -> Self
pub fn vtrace_rho_bar(self, rho_bar: f32) -> Self
Set the V-trace rho clip threshold (builder style).
Sourcepub fn vtrace_c_bar(self, c_bar: f32) -> Self
pub fn vtrace_c_bar(self, c_bar: f32) -> Self
Set the V-trace c clip threshold (builder style).
Trait Implementations§
Source§impl Clone for AsyncActorLearnerConfig
impl Clone for AsyncActorLearnerConfig
Source§fn clone(&self) -> AsyncActorLearnerConfig
fn clone(&self) -> AsyncActorLearnerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AsyncActorLearnerConfig
impl Debug for AsyncActorLearnerConfig
Auto Trait Implementations§
impl Freeze for AsyncActorLearnerConfig
impl RefUnwindSafe for AsyncActorLearnerConfig
impl Send for AsyncActorLearnerConfig
impl Sync for AsyncActorLearnerConfig
impl Unpin for AsyncActorLearnerConfig
impl UnsafeUnpin for AsyncActorLearnerConfig
impl UnwindSafe for AsyncActorLearnerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more