Skip to main content

SacTrainer

Struct SacTrainer 

Source
pub struct SacTrainer<'runtime, 'hooks> { /* private fields */ }
Expand description

Stateful fixed-temperature SAC coordinator over caller-owned components.

Implementations§

Source§

impl<'runtime, 'hooks> SacTrainer<'runtime, 'hooks>

Source

pub fn new( runtime: &'runtime Runtime, actor: &'runtime dyn Module, critic1: &'runtime dyn Module, critic2: &'runtime dyn Module, target_critic1: &'runtime dyn Module, target_critic2: &'runtime dyn Module, actor_optimizer: &'runtime mut dyn Optimizer, critic_optimizer: &'runtime mut dyn Optimizer, replay: &'runtime ReplayBuffer, config: SacTrainerConfig, ) -> Result<Self>

Validate all owners, construct two training lifecycles, and synchronize targets.

§Errors

Returns an error for invalid shape/range/update policy, incompatible critic schemas, optimizer ownership, overflow, or target-copy failure.

Source

pub fn new_resumed( runtime: &'runtime Runtime, actor: &'runtime dyn Module, critic1: &'runtime dyn Module, critic2: &'runtime dyn Module, target_critic1: &'runtime dyn Module, target_critic2: &'runtime dyn Module, actor_optimizer: &'runtime mut dyn Optimizer, critic_optimizer: &'runtime mut dyn Optimizer, replay: &'runtime ReplayBuffer, config: SacTrainerConfig, completed_updates: u64, ) -> Result<Self>

Construct a resumed SAC trainer at completed_updates without overwriting restored target-critic weights.

Validates both target-critic schemas and runtime ownership, ensures target parameters do not require gradients, and sets replay/policy seeds and target-sync cadence to continue from completed_updates.

§Errors

Returns an error when completed_updates > config.updates or any precondition checked by SacTrainer::new fails.

Source

pub fn completed_updates(&self) -> u64

Return the cumulative number of completed update pairs (including any resumed offset).

Source

pub fn update(&mut self) -> Result<bool>

Complete one critic update followed by one actor update.

Returns false when either coordinated loop has stopped or exhausted its budget. Next-state policy and target-critic work is recorded before either tape, preserving the donor’s detached Bellman target.

§Errors

Returns an error for insufficient replay, module output drift, loss, reverse-mode, optimizer, callback, synchronization, or runtime failure.

Source

pub fn sync_targets(&self) -> Result<()>

Exactly synchronize both online critics into their target peers.

Source

pub fn is_done(&self) -> bool

Return whether either coordinated loop has stopped or reached its budget.

Source

pub const fn metrics(&self) -> SacTrainerMetrics

Return the last completed update-pair metrics.

Source

pub const fn training_loop(&self) -> &Training<'runtime, 'hooks>

Borrow the primary critic update lifecycle.

Source

pub fn training_loop_mut(&mut self) -> &mut Training<'runtime, 'hooks>

Mutably borrow the primary critic update lifecycle.

Source

pub const fn actor_training_loop(&self) -> &Training<'runtime, 'hooks>

Borrow the independently observable actor update lifecycle.

Source

pub fn actor_training_loop_mut(&mut self) -> &mut Training<'runtime, 'hooks>

Mutably borrow the actor update lifecycle.

Source

pub fn finish(self) -> Result<(TrainingSnapshot, TrainingSnapshot)>

Fire both explicit terminal boundaries and return critic then actor snapshots.

§Errors

Returns an error for incomplete steps or terminal callback failure.

Auto Trait Implementations§

§

impl<'runtime, 'hooks> !Freeze for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> !RefUnwindSafe for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> !Send for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> !Sync for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> !UnwindSafe for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> Forget for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> Move for SacTrainer<'runtime, 'hooks>

§

impl<'runtime, 'hooks> Unpin for SacTrainer<'runtime, 'hooks>
where &'runtime Runtime: Unpin, &'runtime dyn Module: Unpin, &'runtime ReplayBuffer: Unpin, *const u8 is !null: Unpin, &'runtime mut AdamW: Unpin, &'runtime mut dyn Optimizer: Unpin, &'runtime mut dyn CheckpointOptimizer: Unpin, &'hooks mut dyn TrainingMetric: Unpin, &'hooks mut dyn TrainingCallback: Unpin, Arc<Shared>: Unpin, Box<dyn FnMut() -> Result<(), Error> + 'hooks>: Unpin, Box<dyn FnMut(&TrainingCommand) -> Result<(), Error> + 'hooks>: Unpin, Box<dyn Fn() -> TrainingValue + 'hooks>: Unpin, Box<dyn FnMut(&TrainingValue) -> Result<(), Error> + 'hooks>: Unpin, Rc<RefCell<RuntimeState>>: Unpin, &'static str: Unpin, Arc<BufferInner>: Unpin, Arc<DecodedPlaneCopy>: Unpin, Arc<RetainedDecode>: Unpin, Arc<EncodePlaneCopy>: Unpin, Arc<RetainedEncode>: Unpin, Rc<StorageInner>: Unpin, Arc<Device>: Unpin, Arc<RetirementCompletion>: Unpin, Arc<WorkerControl>: Unpin, Arc<TimestampPairInner>: Unpin, Arc<Mutex<Vec<Arc<DecodeStatus>>>>: Unpin, Arc<Mutex<Vec<Arc<EncodeReceipt>>>>: Unpin, Arc<ReusableCommandBufferInner>: Unpin, Rc<MatrixSemantic>: Unpin, Rc<()>: Unpin,

§

impl<'runtime, 'hooks> UnsafeUnpin for SacTrainer<'runtime, 'hooks>
where &'runtime Runtime: UnsafeUnpin, &'runtime dyn Module: UnsafeUnpin, &'runtime ReplayBuffer: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, &'runtime mut AdamW: UnsafeUnpin, &'runtime mut dyn Optimizer: UnsafeUnpin, &'runtime mut dyn CheckpointOptimizer: UnsafeUnpin, PhantomData<u64>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<&'hooks mut dyn TrainingMetric>: UnsafeUnpin, PhantomData<&'hooks mut dyn TrainingCallback>: UnsafeUnpin, *const ArcInner<Shared> is !null: UnsafeUnpin, PhantomData<ArcInner<Shared>>: UnsafeUnpin, *const dyn FnMut() -> Result<(), Error> + 'hooks is !null: UnsafeUnpin, PhantomData<dyn FnMut() -> Result<(), Error> + 'hooks>: UnsafeUnpin, *const dyn FnMut(&TrainingCommand) -> Result<(), Error> + 'hooks is !null: UnsafeUnpin, PhantomData<dyn FnMut(&TrainingCommand) -> Result<(), Error> + 'hooks>: UnsafeUnpin, PhantomData<TrainingParameterDesc<'hooks>>: UnsafeUnpin, *const RcInner<RefCell<RuntimeState>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<RuntimeState>>>: UnsafeUnpin, PhantomData<GraphNode>: UnsafeUnpin, PhantomData<Vec<BufferHazard>>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<Storage>: UnsafeUnpin, PhantomData<SemanticValueDesc>: UnsafeUnpin, PhantomData<SemanticOpDesc>: UnsafeUnpin, PhantomData<SemanticAutogradDesc>: UnsafeUnpin, PhantomData<DnnValueDesc>: UnsafeUnpin, PhantomData<DnnOpDesc>: UnsafeUnpin, PhantomData<DnnPartition>: UnsafeUnpin, PhantomData<MatrixInputBinding>: UnsafeUnpin, PhantomData<ExecutionBindingDesc>: UnsafeUnpin, PhantomData<CapturedResourceDesc>: UnsafeUnpin, PhantomData<SemanticStorageBinding>: UnsafeUnpin, PhantomData<(Vec<u32>, Vec<ReusableCommandBuffer>)>: UnsafeUnpin, *const ArcInner<Device> is !null: UnsafeUnpin, PhantomData<ArcInner<Device>>: UnsafeUnpin, *const ArcInner<RetirementCompletion> is !null: UnsafeUnpin, PhantomData<ArcInner<RetirementCompletion>>: UnsafeUnpin, *const ArcInner<WorkerControl> is !null: UnsafeUnpin, PhantomData<ArcInner<WorkerControl>>: UnsafeUnpin, *const ArcInner<TimestampPairInner> is !null: UnsafeUnpin, PhantomData<ArcInner<TimestampPairInner>>: UnsafeUnpin, *const ArcInner<Mutex<Vec<Arc<DecodeStatus>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Vec<Arc<DecodeStatus>>>>>: UnsafeUnpin, *const ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>>>: UnsafeUnpin, *const RcInner<StorageInner> is !null: UnsafeUnpin, PhantomData<RcInner<StorageInner>>: UnsafeUnpin, *const RcInner<MatrixSemantic> is !null: UnsafeUnpin, PhantomData<RcInner<MatrixSemantic>>: UnsafeUnpin, PhantomData<Rc<()>>: UnsafeUnpin, PhantomData<(u64, u64)>: UnsafeUnpin, PhantomData<Duration>: UnsafeUnpin, PhantomData<CommittedMetric>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.