v41-quant-worker / progress.py
apetersson's picture
v41 quant: progress reporter
4fcf06b verified
Raw
History Blame Contribute Delete
1.24 kB
import datetime, glob, json, os
out = '/workspace/v41-quant/q2-iq2-20260910'
plan = json.load(open(out + '/plan.json'))
shards = plan['shards']
total_q = sum(sum(t['out_bytes'] for t in s['tensors'] if t['role'] == 'quantised') for s in shards)
files = sorted(glob.glob(out + '/*.complete'), key=os.path.getmtime)
done = [os.path.basename(f).replace('.complete', '') for f in files]
q = sum(sum(t['out_bytes'] for t in s['tensors'] if t['role'] == 'quantised') for s in shards if s['output_shard'] in done)
m = [os.path.getmtime(f) for f in files]
recent = [m[j + 1] - m[j] for j in range(max(0, len(m) - 6), len(m) - 1)]
cad = sum(recent) / len(recent) if recent else 0.0
now = datetime.datetime.now(datetime.timezone.utc)
eta_s = cad * (len(shards) - len(done))
abs_t = (now + datetime.timedelta(seconds=eta_s)).strftime('%H:%M')
size = sum(os.path.getsize(out + '/' + s['output_shard']) for s in shards if os.path.exists(out + '/' + s['output_shard']))
total_bytes = sum(s['data_bytes'] for s in shards)
print(f"{now.strftime('%H:%M:%S')}Z shards {len(done)}/{len(shards)} {q / total_q * 100:.1f}% of quantised bytes "
f"{size / 1e9:.1f}/{total_bytes / 1e9:.1f} GB cadence {cad:.0f}s/shard ETA {eta_s / 60:.0f} min -> ~{abs_t}Z")