"""Reproduce the ACTUAL failing call, not a paraphrase of it. quant_a16_datafree.py dies inside `AutoTokenizer.from_pretrained(path, trust_remote_code=True)`. A bare `AutoConfig.from_pretrained(dir)` does NOT reproduce it -- I checked, and all four config variants sailed through. So the trigger lives in the tokenizer path, and testing the config alone would have sent me off patching a file that was never the problem. POSITIVE CONTROL, and it is the whole point of this script: zerofata's canonical v2 tree quantized cleanly on 2026-08-21. If it now fails on this same call, the config is exonerated and the toolchain moved under us -- `vllm/vllm-openai:latest` was re-pulled mid-campaign and carries transformers 5.16.1 where the successful August run had 5.12.1. """ import json, os, tempfile, traceback from pathlib import Path import transformers from transformers import AutoTokenizer print(f"transformers {transformers.__version__}", flush=True) HERETIC = Path("/tank/aimodels/G4-MeroMero-v2-31B-heretic-bf16") CANON = Path("/tank/aimodels/meromero-v2-nvfp4-work/src") # Tokenizer loading reads config.json, so a variant needs the whole tree. Symlink # everything, then overwrite the one file under test. def tree(name, src, mutate=None): d = Path(tempfile.mkdtemp(prefix=f"tok-{name}-")) for f in src.iterdir(): if f.is_file(): os.symlink(f, d / f.name) if mutate is not None: cfg = json.loads((src / "config.json").read_text()) mutate(cfg) (d / "config.json").unlink() (d / "config.json").write_text(json.dumps(cfg)) return d def drop_plc(c): c["text_config"].pop("per_layer_config", None) def force_global(c): c["text_config"]["allow_global_per_layer_attribute_access"] = True cases = [ ("A-canonical-POSITIVE-CONTROL", tree("canon", CANON)), ("B-heretic-asis", tree("heretic", HERETIC)), ("C-heretic-drop-per_layer_config", tree("drop", HERETIC, drop_plc)), ("D-heretic-force-global-access", tree("force", HERETIC, force_global)), ("E-canonical-force-global-access", tree("canonforce", CANON, force_global)), ] for name, d in cases: print(f"\n=== {name} ===", flush=True) try: tok = AutoTokenizer.from_pretrained(d, trust_remote_code=True) except Exception as e: tb = traceback.format_exc().strip().splitlines() print(f" FAILED {type(e).__name__}") print(" " + "\n ".join(tb[-4:])) continue trunc = getattr(tok, "truncation_side", None) print(f" OK {type(tok).__name__} vocab={len(tok)} truncation_side={trunc}")