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

+9 -6
View File
@@ -14,7 +14,7 @@ gguf_to_nvfp4_gguf \- quantize or repack an existing GGUF model to NVFP4 GGUF
[\fB\-\-convert\-to\-quant\fR \fIPATH\fR]
[\fB\-\-model\-name\fR \fINAME\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]
@@ -51,8 +51,8 @@ reads an existing GGUF model (such as an F16, BF16, or existing quantized checkp
and converts it to NVIDIA FP4 (NVFP4) format, or repacks an existing NVFP4 GGUF file.
.PP
Vocabulary, tokenizer settings, architecture metadata, and tensor names are copied directly
from the source GGUF header. When quantizing unquantized (float) tensors, learned rounding
or simple grid rounding is applied using the same optimization flags as \fBhf_to_nvfp4_gguf\fR.
from the source GGUF header. When quantizing unquantized (float) tensors, round-to-grid refinement (default)
or learned rounding (\fB\-\-learned\fR) is applied using the same optimization flags as \fBhf_to_nvfp4_gguf\fR.
.PP
An accompanying Ollama \fBModelfile\fR is written alongside the output GGUF, configured with
the source model's parameters and templates.
@@ -91,8 +91,11 @@ Skip learned rounding. Writes a float GGUF, or copies/repacks an existing NVFP4
Target data type when learned rounding is skipped. \fBnvfp4\fR copies an already NVFP4 GGUF without re-optimizing;
\fBauto\fR leaves tensors as stored in the source file (default: \fBauto\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 each value directly onto the E2M1 grid without learned rounding (fast, non-iterative).
Round onto the E2M1 grid without learned rounding (default; accepted for compatibility).
.TP
.B \-\-quantize\-output
Also quantize the output (\fIlm_head\fR) matrix. By default, output projection layers are left unquantized.
@@ -188,10 +191,10 @@ gguf_to_nvfp4_gguf -o ./llama3-nvfp4 ./llama-3-8b-f16.gguf
.fi
.RE
.TP
.B Fast conversion with simple grid rounding:
.B Default conversion (grid rounding with scale and code refinement):
.RS
.nf
gguf_to_nvfp4_gguf --simple -o ./qwen-nvfp4 ./qwen2.5-7b-bf16.gguf
gguf_to_nvfp4_gguf -o ./qwen-nvfp4 ./qwen2.5-7b-bf16.gguf
.fi
.RE
.TP