make round-to-grid with refinement the default, add --learned for learned rounding

On Qwen2.5-0.5B, learned rounding matched round-to-grid in perplexity and KL
(22.38 vs 22.37, 0.0920 vs 0.0919) at about six times the quantize time.
--simple is still accepted as a no-op. Docs and man pages updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
zefieandClaude Sonnet 5.5 committed 2026-11-05 19:34:15 -05:00
1 parent 164fa6b4a4
commit 1e50e4e045
16 files changed
+76 -39

No files matched your search

+8 -5
View File
@@ -22,7 +22,7 @@ hf_to_nvfp4_hf \- quantize Hugging Face models to NVFP4 Hugging Face format
[\fB\-\-llama\-cpp\fR \fIPATH\fR]
[\fB\-\-convert\-to\-quant\fR \fIPATH\fR]
[\fB\-\-device\fR \fIDEVICE\fR]
[\fB\-\-simple\fR]
[\fB\-\-learned\fR]
[\fB\-\-optimizer\fR \fIOPT\fR]
[\fB\-\-num\-iter\fR \fIN\fR]
[\fB\-\-lr\fR \fILR\fR]
@@ -56,8 +56,8 @@ vocabulary, chat templates, and generation configs. For each quantized weight ma
the script writes ModelOpt-compatible packed 4-bit weights alongside per-block E4M3 scale
factors (\fI<name>.weight_scale\fR) and per-tensor scale factors (\fI<name>.weight_scale_2\fR).
.PP
Weights are quantized using learned rounding (via \fBconvert_to_quant\fR) or simple nearest-grid
projection onto the E2M1 floating point grid with two-level scaling. Biases are adjusted
Weights are quantized using nearest-grid projection with block-scale and code refinement (default)
or learned rounding (\fB\-\-learned\fR, via \fBconvert_to_quant\fR), onto the E2M1 floating point grid with two-level scaling. Biases are adjusted
using simulated calibration data unless disabled. Checkpoint-based resumption is supported
per tensor so interrupted runs can resume without recomputing.
.SH POSITIONAL ARGUMENTS
@@ -97,8 +97,11 @@ Data type for non-quantized weights when learned rounding is skipped (default: \
.BI \-\-output\-dtype " " {bfloat16,float16}
Data type used for unquantized 2D weights, layer norms, and embeddings (default: \fBbfloat16\fR).
.TP
.B \-\-learned
Use \fBconvert_to_quant\fR's learned rounding instead of the default round-to-grid with block-scale and code refinement. On Qwen2.5-0.5B it matched the default in perplexity and KL and took about six times as long.
.TP
.B \-\-simple
Round weights directly onto the E2M1 grid without iterative learned rounding.
Round onto the E2M1 grid without learned rounding (default; accepted for compatibility).
.SS Optimization & Learning Rate
.TP
.BI \-\-optimizer " " {auto,prodigy,adamw,radam,original}
@@ -220,7 +223,7 @@ Quantize with fast simple grid rounding without learned iterations:
.PP
.nf
.RS
hf_to_nvfp4_hf --simple -o ./my-model-nvfp4 ./my-model
hf_to_nvfp4_hf -o ./my-model-nvfp4 ./my-model
.RE
.fi
.SH SEE ALSO