Download rebuild_external.py from nur-dev/unionmind-predictive-representations: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/nur-dev/unionmind-predictive-representations/resolve/main/rebuild_external.py
- Command line
-
hf download hf://nur-dev/unionmind-predictive-representations/rebuild_external.py
-
curl -L -o rebuild_external.py https://huggingface.co/nur-dev/unionmind-predictive-representations/resolve/main/rebuild_external.py
2.16 kB
| """Reconstruct the external compression matrix in a NEW output directory. | |
| The gas-drift archive has an older research-only notice. Use this command for | |
| research and retain that notice. No raw or processed gas-drift data is bundled. | |
| Scientific functions are unchanged; only paths/device and a new replay hash lock | |
| are supplied. The original failed gate is never revised. | |
| """ | |
| from pathlib import Path | |
| import argparse,hashlib,json,shutil,time | |
| import torch | |
| from reproduce import ROOT | |
| from unionmind.external_sufficiency import data,study,analysis | |
| def main(): | |
| p=argparse.ArgumentParser(description=__doc__);p.add_argument('--output',required=True);p.add_argument('--device',default='cuda:0');p.add_argument('--metrics-only',action='store_true');a=p.parse_args() | |
| out=Path(a.output).resolve();assert not out.exists(),'Use a new output directory; no overwriting.';out.mkdir(parents=True) | |
| assert a.device.startswith('cuda') and torch.cuda.is_available();torch.cuda.set_device(a.device);torch.backends.cuda.matmul.allow_tf32=False | |
| config=json.loads((ROOT/'protocols/external_sufficiency_protocol_01.json').read_text());config['device']=a.device;protocol=out/'replay_protocol.json';protocol.write_text(json.dumps(config,indent=2)) | |
| for module in (data,study,analysis):module.ROOT=out;module.PROTOCOL=protocol | |
| files=[*list((ROOT/'unionmind/external_sufficiency').glob('*.py')),ROOT/'unionmind/decision_sufficiency/core.py',protocol] | |
| lock={'files':{str(f):hashlib.sha256(f.read_bytes()).hexdigest() for f in files},'purpose':'reproduction; does not replace original preconfirmation lock','timestamp_unix':time.time()} | |
| data.write(out/'preconfirmation_lock.json',lock) | |
| data.acquire(config);manifest=json.loads((out/'sources/manifest.json').read_text());old=json.loads((ROOT/'provenance/external/sources/manifest.json').read_text()) | |
| assert [r['sha256'] for r in manifest['archives']]==[r['sha256'] for r in old['archives']] | |
| data.prepare(config);study.evaluate(config) | |
| if not a.metrics_only:analysis.run() | |
| print('External replay complete. The original external improvement gate remains failed.') | |
| if __name__=='__main__':main() | |