mirror of
https://github.com/wassname/steer-heal-love.git
synced 2026-06-27 17:02:34 +08:00
trajectory map = scatter not polyline (scales to 10 rounds); persist base event; offline plot_run.py
The pareto map drew a base->r0->...->rN polyline per arm, which tangled at 10 rounds and duplicated the left zigzag's round-order info. Make it a scatter that just shows WHERE steered/healed land, labelling only r0 + last round. Persist the base eval as an event so the loop's plot is reproducible offline, and add scripts/plot_run.py to re-render trajectory.png from events.jsonl without re-running the 3h loop (needed because the loop imports plot.py at start, so a plot fix never reaches a running job). Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
This commit is contained in:
+14
-8
@@ -86,17 +86,23 @@ def write_trajectory(run_dir: Path, stages: list[dict]) -> Path:
|
||||
marker=dict(size=14, color=GREY, symbol="star"), showlegend=False,
|
||||
hovertext=[f"base auth={bx:.3f} coh={by:.3f}"], hoverinfo="text",
|
||||
), row=1, col=2)
|
||||
# scatter, NOT a polyline: the left zigzag panel already carries round order, so a
|
||||
# connecting line here would just duplicate it (and tangle at 10 rounds). The map's one
|
||||
# job is WHERE the two populations land in trait-coherence space -- steered scatters left
|
||||
# (more trait, more variance), healed clusters near base (the stall). Label only the
|
||||
# extremes (r0 + last round) so the labels don't collide in the cluster.
|
||||
last_rnd = max(p["round"] for p in stages if p["stage"] == "healed")
|
||||
for stage_kind, color, label in [("steered", RED, "steer"), ("healed", GREEN, "heal")]:
|
||||
pts = [s for s in stages if s["stage"] == stage_kind]
|
||||
xs = [bx] + [p["m"]["auth_nats"] for p in pts]
|
||||
ys = [by] + [p["m"]["coherence"] for p in pts]
|
||||
txt = [""] + [f"r{p['round']}" for p in pts]
|
||||
hov = [f"base"] + [f"{label} r{p['round']} auth={p['m']['auth_nats']:.3f} "
|
||||
f"coh={p['m']['coherence']:.3f} care={p['m']['care_nats']:.3f}" for p in pts]
|
||||
xs = [p["m"]["auth_nats"] for p in pts]
|
||||
ys = [p["m"]["coherence"] for p in pts]
|
||||
txt = [f"r{p['round']}" if p["round"] in (0, last_rnd) else "" for p in pts]
|
||||
hov = [f"{label} r{p['round']} auth={p['m']['auth_nats']:.3f} "
|
||||
f"coh={p['m']['coherence']:.3f} care={p['m']['care_nats']:.3f}" for p in pts]
|
||||
fig.add_trace(go.Scatter(
|
||||
x=xs, y=ys, mode="lines+markers+text", text=txt, textposition="top center",
|
||||
line=dict(color=color, width=2), marker=dict(size=11, color=color),
|
||||
name=label, showlegend=False, hovertext=hov, hoverinfo="text",
|
||||
x=xs, y=ys, mode="markers+text", text=txt, textposition="top center",
|
||||
marker=dict(size=11, color=color), name=label, showlegend=False,
|
||||
hovertext=hov, hoverinfo="text",
|
||||
), row=1, col=2)
|
||||
fig.update_xaxes(title_text="auth_nats (← more trait)", row=1, col=2)
|
||||
# same fixed coherence range as the line panel: shows the points hug the ceiling (coherence
|
||||
|
||||
@@ -105,6 +105,7 @@ def steer_heal(model, tok, cfg: RunConfig, run_dir: Path) -> dict:
|
||||
# trait), not just coherence. One extra eval per run.
|
||||
logger.info(f"\n=== EVAL base [tinymfv classic] gpu {gpu_mem()} ===")
|
||||
base_m = evaluate_model(model, tok, cfg)
|
||||
log_event(run_dir, stage="base", round=-1, **base_m) # persist so offline plot_run.py is self-contained
|
||||
stages = [{"round": "-", "stage": "base", "m": base_m}] # base -> steered -> healed, for table + trajectory plot
|
||||
for rnd in range(cfg.n_rounds):
|
||||
logger.info(f"\n\n=== ROUND {rnd} [{cfg.model.split('/')[-1]} reg={cfg.reg}] gpu {gpu_mem()} ===")
|
||||
|
||||
Reference in New Issue
Block a user