utils¶
numerical
¶
Numerical stability utilities for mixed-precision training.
General-purpose helpers for preventing NaN/Inf values in deep learning computations, particularly under FP16/BF16 autocast.
StabilityConfig
¶
Default numerical stability bounds.
get_eps
¶
Return an appropriate epsilon for the given dtype.
safe_normalize
¶
L2-normalize with numerical stability (avoids division by ~zero norms).
Source code in deltaflow/utils/numerical.py
safe_sqrt
¶
Compute a square root, clamping the input to be non-negative first.
clamp_noise
¶
Clamp a noise tensor to prevent extreme values under FP16.
Source code in deltaflow/utils/numerical.py
clamp_prediction
¶
Clamp model predictions to prevent extreme values.
Source code in deltaflow/utils/numerical.py
clamp_loss
¶
Clamp a scalar loss to prevent gradient explosion.
Source code in deltaflow/utils/numerical.py
clamp_cosine_similarity
¶
Clamp cosine similarity to the valid range [-1, 1].