Files
nvfp4_gguf_quant/nvfp4gguf/__init__.py
T
zefieandClaude Sonnet 5.5 1e50e4e045 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>
2026-11-05 19:34:15 -05:00

114 lines
2.8 KiB
Python

"""Shared NVFP4 quantization used by the GGUF scripts in this project."""
from .quant import (
CTQ_NUM_ITER,
DEFAULT_CONVERT_TO_QUANT,
DEFAULT_LLAMA_CPP,
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,
FP4_LEVELS_SORTED,
FP4_LEVEL_MAP,
FP4_TABLE,
QUANT_VERSION,
ShapeView,
TensorQuantizer,
add_quant_arguments,
add_rounding_arguments,
bind_exclude,
ctq_skips_key,
eligible_weight,
ensure_cuda_interpreter,
import_gguf,
load_gguf_modules,
load_learned_converter,
looks_like_spark,
check_scale_policy,
must_bake_nvfp4_scale,
mtp_layer_tensor,
bake_packed_nvfp4,
optimize_block_scales,
optimize_block_scales_torch,
pack_nvfp4,
preserve_scale_tensor,
quant_profile,
quant_settings,
quantize_and_pack,
refine_codes_for_scale,
refine_codes_for_scale_torch,
report_reconstruction,
require_quant_settings,
resolve_optimizer,
scale_bake_notice,
ue4m3_bits,
ue4m3_bits_torch,
coordinate_descent_refine,
coordinate_descent_refine_torch,
sweep_per_tensor_scale,
sweep_per_tensor_scale_torch,
get_ue4m3_lut,
get_fp4_torch_constants,
)
__all__ = [
"CTQ_NUM_ITER",
"DEFAULT_CONVERT_TO_QUANT",
"DEFAULT_LLAMA_CPP",
"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",
"FP4_LEVELS_SORTED",
"FP4_LEVEL_MAP",
"FP4_TABLE",
"QUANT_VERSION",
"ShapeView",
"TensorQuantizer",
"add_quant_arguments",
"add_rounding_arguments",
"bind_exclude",
"ctq_skips_key",
"eligible_weight",
"ensure_cuda_interpreter",
"import_gguf",
"load_gguf_modules",
"load_learned_converter",
"looks_like_spark",
"check_scale_policy",
"must_bake_nvfp4_scale",
"mtp_layer_tensor",
"bake_packed_nvfp4",
"optimize_block_scales",
"optimize_block_scales_torch",
"pack_nvfp4",
"preserve_scale_tensor",
"quant_profile",
"quant_settings",
"quantize_and_pack",
"refine_codes_for_scale",
"refine_codes_for_scale_torch",
"coordinate_descent_refine",
"coordinate_descent_refine_torch",
"sweep_per_tensor_scale",
"sweep_per_tensor_scale_torch",
"get_ue4m3_lut",
"get_fp4_torch_constants",
"report_reconstruction",
"require_quant_settings",
"resolve_optimizer",
"scale_bake_notice",
"ue4m3_bits",
"ue4m3_bits_torch",
]