Skip to main content

AsyncActorLearnerConfig

Struct AsyncActorLearnerConfig 

Source
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: usize

Number of actor threads (each owns one environment instance).

§num_steps: usize

Per-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: usize

Total env-step budget. The learner runs total_env_steps / (num_steps * num_actors) PPO updates.

§broadcast_every: usize

Broadcast 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: usize

Soft 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: f32

Discount factor for GAE.

§gae_lambda: f32

GAE lambda. Ignored when Self::use_vtrace is true (V-trace has no lambda parameter), but still validated to lie in (0, 1].

§use_vtrace: bool

If 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: f32

V-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: f32

V-trace c clipping threshold (Espeholt 2018, eq. 2). Ignored when Self::use_vtrace is false. Typical value: 1.0.

§seed: u64

Base 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

Source

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).

Source

pub fn num_updates(&self) -> usize

Number of PPO updates the learner will run for this budget.

Source

pub fn effective_max_lead_steps(&self) -> usize

Resolve the staleness valve: max_lead_steps when nonzero, otherwise 2 * broadcast_every * num_steps.

Source

pub fn actor_throttle(&self) -> ActorThrottle

Build the per-actor ActorThrottle for this configuration.

Source

pub fn use_vtrace(self, enabled: bool) -> Self

Enable or disable V-trace off-policy correction (builder style).

Source

pub fn vtrace_rho_bar(self, rho_bar: f32) -> Self

Set the V-trace rho clip threshold (builder style).

Source

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

Source§

fn clone(&self) -> AsyncActorLearnerConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsyncActorLearnerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AsyncActorLearnerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more