pub struct MixedPrecisionConfig {
pub compute_dtype: PrecisionMode,
pub param_dtype: PrecisionMode,
pub loss_scaling: LossScalingStrategy,
pub gradient_checkpointing: bool,
pub gradient_clipping: bool,
pub max_gradient_norm: f64,
pub stability_checks: bool,
pub skip_on_overflow: bool,
pub use_master_weights: bool,
}Expand description
Mixed precision training configuration.
Fields§
§compute_dtype: PrecisionModePrecision mode for computation
param_dtype: PrecisionModePrecision mode for parameters (usually FP32)
loss_scaling: LossScalingStrategyLoss scaling strategy
gradient_checkpointing: boolEnable gradient checkpointing to save memory
gradient_clipping: boolEnable gradient clipping before unscaling
max_gradient_norm: f64Maximum gradient norm for clipping
stability_checks: boolEnable numerical stability checks
skip_on_overflow: boolSkip optimizer step if overflow detected
use_master_weights: boolEnable master weights in FP32
Implementations§
Source§impl MixedPrecisionConfig
impl MixedPrecisionConfig
Sourcepub fn new(compute_dtype: PrecisionMode, param_dtype: PrecisionMode) -> Self
pub fn new(compute_dtype: PrecisionMode, param_dtype: PrecisionMode) -> Self
Create a new mixed precision config.
Sourcepub fn with_compute_dtype(self, dtype: PrecisionMode) -> Self
pub fn with_compute_dtype(self, dtype: PrecisionMode) -> Self
Set the compute dtype.
Sourcepub fn with_param_dtype(self, dtype: PrecisionMode) -> Self
pub fn with_param_dtype(self, dtype: PrecisionMode) -> Self
Set the parameter dtype.
Sourcepub fn with_loss_scaling(self, strategy: LossScalingStrategy) -> Self
pub fn with_loss_scaling(self, strategy: LossScalingStrategy) -> Self
Set the loss scaling strategy.
Sourcepub fn with_gradient_checkpointing(self, enabled: bool) -> Self
pub fn with_gradient_checkpointing(self, enabled: bool) -> Self
Enable or disable gradient checkpointing.
Sourcepub fn with_gradient_clipping(self, enabled: bool, max_norm: f64) -> Self
pub fn with_gradient_clipping(self, enabled: bool, max_norm: f64) -> Self
Enable or disable gradient clipping.
Sourcepub fn with_stability_checks(self, enabled: bool) -> Self
pub fn with_stability_checks(self, enabled: bool) -> Self
Enable or disable stability checks.
Sourcepub fn with_master_weights(self, enabled: bool) -> Self
pub fn with_master_weights(self, enabled: bool) -> Self
Enable or disable master weights.
Sourcepub fn validate(&self) -> Result<(), MixedPrecisionError>
pub fn validate(&self) -> Result<(), MixedPrecisionError>
Validate the configuration.
Trait Implementations§
Source§impl Clone for MixedPrecisionConfig
impl Clone for MixedPrecisionConfig
Source§fn clone(&self) -> MixedPrecisionConfig
fn clone(&self) -> MixedPrecisionConfig
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 moreSource§impl Debug for MixedPrecisionConfig
impl Debug for MixedPrecisionConfig
Source§impl Default for MixedPrecisionConfig
impl Default for MixedPrecisionConfig
Source§impl<'de> Deserialize<'de> for MixedPrecisionConfig
impl<'de> Deserialize<'de> for MixedPrecisionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MixedPrecisionConfig
impl PartialEq for MixedPrecisionConfig
Source§impl Serialize for MixedPrecisionConfig
impl Serialize for MixedPrecisionConfig
impl StructuralPartialEq for MixedPrecisionConfig
Auto Trait Implementations§
impl Freeze for MixedPrecisionConfig
impl RefUnwindSafe for MixedPrecisionConfig
impl Send for MixedPrecisionConfig
impl Sync for MixedPrecisionConfig
impl Unpin for MixedPrecisionConfig
impl UnwindSafe for MixedPrecisionConfig
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