pub struct MemoryBandwidthOptimizer { /* private fields */ }Expand description
Memory-bandwidth co-optimization
Implementations§
Source§impl MemoryBandwidthOptimizer
impl MemoryBandwidthOptimizer
Sourcepub fn new(
optimizer: Box<dyn Optimizer>,
memory_threshold: usize,
bandwidth_threshold: f64,
base_batch_size: usize,
) -> Self
pub fn new( optimizer: Box<dyn Optimizer>, memory_threshold: usize, bandwidth_threshold: f64, base_batch_size: usize, ) -> Self
Create a new memory-bandwidth co-optimizer
Sourcepub fn adjust_batch_size(
&mut self,
memory_usage: usize,
bandwidth_usage: f64,
) -> usize
pub fn adjust_batch_size( &mut self, memory_usage: usize, bandwidth_usage: f64, ) -> usize
Adjust batch size based on memory and bandwidth usage
Sourcepub fn get_utilization(&self) -> ResourceUtilization
pub fn get_utilization(&self) -> ResourceUtilization
Get current resource utilization
Trait Implementations§
Source§impl Optimizer for MemoryBandwidthOptimizer
impl Optimizer for MemoryBandwidthOptimizer
Source§fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
Updates a parameter based on its gradient. Read more
Source§fn accumulate_grad(
&mut self,
parameter: &mut Tensor,
grad: &Tensor,
) -> Result<(), TrustformersError>
fn accumulate_grad( &mut self, parameter: &mut Tensor, grad: &Tensor, ) -> Result<(), TrustformersError>
Accumulates gradients for gradient accumulation. Read more
Source§fn apply_accumulated_grads(
&mut self,
accumulation_steps: usize,
) -> Result<(), TrustformersError>
fn apply_accumulated_grads( &mut self, accumulation_steps: usize, ) -> Result<(), TrustformersError>
Applies accumulated gradients after gradient accumulation. Read more
Auto Trait Implementations§
impl Freeze for MemoryBandwidthOptimizer
impl !RefUnwindSafe for MemoryBandwidthOptimizer
impl Send for MemoryBandwidthOptimizer
impl Sync for MemoryBandwidthOptimizer
impl Unpin for MemoryBandwidthOptimizer
impl !UnwindSafe for MemoryBandwidthOptimizer
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
Mutably borrows from an owned value. Read more
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>
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 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>
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