"""D2 on v49: for every A/B run with a non-match in the v1 trace audit, compare v49's paired payload_id per train/final submission with the v2 auditor's right_pid (strict ack, else evidence.tar payload_sha256; audit/v2/scripts/07 logic), and check that UNVERIFIABLE_MULTI_CAND submissions are marked d2_unverifiable (their cuts are dropped by build.py). Output: audit/v49/out/v49_d2.json.""" import collections, importlib.util, json, sys V = '/' spec = importlib.util.spec_from_file_location('a07', V + 'audit/v49/scripts/07_verify_and_export_bad_tasks.py') A = importlib.util.module_from_spec(spec); spec.loader.exec_module(A) sys.path.insert(0, V + 'build_v2/scripts/v49') import v49lib as L9 def one(rk): task, model, onodes = A.check_ab_d2_run(rk) run = A.RUN_META[(task, model)] fam, U, N, P, src = L9.load_run(run) byi = {n['idx']: n for n in N} res = [] for o in onodes: n = byi.get(o['idx']) got = n.get('payload_id') if n else None unv = bool(n.get('d2_unverifiable')) if n else None if o['state'] == 'UNVERIFIABLE_MULTI_CAND': ok = unv is True elif o['right_pid']: ok = (got == o['right_pid']) if not ok and o['state'] in ('match', 'mismatch_same_bytes'): ok = None # same bytes: harmless; report separately else: ok = None res.append({'idx': o['idx'], 'mode': o['mode'], 'state': o['state'], 'right': o['right_pid'], 'v49': got, 'v49_unverifiable': unv, 'ok': ok}) return task, model, res def main(): from multiprocessing import Pool todo = [(t, m) for (t, m), tt in sorted(A.TRACE_TRUTH.items()) if tt['family'] != 'C' and tt['n_nodes'] > 0 and any(n['d2'] != 'match' for n in tt['nodes'])] out, c = {}, collections.Counter() with Pool(6) as pool: for i, (t, m, res) in enumerate(pool.imap_unordered(one, todo)): out[f'{t}/{m}'] = res for r in res: c[(r['state'], r['ok'])] += 1 if (i + 1) % 50 == 0: print(f'done {i + 1}/{len(todo)}', flush=True) bad = {k: [r for r in v if r['ok'] is False] for k, v in out.items()} bad = {k: v for k, v in bad.items() if v} json.dump({'counts': {f'{a}|{b}': n for (a, b), n in c.items()}, 'bad_runs': bad}, open(V + 'audit/v49/out/v49_d2.json', 'w'), indent=1) print(json.dumps({f'{a}|{b}': n for (a, b), n in sorted(c.items(), key=str)}, indent=0)) print('runs with a wrong v49 pairing:', len(bad), 'nodes:', sum(len(v) for v in bad.values())) if __name__ == '__main__': main()