"""NVFP4A16 without a calibration dataset. Playbook §3.16, measured 2026-09-08 on this architecture: with scheme NVFP4A16 llm-compressor logs `Inferred DataFreePipeline` and NEVER touches the dataset. Passing one is therefore pure liability, and it cost two failures here: * llmcompressor demands a model PROCESSOR whenever a dataset is provided, which is what killed the v2 pass (`DogOnKeyboard` ships no processor_config.json). * building the calib set calls the fast tokenizer with truncation=True, which mutates the Rust backend in place and `save_pretrained` then BAKES that cap into the shipped tokenizer.json -- playbook §3.14, fatal on a newer transformers for a vision model. Dropping the dataset removes both for zero loss, because the quant is data-free. Everything else -- targets, ignore list, save path -- matches the reference script. """ import argparse, json, sys, importlib.util spec = importlib.util.spec_from_file_location( "ref", "/tank/aimodels/meromero-v2-nvfp4-work/quant_nvfp4_gemma.py") ref = importlib.util.module_from_spec(spec) # The reference module runs argparse at IMPORT with required=True args, so an # empty argv still exits 2. Feed placeholders; our own parse happens after. _real_argv = sys.argv sys.argv = ["ref", "--model", "/dev/null", "--calib", "/dev/null", "--out", "/dev/null"] spec.loader.exec_module(ref) sys.argv = _real_argv ap = argparse.ArgumentParser() ap.add_argument("--model", required=True) ap.add_argument("--out", required=True) ap.add_argument("--scheme", default="NVFP4A16") a = ap.parse_args() assert a.scheme.endswith("A16"), f"{a.scheme} is not weight-only; it needs calibration data" print(f"loading {a.model}", flush=True) model, tok = ref.load_model(a.model) from llmcompressor import oneshot from llmcompressor.modifiers.quantization import QuantizationModifier recipe = QuantizationModifier(targets="Linear", scheme=a.scheme, ignore=ref.IGNORE) print(f"NVFP4 oneshot (DATA-FREE): scheme={a.scheme}, Linear-only, " f"vision/audio/projector/embed/lm_head/norms kept BF16", flush=True) oneshot(model=model, recipe=recipe) print(f"saving -> {a.out}", flush=True) model.save_pretrained(a.out, save_compressed=True) tok.save_pretrained(a.out) print("DONE", flush=True)