File size: 5,465 Bytes
0a4f337 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | """Render the recorded experiment data; does not run or alter experiments."""
from pathlib import Path
import csv
import json
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
ROOT=Path(__file__).resolve().parents[1]
OUT=ROOT/'figures';OUT.mkdir(exist_ok=True)
plt.rcParams.update({'font.family':'DejaVu Sans','font.size':10,
'axes.spines.top':False,'axes.spines.right':False,
'axes.titleweight':'bold','figure.facecolor':'white','savefig.facecolor':'white',
'pdf.fonttype':42,'ps.fonttype':42})
summary=json.loads((ROOT/'results'/'summary.json').read_text())
methods=['wave_only','immediate_echo','random_echo_matched_rank','recursive_echo','classical_observable_quotient']
labels=['Coarse waves | 4','Immediate echo | 6','Random echo | 16','Recursive echo | 16','Classical quotient | 16']
colors=['#8e9cae','#7489a3','#ba9b73','#1e806f','#6362a1']
fig,axes=plt.subplots(1,2,figsize=(11,4.2),sharey=True)
for ax,mode,title in zip(axes,['held_out_open_loop','adaptive_closed_loop'],['Fixed held-out edit sequences','Adaptive edit selection']):
lookup={r['method']:r for r in summary['results'] if r['mode']==mode}
vals=[lookup[m]['pooled_relative_trajectory_error'] for m in methods]
for i,(v,c) in enumerate(zip(vals,colors)):
ax.barh(i,v,color=c,height=.62,left=0)
ax.text(max(v*1.4,3e-14),i,f'{v:.2e}',va='center',fontsize=9)
ax.set_xscale('log');ax.set_xlim(1e-15,15);ax.set_title(title,pad=14)
ax.set_yticks(range(len(labels)),labels);ax.invert_yaxis()
ax.set_xlabel('Relative trajectory error (pooled L2 norm)')
ax.grid(axis='x',alpha=.15)
ax.axvline(1e-12,color='#888888',linewidth=.8,linestyle=':')
fig.suptitle('Preserving future responses requires the recursive closure',fontsize=15,y=1.02)
fig.text(.5,-.035,'32 constructed systems; 16 trajectories per system; 24 edits. Classical reduction is an equivalent baseline.',ha='center',fontsize=9,color='#555555')
fig.tight_layout()
for ext in ['pdf','png']:
fig.savefig(OUT/f'echo_benchmark.{ext}',dpi=180,bbox_inches='tight')
plt.close(fig)
rows=list(csv.DictReader((ROOT/'results'/'self_application_trajectories.csv').open()))
fig,axes=plt.subplots(1,2,figsize=(11,4.2))
label_map={'full':'Full / exact 3-coordinate echo','task_only_1':'Task only (1 coordinate)',
'task_rule_2':'Task + learner (2 coordinates)','frozen_improver':'Frozen improver',
'oracle_step_1':'Oracle unit step'}
palette={'full':'#1e806f','task_only_1':'#8e9cae','task_rule_2':'#ba9b73',
'frozen_improver':'#6362a1','oracle_step_1':'#424a56'}
for method in label_map:
med=[]
for t in range(9):
v=[float(r['loss']) for r in rows if r['method']==method and int(r['generation'])==t]
med.append(np.median(v))
if method=='oracle_step_1':
axes[0].scatter([1],[1e-24],marker='v',color=palette[method],label='Oracle: exactly zero after 1 step',zorder=5)
else:
axes[0].semilogy(range(9),np.maximum(med,1e-24),'-o',markersize=3,color=palette[method],label=label_map[method])
axes[0].set_ylim(1e-24,2);axes[0].set_title('Loss on engineered scalar tasks')
axes[0].set_xlabel('Generation');axes[0].set_ylabel('Median quadratic loss, 32 initial states')
axes[0].legend(loc='lower left',fontsize=7.4);axes[0].grid(alpha=.15)
example=[r for r in rows if r['method']=='full' and int(r['seed'])==0]
axes[1].plot([int(r['generation']) for r in example],[float(r['learner_gain']) for r in example],'-o',label='Learner gain a',color='#1e806f')
axes[1].plot([int(r['generation']) for r in example],[float(r['improver_gain']) for r in example],'-s',label='Improver gain b',color='#6362a1')
axes[1].set_title('The rule improves its own gain (example)')
axes[1].set_xlabel('Generation');axes[1].set_ylabel('Gain');axes[1].set_ylim(0,1.05)
axes[1].legend();axes[1].grid(alpha=.15)
fig.suptitle('A bounded self-application sanity test',fontsize=15,y=1.02)
fig.text(.5,-.035,'The update formula is supplied by the designer; the known optimal one-step method wins. This is not general RSI.',ha='center',fontsize=9,color='#555555')
fig.tight_layout()
for ext in ['pdf','png']:
fig.savefig(OUT/f'echo_self_application.{ext}',dpi=180,bbox_inches='tight')
plt.close(fig)
fig,axes=plt.subplots(1,2,figsize=(10.5,4.0))
trace=[6,8,10,12,14,16]
axes[0].plot(range(len(trace)),trace,'o-',color='#1e806f',linewidth=2)
axes[0].set_title('Discovering future-sensitive directions')
axes[0].set_ylabel('Retained state coordinates');axes[0].set_xlabel('Closure iteration')
axes[0].set_ylim(0,20);axes[0].grid(alpha=.15)
renewed=summary['counterexamples']['outside_certified_span']['renewed_closure_rank_trace']
axes[1].plot(range(len(renewed)),renewed,'o-',color='#ad6c52',linewidth=2)
axes[1].axhline(64,linestyle=':',color='#7e7e7e');axes[1].set_ylim(0,70)
axes[1].set_title('One new edit can consume the entire budget')
axes[1].set_xlabel('Certificate renewal iteration');axes[1].set_ylabel('Retained state coordinates')
axes[1].grid(alpha=.15)
fig.suptitle('Compression is conditional on the allowed edits',fontsize=15,y=1.02)
fig.text(.5,-.035,'The new edit causes 0.25 output error before repair; exact repair expands the state from 16 to 64 coordinates.',ha='center',fontsize=9,color='#555555')
fig.tight_layout()
for ext in ['pdf','png']:
fig.savefig(OUT/f'echo_certificate_growth.{ext}',dpi=180,bbox_inches='tight')
plt.close(fig)
print('Rendered 3 figures as PDF and PNG.')
|