File size: 7,566 Bytes
f227f52 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | #!/usr/bin/env python3
"""Plot the fixed-validation curves for the software-transfer arms."""
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.lines import Line2D
ARTIFACTS = Path(__file__).resolve().parent
INPUT = ARTIFACTS / "software-transfer-fixed-validation.csv"
OUTPUT = ARTIFACTS / "software-transfer-fixed-validation"
SERIES = {
"factorial_constdenom_g4_entropy_0.00003_lr_2e-6": ("constant_denominator", 4),
"factorial_sequence_mean_g8_entropy_0.00003_lr_2e-6": ("sequence_mean", 8),
"factorial_sequence_mean_g16_entropy_0.00003_lr_2e-6": ("sequence_mean", 16),
"factorial_sequence_mean_g32_entropy_0.00003_lr_2e-6": ("sequence_mean", 32),
"factorial_constdenom_g8_entropy_0.00003_lr_2e-6": ("constant_denominator", 8),
"factorial_constdenom_g16_entropy_0.00003_lr_2e-6": ("constant_denominator", 16),
"factorial_constdenom_g32_entropy_0.00003_lr_2e-6": ("constant_denominator", 32),
"factorial_constdenom_g64_entropy_0.00003_lr_2e-6": ("constant_denominator", 64),
}
GROUP_COLORS = {4: "#E69F00", 8: "#0072B2", 16: "#D55E00", 32: "#009E73", 64: "#CC79A7"}
LOSS_STYLES = {"sequence_mean": "--", "constant_denominator": "-"}
# Non-paired Qwen3-Coder archive estimates published from marin issue #8809:
# https://github.com/marin-community/marin/issues/8809#issuecomment-5516287195
BASE_REFERENCES = {
"BugsInPy": {"pass@1": 0.3049, "pass@16": 0.5761},
"SWE-Gym": {"pass@1": 0.3943, "pass@16": 0.9084},
}
BASE_STYLES = {"pass@1": ":", "pass@16": "-."}
def main() -> None:
frame = pd.read_csv(INPUT)
frame = frame[
frame["status"].isin(["authoritative", "authoritative_policy_stop", "authoritative_user_stop"])
].copy()
frame = frame[frame["recipe"].isin(SERIES)].copy()
# A restarted arm can have more than one authoritative attempt. Retain only
# the latest attempt so disconnected histories are not presented as a curve.
latest_attempts = frame.groupby(["dataset", "recipe"])["attempt"].transform("max")
frame = frame[frame["attempt"] == latest_attempts]
peaks = frame.groupby(["dataset", "recipe"])["pass_at_1"].max()
leaders = peaks.groupby(level="dataset").idxmax().to_dict()
plt.rcParams.update(
{
"font.family": "DejaVu Sans",
"font.size": 12,
"axes.titlesize": 17,
"axes.titleweight": "bold",
"axes.labelsize": 13,
"legend.fontsize": 10.5,
}
)
fig, axes = plt.subplots(1, 2, figsize=(15.5, 8.5), sharey=True)
for ax, dataset in zip(axes, ("BugsInPy", "SWE-Gym"), strict=True):
panel = frame[frame["dataset"] == dataset]
for recipe, (loss_reduction, group_size) in SERIES.items():
series = panel[panel["recipe"] == recipe].sort_values("step")
if series.empty:
continue
is_leader = leaders[dataset][1] == recipe
ax.plot(
series["step"],
series["pass_at_1"],
color=GROUP_COLORS[group_size],
linestyle=LOSS_STYLES[loss_reduction],
marker="o",
markersize=6 if is_leader else 5,
linewidth=3.0 if is_leader else 1.8,
alpha=1.0 if is_leader else 0.72,
zorder=3 if is_leader else 2,
)
peak_row = series.loc[series["pass_at_1"].idxmax()]
ax.scatter(
[peak_row["step"]],
[peak_row["pass_at_1"]],
marker="D",
s=68 if is_leader else 48,
color=GROUP_COLORS[group_size],
edgecolor="white",
linewidth=0.9,
zorder=4,
)
stop_rows = series[series["status"].isin(["authoritative_policy_stop", "authoritative_user_stop"])]
if not stop_rows.empty:
stop_row = stop_rows.sort_values("step").iloc[-1]
ax.scatter(
[stop_row["step"]],
[stop_row["pass_at_1"]],
marker="X",
s=105 if is_leader else 82,
color=GROUP_COLORS[group_size],
edgecolor="white",
linewidth=1.0,
zorder=5,
)
for metric, value in BASE_REFERENCES[dataset].items():
ax.axhline(
value,
color="#555555",
linestyle=BASE_STYLES[metric],
linewidth=1.6,
alpha=0.82,
zorder=1,
)
ax.text(
0.985,
value + 0.008,
f"Archive base {metric} {value:.4f}",
transform=ax.get_yaxis_transform(),
ha="right",
va="bottom",
fontsize=9.5,
color="#444444",
bbox={"facecolor": "white", "edgecolor": "none", "alpha": 0.82, "pad": 1.4},
zorder=6,
)
ax.set_title(dataset, pad=10)
ax.set_xlabel("Training step")
ax.set_xlim(-0.35, max(8.8, float(panel["step"].max()) + 0.8))
ax.set_ylim(0, 1.0)
ax.set_xticks(sorted(panel["step"].unique()))
ax.grid(True, color="#CFD5DC", linewidth=0.7, alpha=0.65)
ax.set_axisbelow(True)
axes[0].set_ylabel("Fixed-validation pass@1")
fig.suptitle("Software-transfer performance so far", fontsize=21, fontweight="bold", y=0.96)
fig.text(
0.5,
0.905,
"Seed-42 disjoint 128-task validation; matched factorial arms only. Diamonds mark peaks; X marks termination; bold lines lead.\n"
"Gray lines are non-paired Qwen3-Coder archive references from Marin issue #8809.",
ha="center",
va="top",
fontsize=12.5,
color="#444444",
)
legend_handles = [
*[
Line2D(
[0],
[0],
color=GROUP_COLORS[group_size],
marker="o",
linestyle="none",
markersize=7,
label=f"Group {group_size}",
)
for group_size in GROUP_COLORS
],
Line2D([0], [0], color="#333333", linestyle="--", linewidth=2.2, label="Sequence mean"),
Line2D([0], [0], color="#333333", linestyle="-", linewidth=2.2, label="Constant denominator"),
Line2D(
[0],
[0],
color="#555555",
marker="X",
markeredgecolor="white",
linestyle="none",
markersize=9,
label="Terminated",
),
Line2D(
[0],
[0],
color="#555555",
linestyle=BASE_STYLES["pass@1"],
linewidth=1.8,
label="Archive base pass@1",
),
Line2D(
[0],
[0],
color="#555555",
linestyle=BASE_STYLES["pass@16"],
linewidth=1.8,
label="Archive base pass@16",
),
]
fig.legend(
handles=legend_handles,
loc="lower center",
bbox_to_anchor=(0.5, 0.025),
ncol=5,
frameon=False,
title="Color = group size; line = loss reduction",
)
fig.tight_layout(rect=(0, 0.18, 1, 0.84), w_pad=3.0)
fig.savefig(OUTPUT.with_suffix(".png"), dpi=180, bbox_inches="tight")
fig.savefig(OUTPUT.with_suffix(".svg"), bbox_inches="tight")
if __name__ == "__main__":
main()
|