pub struct HardwareAwareOptimizer<A: Float + 'static, D: Dimension + 'static> { /* private fields */ }Expand description
Hardware-aware optimizer that adapts to different platforms
Implementations§
Source§impl<A: Float + ScalarOperand + Debug + Sum + for<'a> Sum<&'a A> + Send + Sync + 'static, D: Dimension + 'static> HardwareAwareOptimizer<A, D>
impl<A: Float + ScalarOperand + Debug + Sum + for<'a> Sum<&'a A> + Send + Sync + 'static, D: Dimension + 'static> HardwareAwareOptimizer<A, D>
Sourcepub fn new(platform: HardwarePlatform, initialparameters: Array<A, D>) -> Self
pub fn new(platform: HardwarePlatform, initialparameters: Array<A, D>) -> Self
Create a new hardware-aware optimizer at the default learning rate
(DEFAULT_BASE_LEARNING_RATE).
Sourcepub fn new_with_learning_rate(
platform: HardwarePlatform,
initialparameters: Array<A, D>,
base_learning_rate: A,
) -> Self
pub fn new_with_learning_rate( platform: HardwarePlatform, initialparameters: Array<A, D>, base_learning_rate: A, ) -> Self
Create a new hardware-aware optimizer with an explicit base learning rate.
The optimizer family is chosen by HardwareOptimizerKind::recommend_for
from the platform’s default configuration, and the gradient accumulation
window from that configuration’s MemoryStrategy, so the returned
optimizer can take a real step immediately — before
Self::optimize_for_hardware has refined anything.
Sourcepub fn optimize_for_hardware(&mut self) -> Result<()>
pub fn optimize_for_hardware(&mut self) -> Result<()>
Optimize configuration for target hardware
Sourcepub fn recommended_optimizer_kind(&self) -> HardwareOptimizerKind
pub fn recommended_optimizer_kind(&self) -> HardwareOptimizerKind
Optimizer family the current platform and configuration call for.
Sourcepub fn adopt_recommended_optimizer(&mut self) -> HardwareOptimizerKind
pub fn adopt_recommended_optimizer(&mut self) -> HardwareOptimizerKind
Adopt the current recommendation, discarding the existing optimizer’s accumulated state.
Returns the family now in use.
Sourcepub fn step(&mut self, gradients: &Array<A, D>) -> Result<HardwareStepReport<A>>
pub fn step(&mut self, gradients: &Array<A, D>) -> Result<HardwareStepReport<A>>
Apply one gradient through the configured optimizer.
This is the step path the module’s hardware analysis exists to configure: the optimizer family, the learning rate schedule and the gradient accumulation window all come from the platform configuration.
Sourcepub fn parameters(&self) -> &Array<A, D>
pub fn parameters(&self) -> &Array<A, D>
Current parameters.
Sourcepub fn optimization_state(&self) -> &OptimizationState<A, D>
pub fn optimization_state(&self) -> &OptimizationState<A, D>
The optimization state, for callers that need the step count, the learning rate or the optimizer family.
Sourcepub fn optimization_state_mut(&mut self) -> &mut OptimizationState<A, D>
pub fn optimization_state_mut(&mut self) -> &mut OptimizationState<A, D>
Mutable access to the optimization state, for installing a learning rate schedule or a caller-supplied optimizer.
Sourcepub fn tuner(&self) -> &AdaptiveTuner<A>
pub fn tuner(&self) -> &AdaptiveTuner<A>
The adaptive tuner, for inspecting the tuning history and the tuned parameters.
Sourcepub fn tuner_mut(&mut self) -> &mut AdaptiveTuner<A>
pub fn tuner_mut(&mut self) -> &mut AdaptiveTuner<A>
Mutable access to the adaptive tuner, for registering the parameters the
search may move and selecting a TuningStrategy.
Sourcepub fn tune_parameters<F>(&mut self, evaluate: F) -> Result<TuningOutcome<A>>
pub fn tune_parameters<F>(&mut self, evaluate: F) -> Result<TuningOutcome<A>>
Run the configured tuning search, then apply anything it found that this module knows how to apply.
A tuned parameter named batch_size is written back into the hardware
configuration (rounded and clamped to at least 1); every other tuned
parameter is left for the caller to read from
AdaptiveTuner::current_params, because only the caller knows what it
means.
Sourcepub fn profile_performance(
&mut self,
computation_time: A,
memoryused: usize,
energy: A,
)
pub fn profile_performance( &mut self, computation_time: A, memoryused: usize, energy: A, )
Profile current performance
Sourcepub fn update_resource_monitor(
&mut self,
memory: usize,
cpuutil: A,
power: A,
temp: A,
)
pub fn update_resource_monitor( &mut self, memory: usize, cpuutil: A, power: A, temp: A, )
Update resource monitoring
Sourcepub fn adaptive_tune(&mut self, targetperformance: A) -> Result<()>
pub fn adaptive_tune(&mut self, targetperformance: A) -> Result<()>
Adaptive tuning based on performance feedback
Sourcepub fn get_config(&self) -> &HardwareOptimizationConfig<A>
pub fn get_config(&self) -> &HardwareOptimizationConfig<A>
Get current configuration
Sourcepub fn get_performance_stats(&self) -> HardwarePerformanceStats<A>
pub fn get_performance_stats(&self) -> HardwarePerformanceStats<A>
Get performance statistics
Trait Implementations§
Auto Trait Implementations§
impl<A, D> !RefUnwindSafe for HardwareAwareOptimizer<A, D>
impl<A, D> !UnwindSafe for HardwareAwareOptimizer<A, D>
impl<A, D> Freeze for HardwareAwareOptimizer<A, D>
impl<A, D> Send for HardwareAwareOptimizer<A, D>where
A: Send,
impl<A, D> Sync for HardwareAwareOptimizer<A, D>where
A: Sync,
impl<A, D> Unpin for HardwareAwareOptimizer<A, D>
impl<A, D> UnsafeUnpin for HardwareAwareOptimizer<A, D>where
A: UnsafeUnpin,
D: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.