From 5a72da7193450febc16707c47d904f8a3227d6c7 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Sat, 9 May 2026 15:58:36 +0000 Subject: [PATCH] Fix: apply hf_ptq __main__ post-parse conversions (dataset split, calib_size int list) When calling hf_main(args) directly, the __main__ block conversions that run between parse_args() and main() are skipped. calib_size stays as string '128' instead of [128], causing TypeError on list concatenation. --- scripts/quantize_nvfp4.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/quantize_nvfp4.py b/scripts/quantize_nvfp4.py index 4532a73..37a520f 100644 --- a/scripts/quantize_nvfp4.py +++ b/scripts/quantize_nvfp4.py @@ -227,6 +227,12 @@ def run_calibration(model_path, export_dir, calib_save_path, amax_snapshot_path, args = parse_args() sys.argv = saved_argv + # Apply the same post-parse conversions that hf_ptq's __main__ block does + # (these normally run between parse_args() and main() in the original script, + # but since we call main() directly, we have to do them ourselves) + args.dataset = args.dataset.split(",") if isinstance(args.dataset, str) else args.dataset + args.calib_size = [int(num_sample) for num_sample in args.calib_size.split(",")] + # ── Post-calibration hook ── # We monkey-patch export_quantized to add our defensive saves before export. import hf_ptq