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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user