pub struct GradientCompressor { /* private fields */ }Expand description
Gradient compressor using random projection.
Uses Johnson-Lindenstrauss style random projection for communication-efficient distributed training.
Implementations§
Source§impl GradientCompressor
impl GradientCompressor
Sourcepub fn new(config: TrainingConfig) -> GradientCompressor
pub fn new(config: TrainingConfig) -> GradientCompressor
Create a new gradient compressor.
Sourcepub fn compress(
&self,
gradients: &[f32],
ratio: Option<f32>,
) -> Result<CompressedGradient, TrainingError>
pub fn compress( &self, gradients: &[f32], ratio: Option<f32>, ) -> Result<CompressedGradient, TrainingError>
Sourcepub fn decompress(
&self,
compressed: &CompressedGradient,
) -> Result<Vec<f32>, TrainingError>
pub fn decompress( &self, compressed: &CompressedGradient, ) -> Result<Vec<f32>, TrainingError>
Sourcepub fn compress_ternary(
&self,
gradients: &[f32],
ratio: Option<f32>,
) -> Result<TernaryCompressedGradient, TrainingError>
pub fn compress_ternary( &self, gradients: &[f32], ratio: Option<f32>, ) -> Result<TernaryCompressedGradient, TrainingError>
Compress and immediately quantize to ternary for maximum compression.
This achieves ~300x compression: 10x from projection + ~30x from ternary.
Sourcepub fn decompress_ternary(
&self,
compressed: &TernaryCompressedGradient,
) -> Result<Vec<f32>, TrainingError>
pub fn decompress_ternary( &self, compressed: &TernaryCompressedGradient, ) -> Result<Vec<f32>, TrainingError>
Decompress ternary compressed gradients.
Trait Implementations§
Source§impl Clone for GradientCompressor
impl Clone for GradientCompressor
Source§fn clone(&self) -> GradientCompressor
fn clone(&self) -> GradientCompressor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GradientCompressor
impl RefUnwindSafe for GradientCompressor
impl Send for GradientCompressor
impl Sync for GradientCompressor
impl Unpin for GradientCompressor
impl UnwindSafe for GradientCompressor
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> 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>
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