FTG64 commited on
Commit
a73cb4e
·
verified ·
1 Parent(s): 191e35a

code: trajectory logging, te_weights grid, chunk profile

Browse files
code/scripts/chunk_eval.py CHANGED
@@ -52,10 +52,13 @@ class Condition:
52
  k: int | None = None # actions executed per prediction in "replan" mode
53
  delay: int = 0 # observation latency in control steps
54
  displacement_cm: float = 0.0
 
55
 
56
  @property
57
  def name(self) -> str:
58
  mode = f"replan{self.k}" if self.mode == "replan" else self.mode
 
 
59
  return f"{mode}_d{self.delay:02d}_m{self.displacement_cm:g}"
60
 
61
 
@@ -82,6 +85,11 @@ def build_grid(name: str, modes: list[tuple[str, int | None]] | None = None) ->
82
  delay_sweep = [Condition(mode, k, delay=d) for mode, k in modes for d in DELAYS]
83
  displacement_sweep = [Condition(mode, k, displacement_cm=m) for mode, k in modes for m in DISPLACEMENTS_CM]
84
  return delay_sweep + displacement_sweep
 
 
 
 
 
85
  raise ValueError(f"unknown grid {name!r}")
86
 
87
 
@@ -175,10 +183,11 @@ class CubeDisplacement(gym.Wrapper):
175
  """
176
 
177
  def __init__(self, env: gym.Env, displacement_m: float, window: tuple[int, int] = DISPLACEMENT_WINDOW,
178
- seed_offset: int = 10_000):
179
  super().__init__(env)
180
  self.displacement_m = displacement_m
181
  self.window = window
 
182
  self.seed_offset = seed_offset
183
  self.records: list[dict] = []
184
  self._episode: dict | None = None
@@ -187,6 +196,13 @@ class CubeDisplacement(gym.Wrapper):
187
  def _physics(self):
188
  return self.env.unwrapped._env.physics
189
 
 
 
 
 
 
 
 
190
  def _cube_xy(self) -> np.ndarray:
191
  return self._physics().data.qpos[-7:-5].copy() # the cube's free joint is the last 7 qpos
192
 
@@ -230,6 +246,8 @@ class CubeDisplacement(gym.Wrapper):
230
  "reward_before_move": None,
231
  "first_step_at_reward": {},
232
  }
 
 
233
  self.records.append(self._episode)
234
  return obs, info
235
 
@@ -247,6 +265,8 @@ class CubeDisplacement(gym.Wrapper):
247
  if ep is not None:
248
  for level in range(1, int(reward) + 1):
249
  ep["first_step_at_reward"].setdefault(str(level), self._t)
 
 
250
  return obs, reward, terminated, truncated, info
251
 
252
 
@@ -302,8 +322,9 @@ def run_task(task: dict) -> dict:
302
  cond = Condition(**task["condition"])
303
  env_cfg, policy, preprocessor, postprocessor, env_pre, env_post = _load(task["checkpoint"], task["device"])
304
  vec = make_env(env_cfg, n_envs=task["n_envs"], use_async_envs=False)[env_cfg.type][0]
305
- vec.envs = [CubeDisplacement(e, cond.displacement_cm / 100.0, window=tuple(task['window'])) for e in vec.envs]
306
- executor = ChunkExecutor(policy, cond.mode, delay=cond.delay, k=cond.k)
 
307
  videos_dir = Path(task["out_path"]).with_suffix("") if task["n_videos"] else None
308
 
309
  start = time.time()
@@ -375,7 +396,7 @@ def main() -> None:
375
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
376
  parser.add_argument("--checkpoint", required=True, help="local pretrained_model directory")
377
  parser.add_argument("--checkpoint-label", default=None, help="name recorded in the results")
378
- parser.add_argument("--grid", choices=("validation", "core"), required=True)
379
  parser.add_argument("--only", nargs="*", default=None, help="run only these condition names from the grid")
380
  parser.add_argument("--modes", nargs="*", default=None, help="execution modes, e.g. full replan50 replan25 replan10 te")
381
  parser.add_argument("--window", default=f"{DISPLACEMENT_WINDOW[0]}:{DISPLACEMENT_WINDOW[1]}",
@@ -386,6 +407,8 @@ def main() -> None:
386
  parser.add_argument("--workers", type=int, default=min(8, os.cpu_count() or 1))
387
  parser.add_argument("--device", default="cuda")
388
  parser.add_argument("--videos-per-condition", type=int, default=0)
 
 
389
  parser.add_argument("--deterministic", action=argparse.BooleanOptionalAction, default=True,
390
  help="deterministic GPU kernels so reruns are identical (default on; --no-deterministic matches lerobot-eval)")
391
  parser.add_argument("--out", required=True, type=Path)
@@ -437,6 +460,7 @@ def main() -> None:
437
  "n_videos": args.videos_per_condition if i == 0 else 0,
438
  "deterministic": args.deterministic,
439
  "window": list(window),
 
440
  "out_path": str(out_path),
441
  }
442
  )
 
52
  k: int | None = None # actions executed per prediction in "replan" mode
53
  delay: int = 0 # observation latency in control steps
54
  displacement_cm: float = 0.0
55
+ te_coeff: float = 0.01 # temporal-ensembling weight exp(-c * i), i = 0 for the oldest prediction (ACT's default)
56
 
57
  @property
58
  def name(self) -> str:
59
  mode = f"replan{self.k}" if self.mode == "replan" else self.mode
60
+ if self.mode == "te" and self.te_coeff != 0.01:
61
+ mode = f"te{self.te_coeff:g}" # e.g. te0, te-0.05; the default keeps the plain "te" name
62
  return f"{mode}_d{self.delay:02d}_m{self.displacement_cm:g}"
63
 
64
 
 
85
  delay_sweep = [Condition(mode, k, delay=d) for mode, k in modes for d in DELAYS]
86
  displacement_sweep = [Condition(mode, k, displacement_cm=m) for mode, k in modes for m in DISPLACEMENTS_CM]
87
  return delay_sweep + displacement_sweep
88
+ if name == "te_weights":
89
+ # Does favoring recent predictions let temporal ensembling react to a moved cube, and at
90
+ # what latency cost? The default (0.01) runs are in the core grid.
91
+ return [Condition("te", delay=d, displacement_cm=m, te_coeff=c)
92
+ for c in (0.0, -0.05) for d, m in ((0, 0), (0, 6), (20, 0))]
93
  raise ValueError(f"unknown grid {name!r}")
94
 
95
 
 
183
  """
184
 
185
  def __init__(self, env: gym.Env, displacement_m: float, window: tuple[int, int] = DISPLACEMENT_WINDOW,
186
+ seed_offset: int = 10_000, log_steps: int = 0):
187
  super().__init__(env)
188
  self.displacement_m = displacement_m
189
  self.window = window
190
+ self.log_steps = log_steps # log right-arm joints and gripper-cube distance for the first N steps
191
  self.seed_offset = seed_offset
192
  self.records: list[dict] = []
193
  self._episode: dict | None = None
 
196
  def _physics(self):
197
  return self.env.unwrapped._env.physics
198
 
199
+ def _log_row(self) -> list[float]:
200
+ physics = self._physics()
201
+ grip = physics.named.data.xpos["vx300s_right/gripper_link"]
202
+ box = physics.named.data.xpos["box"]
203
+ right_arm = physics.data.qpos[8:14] # vx300s_right waist ... wrist_rotate
204
+ return [self._t, *np.round(right_arm, 5).tolist(), round(float(np.linalg.norm(grip - box)), 5)]
205
+
206
  def _cube_xy(self) -> np.ndarray:
207
  return self._physics().data.qpos[-7:-5].copy() # the cube's free joint is the last 7 qpos
208
 
 
246
  "reward_before_move": None,
247
  "first_step_at_reward": {},
248
  }
249
+ if self.log_steps:
250
+ self._episode["trajectory"] = [self._log_row()] # rows: step, 6 right-arm joints, gripper-cube distance
251
  self.records.append(self._episode)
252
  return obs, info
253
 
 
265
  if ep is not None:
266
  for level in range(1, int(reward) + 1):
267
  ep["first_step_at_reward"].setdefault(str(level), self._t)
268
+ if self.log_steps and self._t <= self.log_steps and not (terminated or truncated):
269
+ ep["trajectory"].append(self._log_row())
270
  return obs, reward, terminated, truncated, info
271
 
272
 
 
322
  cond = Condition(**task["condition"])
323
  env_cfg, policy, preprocessor, postprocessor, env_pre, env_post = _load(task["checkpoint"], task["device"])
324
  vec = make_env(env_cfg, n_envs=task["n_envs"], use_async_envs=False)[env_cfg.type][0]
325
+ vec.envs = [CubeDisplacement(e, cond.displacement_cm / 100.0, window=tuple(task['window']),
326
+ log_steps=task.get('log_steps', 0)) for e in vec.envs]
327
+ executor = ChunkExecutor(policy, cond.mode, delay=cond.delay, k=cond.k, te_coeff=cond.te_coeff)
328
  videos_dir = Path(task["out_path"]).with_suffix("") if task["n_videos"] else None
329
 
330
  start = time.time()
 
396
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
397
  parser.add_argument("--checkpoint", required=True, help="local pretrained_model directory")
398
  parser.add_argument("--checkpoint-label", default=None, help="name recorded in the results")
399
+ parser.add_argument("--grid", choices=("validation", "core", "te_weights"), required=True)
400
  parser.add_argument("--only", nargs="*", default=None, help="run only these condition names from the grid")
401
  parser.add_argument("--modes", nargs="*", default=None, help="execution modes, e.g. full replan50 replan25 replan10 te")
402
  parser.add_argument("--window", default=f"{DISPLACEMENT_WINDOW[0]}:{DISPLACEMENT_WINDOW[1]}",
 
407
  parser.add_argument("--workers", type=int, default=min(8, os.cpu_count() or 1))
408
  parser.add_argument("--device", default="cuda")
409
  parser.add_argument("--videos-per-condition", type=int, default=0)
410
+ parser.add_argument("--log-trajectory", type=int, default=0, metavar="N",
411
+ help="log right-arm joints and gripper-cube distance for the first N steps of each episode")
412
  parser.add_argument("--deterministic", action=argparse.BooleanOptionalAction, default=True,
413
  help="deterministic GPU kernels so reruns are identical (default on; --no-deterministic matches lerobot-eval)")
414
  parser.add_argument("--out", required=True, type=Path)
 
460
  "n_videos": args.videos_per_condition if i == 0 else 0,
461
  "deterministic": args.deterministic,
462
  "window": list(window),
463
+ "log_steps": args.log_trajectory,
464
  "out_path": str(out_path),
465
  }
466
  )
code/scripts/chunk_profile.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """How fast does an ACT chunk move, as a function of the index inside the chunk?
2
+
3
+ The policy predicts a chunk for demonstration frames of the approach phase. For every chunk
4
+ index i we measure the right-arm step size ||a[i+1] - a[i]|| (joint targets, radians per control
5
+ step) and average it over frames. For comparison we also measure the demonstrator's own step size
6
+ at the same frames.
7
+
8
+ This tests the replan-10 hypothesis: if the first actions of each chunk are slow, a policy that
9
+ only ever executes indices 0-9 moves slowly. Under latency d the executed slice starts at index d,
10
+ which would explain why latency helps replan 10.
11
+
12
+ Usage (small; no simulator):
13
+ python scripts/chunk_profile.py --checkpoint PATH --label NAME --out results/analysis/profile_NAME.json
14
+ """
15
+
16
+ import argparse
17
+ import glob
18
+ import json
19
+ from pathlib import Path
20
+
21
+ import numpy as np
22
+ import pandas as pd
23
+ import torch
24
+
25
+ RIGHT_ARM = slice(7, 13) # ALOHA action/state layout: left arm 0-5, left gripper 6, right arm 7-12, right gripper 13
26
+ DATASET = "lerobot/aloha_sim_transfer_cube_human"
27
+
28
+
29
+ def main() -> None:
30
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
31
+ parser.add_argument("--checkpoint", required=True)
32
+ parser.add_argument("--label", required=True)
33
+ parser.add_argument("--device", default="mps" if torch.backends.mps.is_available() else "cuda")
34
+ parser.add_argument("--frames-per-episode", type=int, default=6, help="frames sampled from steps 0-150 of each episode")
35
+ parser.add_argument("--out", type=Path, required=True)
36
+ args = parser.parse_args()
37
+
38
+ from lerobot.configs.policies import PreTrainedConfig
39
+ from lerobot.datasets.lerobot_dataset import LeRobotDataset
40
+ from lerobot.envs.configs import AlohaEnv
41
+ from lerobot.policies import make_policy, make_pre_post_processors
42
+
43
+ policy_cfg = PreTrainedConfig.from_pretrained(args.checkpoint)
44
+ policy_cfg.pretrained_path = Path(args.checkpoint)
45
+ policy_cfg.device = args.device
46
+ policy = make_policy(cfg=policy_cfg, env_cfg=AlohaEnv(task="AlohaTransferCube-v0"), rename_map={})
47
+ policy.eval()
48
+ pre, post = make_pre_post_processors(policy_cfg=policy_cfg, pretrained_path=args.checkpoint,
49
+ preprocessor_overrides={"device_processor": {"device": args.device},
50
+ "rename_observations_processor": {"rename_map": {}}})
51
+
52
+ ds = LeRobotDataset(DATASET, video_backend="pyav")
53
+ # Demonstration actions per episode, straight from the parquet files.
54
+ root = Path(ds.root)
55
+ actions = pd.concat(pd.read_parquet(f) for f in sorted(glob.glob(str(root / "data" / "**" / "*.parquet"), recursive=True)))
56
+ demo = {ep: np.stack(g.sort_values("frame_index")["action"].to_numpy()) for ep, g in actions.groupby("episode_index")}
57
+ starts = {ep: int(g["index"].min()) for ep, g in actions.groupby("episode_index")}
58
+
59
+ rng = np.random.default_rng(0)
60
+ chunk_steps, demo_steps, first_offsets = [], [], []
61
+ for ep in sorted(demo):
62
+ for t in sorted(rng.choice(np.arange(0, 150), size=args.frames_per_episode, replace=False)):
63
+ item = ds[starts[ep] + int(t)]
64
+ batch = {"observation.images.top": item["observation.images.top"].unsqueeze(0),
65
+ "observation.state": item["observation.state"].unsqueeze(0), "task": [""]}
66
+ with torch.no_grad():
67
+ chunk = policy.predict_action_chunk(pre(batch)) # (1, H, 14), normalized
68
+ chunk = post(chunk).cpu().numpy()[0] # joint targets
69
+ arm = chunk[:, RIGHT_ARM]
70
+ chunk_steps.append(np.linalg.norm(np.diff(arm, axis=0), axis=1)) # (H-1,)
71
+ first_offsets.append(float(np.linalg.norm(arm[0] - item["observation.state"].numpy()[RIGHT_ARM])))
72
+ demo_arm = demo[ep][int(t):int(t) + 12, RIGHT_ARM]
73
+ demo_steps.append(float(np.linalg.norm(np.diff(demo_arm, axis=0), axis=1).mean()))
74
+
75
+ profile = np.mean(chunk_steps, axis=0)
76
+ result = {
77
+ "label": args.label,
78
+ "n_frames": len(chunk_steps),
79
+ "step_size_by_index": profile.round(6).tolist(),
80
+ "mean_step_first_10": float(profile[:10].mean()),
81
+ "mean_step_10_to_40": float(profile[10:40].mean()),
82
+ "demo_mean_step_next_10": float(np.mean(demo_steps)),
83
+ "mean_offset_first_action_to_state": float(np.mean(first_offsets)),
84
+ }
85
+ args.out.parent.mkdir(parents=True, exist_ok=True)
86
+ args.out.write_text(json.dumps(result, indent=1))
87
+ print({k: v for k, v in result.items() if k != "step_size_by_index"})
88
+ print("step size at indices 0, 2, 5, 10, 20, 40, 80:", [round(float(profile[i]), 4) for i in (0, 2, 5, 10, 20, 40, 80)])
89
+
90
+
91
+ if __name__ == "__main__":
92
+ main()
code/scripts/jobs/run_grid.sh CHANGED
@@ -6,7 +6,7 @@
6
  # "hub:<repo>@<revision>:<subfolder>" (e.g. hub:FTG64/act_aloha_transfer_cube@025000:checkpoints/025000/pretrained_model)
7
  # LABEL short name recorded in the results and used for the output folder (results/<RUN>)
8
  # RUN output folder name inside results/ of the dataset repo
9
- # GRID validation | core ONLY optional space-separated condition names
10
  # SEEDS start:stop WORKERS / NENVS / BLOCK parallelism settings
11
  # VIDEOS videos per condition (default 0)
12
  # MODES optional space-separated modes (default: chunk_eval.py's MODES), e.g. "full replan50 replan25 replan10 te"
@@ -23,7 +23,7 @@ REPO=FTG64/act-chunking-study
23
  STUDY=/tmp/study
24
  : "${CKPT:?}" "${LABEL:?}" "${RUN:?}" "${GRID:?}" "${SEEDS:?}"
25
  WORKERS=${WORKERS:-7}; NENVS=${NENVS:-5}; BLOCK=${BLOCK:-25}; VIDEOS=${VIDEOS:-0}; ONLY=${ONLY:-}
26
- MODES=${MODES:-}; WINDOW=${WINDOW:-}; DETERMINISTIC=${DETERMINISTIC:-0}
27
 
28
  (while true; do echo "[mem $(date +%H:%M:%S)] $(free -m | awk '/Mem:/ {print $3 " MB used of " $2 " MB"}')"; sleep 60; done) &
29
  MEM_PID=$!
@@ -46,6 +46,7 @@ if [ -n "$ONLY" ]; then extra+=(--only $ONLY); fi
46
  if [ -n "$MODES" ]; then extra+=(--modes $MODES); fi
47
  if [ -n "$WINDOW" ]; then extra+=(--window "$WINDOW"); fi
48
  if [ "$DETERMINISTIC" = "1" ]; then extra+=(--deterministic); fi
 
49
  python "$STUDY/code/scripts/chunk_eval.py" --checkpoint "$POLICY" --checkpoint-label "$LABEL" --grid "$GRID" \
50
  "${extra[@]}" --seeds "$SEEDS" --block "$BLOCK" --n-envs "$NENVS" --workers "$WORKERS" \
51
  --videos-per-condition "$VIDEOS" --out "/tmp/$RUN" --hub-repo "$REPO"
 
6
  # "hub:<repo>@<revision>:<subfolder>" (e.g. hub:FTG64/act_aloha_transfer_cube@025000:checkpoints/025000/pretrained_model)
7
  # LABEL short name recorded in the results and used for the output folder (results/<RUN>)
8
  # RUN output folder name inside results/ of the dataset repo
9
+ # GRID validation | core | te_weights ONLY optional space-separated condition names
10
  # SEEDS start:stop WORKERS / NENVS / BLOCK parallelism settings
11
  # VIDEOS videos per condition (default 0)
12
  # MODES optional space-separated modes (default: chunk_eval.py's MODES), e.g. "full replan50 replan25 replan10 te"
 
23
  STUDY=/tmp/study
24
  : "${CKPT:?}" "${LABEL:?}" "${RUN:?}" "${GRID:?}" "${SEEDS:?}"
25
  WORKERS=${WORKERS:-7}; NENVS=${NENVS:-5}; BLOCK=${BLOCK:-25}; VIDEOS=${VIDEOS:-0}; ONLY=${ONLY:-}
26
+ MODES=${MODES:-}; WINDOW=${WINDOW:-}; DETERMINISTIC=${DETERMINISTIC:-0}; LOGTRAJ=${LOGTRAJ:-0}
27
 
28
  (while true; do echo "[mem $(date +%H:%M:%S)] $(free -m | awk '/Mem:/ {print $3 " MB used of " $2 " MB"}')"; sleep 60; done) &
29
  MEM_PID=$!
 
46
  if [ -n "$MODES" ]; then extra+=(--modes $MODES); fi
47
  if [ -n "$WINDOW" ]; then extra+=(--window "$WINDOW"); fi
48
  if [ "$DETERMINISTIC" = "1" ]; then extra+=(--deterministic); fi
49
+ if [ "$LOGTRAJ" != "0" ]; then extra+=(--log-trajectory "$LOGTRAJ"); fi
50
  python "$STUDY/code/scripts/chunk_eval.py" --checkpoint "$POLICY" --checkpoint-label "$LABEL" --grid "$GRID" \
51
  "${extra[@]}" --seeds "$SEEDS" --block "$BLOCK" --n-envs "$NENVS" --workers "$WORKERS" \
52
  --videos-per-condition "$VIDEOS" --out "/tmp/$RUN" --hub-repo "$REPO"
code/scripts/summarize.py CHANGED
@@ -222,13 +222,23 @@ def sweep_figure(by_ckpt: dict[str, list[dict]], kind: str, path: Path) -> None:
222
 
223
 
224
  def checkpoint_figure(ckpt_runs: list[Path], training_log: Path | None, path: Path) -> dict:
225
- points = []
 
 
226
  for run in ckpt_runs:
227
  eps = [e for e in load_run(run) if e["mode_name"] == "full" and e["delay"] == 0 and e["displacement_cm"] == 0]
228
  if eps:
229
- points.append((eps[0]["checkpoint"], cell(eps)))
230
- ours = sorted((int(name.rsplit("_", 1)[-1]), c) for name, c in points if name.startswith("ours"))
231
- reference = [(name, c) for name, c in points if not name.startswith("ours")]
 
 
 
 
 
 
 
 
232
  n_panels = 1 + (training_log is not None)
233
  fig, axes = plt.subplots(1, n_panels, figsize=(5.2 * n_panels, 3.6), squeeze=False)
234
  fig.patch.set_facecolor(SURFACE)
@@ -253,13 +263,14 @@ def checkpoint_figure(ckpt_runs: list[Path], training_log: Path | None, path: Pa
253
  err = np.array([[100 * (c["rate"] - c["lo"]) for _, c in ours], [100 * (c["hi"] - c["rate"]) for _, c in ours]])
254
  ax.errorbar(x, y, yerr=err, color="#2a78d6", linewidth=2, elinewidth=1, capsize=0, marker="o", markersize=7,
255
  markeredgecolor=SURFACE, markeredgewidth=1.5, zorder=3)
256
- for (s, c), xi, yi in zip(ours, x, y):
257
- ax.annotate(f"{100 * c['rate']:.0f}%", (xi, yi), textcoords="offset points", xytext=(0, 9),
258
- ha="center", fontsize=9, color=TEXT_2)
 
259
  for name, c in reference:
260
  ax.axhline(100 * c["rate"], color=MUTED, linewidth=1)
261
- ax.text(ax.get_xlim()[0] if not ours else x.min(), 100 * c["rate"] + 1.5,
262
- f"{name}: {100 * c['rate']:.1f}% (n={c['n']})", fontsize=9, color=TEXT_2)
263
  ax.set_ylim(0, 100)
264
  ax.set_xlabel("training step (thousands)")
265
  ax.set_ylabel("success rate (%)")
 
222
 
223
 
224
  def checkpoint_figure(ckpt_runs: list[Path], training_log: Path | None, path: Path) -> dict:
225
+ import re
226
+
227
+ runs = {}
228
  for run in ckpt_runs:
229
  eps = [e for e in load_run(run) if e["mode_name"] == "full" and e["delay"] == 0 and e["displacement_cm"] == 0]
230
  if eps:
231
+ runs[eps[0]["checkpoint"]] = eps
232
+ ours_runs = {int(m.group(1)): eps for name, eps in runs.items() if (m := re.search(r"ours_(\d+)", name))}
233
+ ours = sorted((step, cell(eps)) for step, eps in ours_runs.items())
234
+ ours_seeds = {e["seed"] for eps in ours_runs.values() for e in eps}
235
+ # Reference checkpoints are scored on the same seeds as our checkpoints so the comparison is paired.
236
+ reference = []
237
+ for name, eps in runs.items():
238
+ if re.search(r"ours_\d+", name):
239
+ continue
240
+ shared = [e for e in eps if e["seed"] in ours_seeds] or eps
241
+ reference.append((name.replace("ckpt_", ""), cell(shared)))
242
  n_panels = 1 + (training_log is not None)
243
  fig, axes = plt.subplots(1, n_panels, figsize=(5.2 * n_panels, 3.6), squeeze=False)
244
  fig.patch.set_facecolor(SURFACE)
 
263
  err = np.array([[100 * (c["rate"] - c["lo"]) for _, c in ours], [100 * (c["hi"] - c["rate"]) for _, c in ours]])
264
  ax.errorbar(x, y, yerr=err, color="#2a78d6", linewidth=2, elinewidth=1, capsize=0, marker="o", markersize=7,
265
  markeredgecolor=SURFACE, markeredgewidth=1.5, zorder=3)
266
+ for i, ((s, c), xi, yi) in enumerate(zip(ours, x, y)): # beside the point, clear of the CI bar
267
+ last = i == len(ours) - 1
268
+ ax.annotate(f"{100 * c['rate']:.1f}%", (xi, yi), textcoords="offset points", xytext=(-8 if last else 8, -2),
269
+ ha="right" if last else "left", va="top", fontsize=9, color=TEXT_2)
270
  for name, c in reference:
271
  ax.axhline(100 * c["rate"], color=MUTED, linewidth=1)
272
+ ax.text(x.min() if ours else 0, 100 * c["rate"] - 2, f"{name} checkpoint, same seeds: {100 * c['rate']:.1f}%",
273
+ fontsize=9, color=TEXT_2, va="top")
274
  ax.set_ylim(0, 100)
275
  ax.set_xlabel("training step (thousands)")
276
  ax.set_ylabel("success rate (%)")