Cion-lab commited on
Commit
c5f35bf
·
verified ·
1 Parent(s): c3592b7

Upload train/preflight.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. train/preflight.py +27 -3
train/preflight.py CHANGED
@@ -388,6 +388,7 @@ def p3_cold_resume(args, R):
388
  # exercises the real step, the real checkpoint size and the real cursor, not a cheaper stand-in.
389
  common = ["--seq-len", str(args.seq_len), "--tokens", str(args.tokens),
390
  "--accum", str(args.accum), "--micro-batch", "4",
 
391
  "--hub-repo", args.ckpt_repo, "--prune", "--log-every", "5"]
392
  legs, cursors, losses = [], [], []
393
  for i in range(3):
@@ -416,20 +417,40 @@ def p3_cold_resume(args, R):
416
  "cursor_line": cur,
417
  "tail": out[-1200:] if r["rc"] else None,
418
  "err": (r["err"] or "")[-900:] if r["rc"] else None}
 
 
 
 
 
 
419
  legs.append(leg)
420
- print(f"VERDICT P3 leg {'abc'[i]} rc={r['rc']} auto_resume={leg['auto_resume']}", flush=True)
 
421
  if r["rc"] != 0:
422
  break
423
  R["P3"] = {"legs": legs, "ckpt_lines": cursors, "prior_loss_lines": losses}
 
 
 
 
 
 
 
 
 
 
424
  seen = [int(s.split("samples=")[1].split()[0].replace(",", "")) for s in cursors
425
  if "samples=" in s]
426
  R["P3_cursor_sequence"] = seen
427
  ok = (len(legs) == 3 and all(l["rc"] == 0 for l in legs)
428
  and all(l["auto_resume"] for l in legs[1:])
429
  and len(cursors) >= 3 and len(seen) >= 3
430
- and seen == sorted(seen) and len(set(seen)) == len(seen))
 
 
431
  R["P3_pass"] = bool(ok)
432
- print("VERDICT P3_pass=", R["P3_pass"], "cursors=", seen, flush=True)
 
433
  R["P3_hub_postclean"] = (sh(["python", "-c", _DEL % args.ckpt_repo],
434
  label="P3 hub postclean")["out"] or "").strip()[-200:]
435
 
@@ -439,6 +460,9 @@ def main():
439
  ap.add_argument("--stage", required=True,
440
  choices=["pargs", "p0", "p1", "p2", "p3", "summary", "all"])
441
  ap.add_argument("--seq-len", type=int, default=1024) # D-011: the config the main run will use
 
 
 
442
  ap.add_argument("--accum", type=int, default=32)
443
  ap.add_argument("--tokens", type=int, default=1_000_000_000)
444
  ap.add_argument("--steps-a", type=int, default=20,
 
388
  # exercises the real step, the real checkpoint size and the real cursor, not a cheaper stand-in.
389
  common = ["--seq-len", str(args.seq_len), "--tokens", str(args.tokens),
390
  "--accum", str(args.accum), "--micro-batch", "4",
391
+ "--attn", args.attn, "--grad-ckpt",
392
  "--hub-repo", args.ckpt_repo, "--prune", "--log-every", "5"]
393
  legs, cursors, losses = [], [], []
394
  for i in range(3):
 
417
  "cursor_line": cur,
418
  "tail": out[-1200:] if r["rc"] else None,
419
  "err": (r["err"] or "")[-900:] if r["rc"] else None}
420
+ for line in out.splitlines():
421
+ if line.startswith("RUN_JSON "):
422
+ try:
423
+ leg.update(json.loads(line[len("RUN_JSON "):]))
424
+ except Exception as e:
425
+ leg["run_json_unparseable"] = str(e)[:120]
426
  legs.append(leg)
427
+ print(f"VERDICT P3 leg {'abc'[i]} rc={r['rc']} auto_resume={leg['auto_resume']} "
428
+ f"tok_per_s={leg.get('tok_per_s')} peak_gb={leg.get('peak_gpu_gb')}", flush=True)
429
  if r["rc"] != 0:
430
  break
431
  R["P3"] = {"legs": legs, "ckpt_lines": cursors, "prior_loss_lines": losses}
432
+ # The last leg is the one that has run 60 steps of the frozen geometry, so it is also the throughput
433
+ # cell D-012's tripwire is read from. Neither earlier 1024 A/B cell used micro 4 *with* grad-ckpt.
434
+ frozen = legs[-1] if legs else {}
435
+ R["P3_frozen_rate_tok_per_s"] = frozen.get("tok_per_s")
436
+ R["P3_frozen_peak_gpu_gb"] = frozen.get("peak_gpu_gb")
437
+ R["P3_frozen_params"] = frozen.get("params")
438
+ R["P3_eta_hours_at_1B"] = (round(1e9 / frozen["tok_per_s"] / 3600, 2)
439
+ if frozen.get("tok_per_s") else None)
440
+ R["P3_D012_fallback_fires"] = (R["P3_frozen_rate_tok_per_s"] < 5150
441
+ if R["P3_frozen_rate_tok_per_s"] else None)
442
  seen = [int(s.split("samples=")[1].split()[0].replace(",", "")) for s in cursors
443
  if "samples=" in s]
444
  R["P3_cursor_sequence"] = seen
445
  ok = (len(legs) == 3 and all(l["rc"] == 0 for l in legs)
446
  and all(l["auto_resume"] for l in legs[1:])
447
  and len(cursors) >= 3 and len(seen) >= 3
448
+ and seen == sorted(seen) and len(set(seen)) == len(seen)
449
+ # ...and the thing that resumed was the frozen model, not a smaller stand-in.
450
+ and R["P3_frozen_params"] == 106194240 and bool(R["P3_frozen_rate_tok_per_s"]))
451
  R["P3_pass"] = bool(ok)
452
+ print("VERDICT P3_pass=", R["P3_pass"], "cursors=", seen,
453
+ "tok_per_s=", R["P3_frozen_rate_tok_per_s"], flush=True)
454
  R["P3_hub_postclean"] = (sh(["python", "-c", _DEL % args.ckpt_repo],
455
  label="P3 hub postclean")["out"] or "").strip()[-200:]
456
 
 
460
  ap.add_argument("--stage", required=True,
461
  choices=["pargs", "p0", "p1", "p2", "p3", "summary", "all"])
462
  ap.add_argument("--seq-len", type=int, default=1024) # D-011: the config the main run will use
463
+ ap.add_argument("--attn", default="eager", choices=["eager", "sdpa"],
464
+ help="passed through to the trainer by P3; named so a default change cannot silently"
465
+ " alter what the frozen-geometry measurement tested")
466
  ap.add_argument("--accum", type=int, default=32)
467
  ap.add_argument("--tokens", type=int, default=1_000_000_000)
468
  ap.add_argument("--steps-a", type=int, default=20,