improve hf_to_nvfp4_safetensors

This commit is contained in:
zefie committed 2026-11-04 14:30:11 -05:00
1 parent b7ac8ed00c
commit baa9c09e0e
4 files changed
+172 -31

No files matched your search

+6
View File
@@ -7,6 +7,9 @@ from .quant import (
DEFAULT_EARLY_STOP_FLOOR_STALL,
DEFAULT_TARGET_LOSS,
DEFAULT_EARLY_STOP_STALL,
DEFAULT_LR_FLOOR,
DEFAULT_LR_PATIENCE,
DEFAULT_LR_THRESHOLD,
DEFAULT_SCALE_OPTIMIZATION,
DEFAULT_SCALE_REFINEMENT_ROUNDS,
FP4_LEVELS,
@@ -59,6 +62,9 @@ __all__ = [
"DEFAULT_EARLY_STOP_FLOOR_STALL",
"DEFAULT_TARGET_LOSS",
"DEFAULT_EARLY_STOP_STALL",
"DEFAULT_LR_FLOOR",
"DEFAULT_LR_PATIENCE",
"DEFAULT_LR_THRESHOLD",
"DEFAULT_SCALE_OPTIMIZATION",
"DEFAULT_SCALE_REFINEMENT_ROUNDS",
"FP4_LEVELS",
+3
View File
@@ -319,6 +319,9 @@ class GgufLearnedNVFP4:
if self._settled:
log.info(" Loss reached %g. Stopping early.", float(self.target_loss))
return True
if limit > 0 and self._learning_rate_floored() and worse_loss_counter >= limit:
log.info(" Loss stalled at lr-min (%d steps). Stopping early.", worse_loss_counter)
return True
return super()._check_early_stop(current_loss, curr_lr, worse_loss_counter)
def _compute_svd_components(self, W_float32, verbose: bool = True):