prlq's picture
gr00t_lora_code: SETUP.md step-by-step guide + check_stats.py + finalize
3d57b4a verified
Raw History Blame Contribute Delete
809 Bytes
# check_stats.py <run_dir> <base_ckpt>: the LoRA run's normalization must equal the 80K's for mmb_go2_arm (state + action)
import json, sys, numpy as np
run = json.load(open(f'{sys.argv[1]}/processor/statistics.json'))
base = json.load(open(f'{sys.argv[2]}/statistics.json'))
tag = 'mmb_go2_arm'
r, b = run[tag], base[tag]
bad = 0
for grp in ('state', 'action'):
for key, st in r[grp].items():
for m in ('min', 'max', 'q01', 'q99', 'mean', 'std'):
if m in st and m in b[grp][key]:
d = np.abs(np.asarray(st[m]) - np.asarray(b[grp][key][m])).max()
if m in ('min', 'max', 'q01', 'q99') and d > 1e-6: bad += 1; print('DIFF', grp, key, m, d)
print('STATS_OK' if bad == 0 else f'STATS_MISMATCH {bad}', 'keys:', {g: sorted(r[g]) for g in ('state', 'action')})