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

+2
View File
@@ -20,6 +20,7 @@ from .quant import (
ShapeView,
TensorQuantizer,
add_quant_arguments,
add_rounding_arguments,
bind_exclude,
ctq_skips_key,
eligible_weight,
@@ -75,6 +76,7 @@ __all__ = [
"ShapeView",
"TensorQuantizer",
"add_quant_arguments",
"add_rounding_arguments",
"bind_exclude",
"ctq_skips_key",
"eligible_weight",
+15 -2
View File
@@ -1116,7 +1116,7 @@ def quant_settings(args) -> dict:
"""Flags that change the bytes in a checkpoint. A mismatch forces --fresh."""
return {
"version": QUANT_VERSION,
"simple": bool(getattr(args, "simple", False)),
"simple": bool(getattr(args, "simple", True)),
"optimizer": args.optimizer,
"num_iter": args.num_iter,
"lr": args.lr,
@@ -1436,10 +1436,23 @@ def eligible_weight(name: str, shape: tuple[int, ...], args, gguf_module) -> boo
return True
def add_rounding_arguments(parser: argparse.ArgumentParser) -> None:
"""--learned opts into learned rounding. Round-to-grid plus scale/code refinement is the default.
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) and took about six times as long.
"""
parser.add_argument("--learned", dest="simple", action="store_false",
help="Use convert_to_quant's learned rounding (much slower, no measured quality gain)")
parser.add_argument("--simple", dest="simple", action="store_true",
help="Round onto the E2M1 grid without learned rounding (default)")
parser.set_defaults(simple=True)
def add_quant_arguments(parser: argparse.ArgumentParser) -> None:
"""Flags shared with convert_to_quant's learned NVFP4 defaults."""
parser.add_argument("--device", default="auto", help="auto, cpu, cuda, or cuda:N")
parser.add_argument("--simple", action="store_true", help="Round onto the E2M1 grid without learned rounding")
add_rounding_arguments(parser)
parser.add_argument("--optimizer", default="auto", choices=("auto", "prodigy", "adamw", "radam", "original"),
help="auto uses prodigy when it is installed, otherwise AdamW")
parser.add_argument("--num-iter", type=int, default=CTQ_NUM_ITER,