File size: 9,396 Bytes
5ce45af 7c3bd43 5ce45af | 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 | """Write results/train.md from the files on the node. Every figure is read from a file; a missing one is said.
python tools/report_train.py /data/train/mini > results/train.md
"""
import collections
import glob
import json
import os
import statistics
import sys
R = sys.argv[1] if len(sys.argv) > 1 else "/data/train/mini"
def load(p):
try:
return json.load(open(p))
except Exception:
return None
def largest(graft):
"""The largest absolute change of any weight, from the per-tensor records of train/graft.py."""
vals = []
for v in (graft.get("changed") or {}).values():
if isinstance(v, dict):
vals += [abs(x) for k, x in v.items() if isinstance(x, (int, float)) and "max" in k]
elif isinstance(v, (int, float)):
vals.append(abs(v))
return max(vals) if vals else "?"
def pass_info(label):
d = f"{R}/results/agent/{label}"
s = load(d + "/summary.json")
st, steps = collections.Counter(), []
for f in glob.glob(d + "/*/*.traj.json"):
try:
t = json.load(open(f))
except ValueError:
continue
st[t["info"].get("exit_status")] += 1
steps.append(sum(1 for m in t["messages"] if m["role"] == "assistant"))
return s, st, steps
def main():
out = []
w = out.append
pool = load(f"{R}/src/train/pool/pool.json") or {}
dis = load(f"{R}/src/train/pool/disjoint.json") or {}
grades = load(f"{R}/results/gen/grades.json") or {}
first = load(f"{R}/results/gen/grades-first-rate-limited.json") or {}
stats = load(f"{R}/results/sft/stats.json") or {}
info = load(f"{R}/runs/sft-r1/train_info.json") or {}
graft = load(f"{R}/models/RightNow-Mini/graft_report.json") or {}
w("# Training: self-distillation from the model's own passing attempts")
w("")
w("Measured on 2026-12-01 on the node (8 GPUs). Nothing below is estimated.")
w("")
w("## The data")
w("")
w(f"- Pool: `{pool.get('dataset')}` (licence {pool.get('license')}), {pool.get('n')} tasks: {pool.get('method')}, seed {pool.get('seed')}.")
w(f"- Kept apart from the evaluation: the pool's {len(dis.get('training_repositories', []))} repositories and the benchmark's "
f"{len(dis.get('evaluation_repositories', []))} share none (`train/pool/disjoint.json` lists both; `repositories_in_both` is "
f"`{dis.get('repositories_in_both')}`, `disjoint` is `{dis.get('disjoint')}`). No SWE-bench task is in the pool.")
w("- No closed model wrote any of it: every attempt is the stock Inkling 2 Mini on this node (vLLM with the checkpoint's own draft head),")
w(" the same bash-only agent as the evaluation, temperature 0.8, at most 75 steps and 8,192 new tokens a step.")
w("- A task's starting state is built in its container from the dataset itself (the bug applied, the tests that catch it removed);")
w(" grading uses SWE-smith's own harness on the task's official branch, so a patch counts only if it fixes the real task.")
w("")
if grades:
w("| Attempt | Tasks tried | Produced a patch | Passed the task's tests |")
w("|---|---|---|---|")
for k, v in sorted(grades.items()):
w(f"| {k} | {v.get('attempted')} | {v.get('with_patch')} | {v.get('resolved')} |")
w("")
if stats:
w(f"- Attempts that ran: {stats.get('trajectories')}. Passed: {stats.get('trajectories_passed')}. Distinct passing patches: {stats.get('distinct_passing_patches')}.")
w(f"- Tasks with at least one passing attempt: {stats.get('tasks_with_a_passing_attempt')} of {pool.get('n')}.")
w(f"- Kept for training: {stats.get('kept_conversations')} conversations, one per task: the passing attempt with the shortest context "
f"(median {stats.get('median_tokens_at_end'):,} tokens at its end, longest {stats.get('max_tokens_at_end'):,}).")
w("")
if first:
w("A first grading lost most tasks to GitHub's API limit (the harness asks the API about every task's repository, 60 calls an hour")
w("without a token) and read three attempts as 0 passed. The harness was patched locally to skip that call and everything was")
w("graded again; the first numbers are kept in `gen/grades-first-rate-limited.json` and not used.")
w("")
w("## The fine-tune")
w("")
w("Tool: Unsloth, LoRA on the attention weights only. The routed experts are not trained: the serving engine on this GPU")
w("family takes them only in their released 4-bit and 8-bit form (it refused a merged model with 16-bit experts), so a model")
w("whose experts changed could not be served by it. The tensors a round changed are written into a copy of the released")
w("checkpoint (`train/graft.py`); the experts and their quantization stay byte for byte as released.")
w("")
w("| Round | LoRA rank (alpha) | Trainable parameters | Conversations (longest allowed) | Epochs | Learning rate | Steps | Loss: first 10 steps, last 10 steps, average | Tensors changed, largest change |")
w("|---|---|---|---|---|---|---|---|---|")
rounds = (("1", "sft-r1", "RightNow-Mini", "ft"), ("2", "sft-r2", "RightNow-Mini-r2", "ft2"))
for name, run, model, _pre in rounds:
info = load(f"{R}/runs/{run}/train_info.json")
graft = load(f"{R}/models/{model}/graft_report.json") or {}
if not info:
w(f"| {name} | not finished | | | | | | | |")
continue
a = info.get("args", {})
losses = [x["loss"] for x in (info.get("log") or []) if "loss" in x]
f10 = sum(losses[:10]) / max(1, len(losses[:10])) if losses else None
l10 = sum(losses[-10:]) / max(1, len(losses[-10:])) if losses else None
w(f"| {name} | {a.get('rank')} ({a.get('alpha')}) | {info.get('trainable_params'):,} of {info.get('total_params'):,} | "
f"{info.get('conversations')} ({a.get('max_len'):,} tokens; {info.get('skipped_too_long_or_empty')} longer ones left out) | {a.get('epochs')} | {a.get('lr')} | "
f"{info.get('steps')} | {'%.3f, %.3f, %.3f' % (f10, l10, info.get('train_loss')) if losses else '?'} | "
f"{graft.get('changed_tensors', '?')}, {largest(graft)} |")
w("")
w("Loss is counted on the model's own reasoning, text and tool calls only. It did not go down in either round: the kept")
w("conversations are the stock model's own passing attempts, which it already predicts well.")
w("")
w("## Scores on the evaluation subset")
w("")
w("One attempt per task, greedy decoding, the same engine line (vLLM, no drafting), agent and limits as `baseline.md`.")
w("")
w("| Pass | Model | Resolved of 100 | Runs that submitted a patch | Runs that hit the 250-step limit | Steps per run, median |")
w("|---|---|---|---|---|---|")
scores = collections.defaultdict(list)
names = {"stock": "stock Inkling 2 Mini", "ft": "fine-tune round 1", "ft2": "fine-tune round 2"}
for pre in ("stock", "ft", "ft2"):
for k in (1, 2, 3):
label = f"{pre}-{k}"
if not os.path.isdir(f"{R}/results/agent/{label}"):
continue
s, st, steps = pass_info(label)
if s:
scores[pre].append(s["resolved"])
w(f"| {label} | {names[pre]} | {'**%d**' % s['resolved'] if s else 'not scored'} | {st.get('Submitted', 0) if st else ''} | "
f"{st.get('LimitsExceeded', 0) if st else ''} | {statistics.median(steps) if steps else ''} |")
w("")
w("Gate (the brief's): the fine-tuned model must score higher than stock by more than run-to-run noise. Read as: every")
w(f"fine-tuned pass above every stock pass, three passes each. Stock: {sorted(scores['stock'])}.")
w("")
for pre in ("ft", "ft2"):
if not scores[pre]:
w(f"- {names[pre]}: no pass scored.")
elif len(scores["stock"]) == 3 and min(scores[pre]) <= max(scores["stock"]):
w(f"- {names[pre]}: {sorted(scores[pre])}. **Not passed.**")
elif len(scores["stock"]) == 3 and len(scores[pre]) == 3:
w(f"- {names[pre]}: {sorted(scores[pre])}. **Passed.**")
else:
w(f"- {names[pre]}: {sorted(scores[pre])}. Not decided: {len(scores[pre])} of three passes scored, each above every stock pass so far.")
w("")
w("Greedy decoding is the setting the gate was written for, and it is this model's weak setting: at temperature 0 a run often")
w("repeats itself until the step limit (the last two columns). At temperature 0.8 the stock model resolves far more (`deep.md`).")
sampled = {}
for tag, who in (("deep", "stock Inkling 2 Mini"), ("ft08", "fine-tune round 1"), ("ft208", "fine-tune round 2")):
got = []
for d in sorted(glob.glob(f"{R}/results/{tag}/att-*"), key=lambda x: int(x.rsplit("-", 1)[1])):
sm = load(d + "/summary.json")
if sm:
got.append(sm["resolved"])
if got:
sampled[who] = got
if len(sampled) > 1:
w("So the same comparison at temperature 0.8 (single attempts, at most 100 steps, the engine with drafting):")
w("")
for who, got in sampled.items():
w(f"- {who}: {', '.join(map(str, got))} (median {statistics.median(got)})")
w("")
print("\n".join(out))
if __name__ == "__main__":
main()
|