Upload folder using huggingface_hub
Browse files- code/train_value_iteration.py +27 -16
- code/vast_bootstrap.sh +3 -2
code/train_value_iteration.py
CHANGED
|
@@ -186,20 +186,25 @@ def main():
|
|
| 186 |
help="States are sampled from walks of 1..this many moves. Past "
|
| 187 |
"~20 every state is fully mixed (God's Number), so a larger "
|
| 188 |
"value buys nothing.")
|
| 189 |
-
p.add_argument("--update-threshold", type=float, default=0.
|
| 190 |
-
help="Refresh the target network once
|
| 191 |
-
"
|
| 192 |
-
"an
|
| 193 |
-
"
|
| 194 |
-
"
|
| 195 |
-
"
|
| 196 |
-
"at 0.
|
| 197 |
-
|
|
|
|
| 198 |
help="Floor on the refresh interval, so one lucky batch cannot "
|
| 199 |
-
"ratchet the target forward.
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
p.add_argument("--eval-every", type=int, default=2000)
|
| 204 |
p.add_argument("--eval-n", type=int, default=200)
|
| 205 |
p.add_argument("--eval-depths", default="3,6,10,15,20")
|
|
@@ -273,15 +278,21 @@ def main():
|
|
| 273 |
opt.step()
|
| 274 |
|
| 275 |
l = loss.item()
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
target_net.load_state_dict(net.state_dict())
|
| 278 |
updates += 1
|
| 279 |
last_update = step
|
| 280 |
-
print(f" step {step}: target net updated (#{updates},
|
|
|
|
| 281 |
flush=True)
|
| 282 |
|
| 283 |
if step % 100 == 0:
|
| 284 |
-
print(f"step {step}/{args.max_steps} loss {l:.4f} "
|
| 285 |
f"tgt_updates {updates} {step/(time.time()-t0):.1f} it/s", flush=True)
|
| 286 |
|
| 287 |
if step % args.eval_every == 0 or step == args.max_steps:
|
|
|
|
| 186 |
help="States are sampled from walks of 1..this many moves. Past "
|
| 187 |
"~20 every state is fully mixed (God's Number), so a larger "
|
| 188 |
"value buys nothing.")
|
| 189 |
+
p.add_argument("--update-threshold", type=float, default=0.15, metavar="MOVES",
|
| 190 |
+
help="Refresh the target network once the net fits its current "
|
| 191 |
+
"target to within this mean absolute error, IN MOVES. "
|
| 192 |
+
"Deliberately not an MSE threshold: target values grow from "
|
| 193 |
+
"~1 early to ~20 at full distance and MSE scales with their "
|
| 194 |
+
"square, so the achievable loss floor rises through the run "
|
| 195 |
+
"and no fixed MSE value works at both ends (measured: 0.0006 "
|
| 196 |
+
"at step 400, 0.02-0.03 by step 1500). MAE in moves is "
|
| 197 |
+
"interpretable and roughly scale-stable.")
|
| 198 |
+
p.add_argument("--min-update-steps", type=int, default=100,
|
| 199 |
help="Floor on the refresh interval, so one lucky batch cannot "
|
| 200 |
+
"ratchet the target forward.")
|
| 201 |
+
p.add_argument("--max-update-steps", type=int, default=400,
|
| 202 |
+
help="Backstop: refresh after this many steps even if the "
|
| 203 |
+
"threshold is unmet. Each refresh propagates accuracy about "
|
| 204 |
+
"one move further from solved, so a threshold that stops "
|
| 205 |
+
"being reachable stalls the frontier outright while training "
|
| 206 |
+
"still looks healthy -- observed at 1300 steps with no "
|
| 207 |
+
"refresh. This bounds the run at ~max*30 steps.")
|
| 208 |
p.add_argument("--eval-every", type=int, default=2000)
|
| 209 |
p.add_argument("--eval-n", type=int, default=200)
|
| 210 |
p.add_argument("--eval-depths", default="3,6,10,15,20")
|
|
|
|
| 278 |
opt.step()
|
| 279 |
|
| 280 |
l = loss.item()
|
| 281 |
+
with torch.no_grad():
|
| 282 |
+
mae = (pred.float() - y).abs().mean().item()
|
| 283 |
+
since = step - last_update
|
| 284 |
+
ready = mae < args.update_threshold and since >= args.min_update_steps
|
| 285 |
+
forced = since >= args.max_update_steps
|
| 286 |
+
if ready or forced:
|
| 287 |
target_net.load_state_dict(net.state_dict())
|
| 288 |
updates += 1
|
| 289 |
last_update = step
|
| 290 |
+
print(f" step {step}: target net updated (#{updates}, "
|
| 291 |
+
f"mae {mae:.3f} moves{', forced' if forced and not ready else ''})",
|
| 292 |
flush=True)
|
| 293 |
|
| 294 |
if step % 100 == 0:
|
| 295 |
+
print(f"step {step}/{args.max_steps} loss {l:.4f} mae {mae:.3f} "
|
| 296 |
f"tgt_updates {updates} {step/(time.time()-t0):.1f} it/s", flush=True)
|
| 297 |
|
| 298 |
if step % args.eval_every == 0 or step == args.max_steps:
|
code/vast_bootstrap.sh
CHANGED
|
@@ -105,8 +105,9 @@ PYVI
|
|
| 105 |
--hidden "${HIDDEN:-512}" --layers "${LAYERS:-8}" --heads 8 \
|
| 106 |
--batch-size "${BATCH:-1024}" --lr "${LR:-3e-4}" --max-steps "${STEPS:-30000}" \
|
| 107 |
--scramble-depth "${WALK_DEPTH:-30}" \
|
| 108 |
-
--update-threshold "${UPDATE_THRESHOLD:-0.
|
| 109 |
-
--min-update-steps "${MIN_UPDATE_STEPS:-
|
|
|
|
| 110 |
--eval-every "${EVAL_EVERY:-1000}" --eval-n "${EVAL_N:-200}" \
|
| 111 |
--out checkpoints/value_iter --hub-repo "${HUB_REPO:-}"
|
| 112 |
echo "=== done ==="
|
|
|
|
| 105 |
--hidden "${HIDDEN:-512}" --layers "${LAYERS:-8}" --heads 8 \
|
| 106 |
--batch-size "${BATCH:-1024}" --lr "${LR:-3e-4}" --max-steps "${STEPS:-30000}" \
|
| 107 |
--scramble-depth "${WALK_DEPTH:-30}" \
|
| 108 |
+
--update-threshold "${UPDATE_THRESHOLD:-0.15}" \
|
| 109 |
+
--min-update-steps "${MIN_UPDATE_STEPS:-100}" \
|
| 110 |
+
--max-update-steps "${MAX_UPDATE_STEPS:-400}" \
|
| 111 |
--eval-every "${EVAL_EVERY:-1000}" --eval-n "${EVAL_N:-200}" \
|
| 112 |
--out checkpoints/value_iter --hub-repo "${HUB_REPO:-}"
|
| 113 |
echo "=== done ==="
|