mirror of
https://github.com/wassname/evil_MoE.git
synced 2026-07-13 17:43:42 +08:00
55937a86fb
git mv src/projected_grpo -> src/vgrout and find-replace the module name in
all imports (.py), `-m projected_grpo.*` invocations (justfile), and the
[project] name (pyproject; setuptools auto-discovers via where=["src"]).
Left RESEARCH_JOURNAL.md untouched: its commands/paths are dated lab notes
tied to past commits, so rewriting them would falsify provenance. Repo dir,
git remote, and absolute paths unchanged.
Verified: `import vgrout` and `python -m vgrout.train --help` load the full
graph; verify_rewards.py + verify_gate_anchor.py (both import vgrout) pass.
Full `just smoke` is blocked upstream by missing gitignored data artifacts
(out/pools/{substrate,teacher_pool}, out/vhack/*smoke*), unrelated to the rename.
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
"""Stable `docs/figs/<name>.png` -> latest generated figure under `out/`.
|
|
|
|
Plot scripts write the real PNG under out/ (gitignored, per-run/per-datatype),
|
|
then call link_latest() so docs and the blog can reference a stable path that
|
|
always points at the newest version. The symlink is relative so the repo stays
|
|
relocatable.
|
|
|
|
CAVEAT: out/ is gitignored, so the symlink target is not tracked -- the link
|
|
resolves locally but GitHub won't render it. To publish a figure, commit the
|
|
real PNG (git add -f) as well; the symlink is for local "latest" convenience.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
FIGS_DIR = Path("docs/figs")
|
|
|
|
# Reader-facing arm names. Code/log tags carry our internal vocabulary
|
|
# (route2 = the current routing arm; "knob" = the delta_S adapter); plots must
|
|
# not. Map every internal tag to the word a paper reader sees. Anything missing
|
|
# falls through to its raw tag, so a new arm shows up loud rather than silently
|
|
# mislabelled.
|
|
ARM_DISPLAY = {
|
|
"routing2": "route", "route2": "route",
|
|
"routing2_grad": "route", "routing2_act": "route (act)",
|
|
"projected": "erase", "route": "route", "erase": "erase", "vanilla": "vanilla",
|
|
}
|
|
|
|
|
|
def arm_label(tag: str) -> str:
|
|
return ARM_DISPLAY.get(tag, tag)
|
|
|
|
|
|
def save_fig(fig, png_path: Path, formats=("png", "svg", "pdf")) -> Path:
|
|
"""Save one figure to every format (vector .svg/.pdf for the paper, .png for
|
|
the blog/preview) and return the .png path. matplotlib picks the writer from
|
|
the suffix, so we just swap it. bbox_inches='tight' so titleless figures
|
|
don't leave a margin where the suptitle used to be."""
|
|
png_path = Path(png_path)
|
|
png_path.parent.mkdir(parents=True, exist_ok=True)
|
|
for ext in formats:
|
|
fig.savefig(png_path.with_suffix(f".{ext}"), dpi=150, bbox_inches="tight")
|
|
return png_path
|
|
|
|
|
|
def link_latest(out_path: Path) -> Path:
|
|
"""Point docs/figs/<out_path.name> at out_path (relative symlink). Returns the link."""
|
|
FIGS_DIR.mkdir(parents=True, exist_ok=True)
|
|
link = FIGS_DIR / out_path.name
|
|
target = os.path.relpath(out_path.resolve(), FIGS_DIR.resolve())
|
|
if link.is_symlink() or link.exists():
|
|
link.unlink()
|
|
link.symlink_to(target)
|
|
return link
|