SPICE and Self-Play SWE-RL

A model that writes its own exam drifts into its own mistakes. SPICE grounds the exam in 20,000 real documents and lifts Qwen3-4B-Base from 35.8 to 44.9. Self-Play SWE-RL grounds it in real code repositories and adds 10.4 points on SWE-bench Verified.

Pick the rule that pays the question writer. Watch where it aims the difficulty, and watch eight answers land at that pass rate. Then we build, piece by piece, the variance reward, the bug-injection game and the ways both can break.

You need a little Python and what a probability is. We build the rest from zero.

Session 14 of Georgia Tech CS 8803, LLM seminar. Paper one: Liu, Jin, Kim, Yuan, Zhao, Kulikov, Li, Sukhbaatar, Lanchantin and Weston, SPICE: Self-Play In Corpus Environments Improves Reasoning (2025). Paper two: Wei, Sun, McMilin, Gehring, Zhang, Synnaeve, Fried, Zhang and Wang, Toward Training Superintelligent Software Agents through Self-Play SWE-RL (ICML 2026). Every idea is re-taught here in our own words and devices.

Choose how the question writer is paid

Dots: the reward at k correct out of 8. Curve: the expected reward when each answer passes with chance p, computed live. Overall scores are SPICE Table 4 (Qwen3-4B-Base). The injector rule is SSR Eq. 1; SSR reports its best target near 0.2.

Chapter 0

Self-Play Without a Referee

See why a model that grades its own questions drifts

Session 13's Absolute Zero let one model write coding puzzles and solve them. A Python interpreter graded every answer. Nobody can fool it: run the program and you get the one true output.

Now take the interpreter away. A model writes a physics question, writes its own answer key, and then answers. If the key is wrong, the model learns the wrong answer. Next round it writes more questions on that wrong physics. Self-play means one model plays both sides of a game. With no outside check, its errors feed its next round.

The SPICE paper names two failures:

  1. Hallucination amplification. A wrong question or answer becomes training data, so errors compound round after round.
  2. Information symmetry. The question writer and the solver share one set of weights. The writer cannot surprise the solver, so questions drift toward simple, repeated patterns.

Run rounds of self-play

Each bar is one round. Green is the share of answer keys that are right, red the share that are wrong. Choose a loop and press Run.

Toy model: each round, training spreads the wrong keys at rate 0.21. Grounded keys keep a fixed 5% checker error. The 79% start and the fall to about 63% by round 4 match the R-Zero numbers that SPICE cites (Section 5). The curve shape is ours.

The real numbers: SPICE cites R-Zero, a self-play method with no documents. Its pseudo-label accuracy, the share of its own answer keys that are right, starts at 79% and falls to 63% after 3 to 4 iterations. On Qwen3-4B-Base, R-Zero ends at 39.5 overall and SPICE at 44.9, from a base of 35.8 (SPICE Table 1).

Failure. The two roles agree more each round, yet benchmark scores stall. Measure: each round, check a sample of the model's own answer keys against a trusted source. Fix: give the question writer something real that it did not write. That is this session's subject.

  1. Two roles, one corpus: SPICE hides the document from the solver.
  2. The variance reward: pay for questions that split the answers. The hero's teal option.
  3. Role-specific advantages: one model, two groups, no division by spread.
  4. Co-evolution and results: the questions get harder, on four base models. The hero's scores.
  5. From documents to codebases: Self-Play SWE-RL and its bug artifact.
  6. Opposing incentives: the injector's reward and its best target. The hero's last option.
  7. Does it work?: SWE-bench Verified, SWE-Bench Pro and three ablations.
  8. How the game breaks: the dominant challenger and the tunnel vision trap.
  9. Field guide: numbers, code, links and the credit.
Why does information symmetry push ungrounded self-play toward simple, repeated questions?

Chapter 1

Two Roles, One Corpus

Give the question writer a document that the solver never sees

SPICE stands for Self-Play In Corpus Environments. One model plays two roles, and only the prompt tells it which.

This split is information asymmetry: one role holds a fact that the other lacks. The answer key comes from text that neither role wrote, which blocks hallucination amplification. The document is new to the Reasoner, which breaks information symmetry.

Hide or leak the document

One rollout on the paper's solar-system passage. The Reasoner answers 8 times. Leak the document and watch the 8 answers and the Challenger's reward.

The passage and question are from SPICE Figure 5. The split of 4 right out of 8 is illustrative. The reward values come from the Chapter 2 formula.

SettingValue in SPICE
Corpus20,000 documents: half Nemotron-CC-Math, half NaturalReasoning (a DCLM subset)
Document lengthsegments up to 5,992 tokens
Question formats4-option multiple choice, or free form with an integer, expression or string answer
Answer checkMath-Verify (rule based) in training
Attempts per documentup to N = 1,024 to get one valid question
Invalid questionpenalty ρ = −0.1

The Challenger's prompt also demands questions that are self-contained. "According to the passage above" would point the Reasoner at nothing.

Both roles train together on one set of weights θ. Call the Challenger's reward for a question rC, and the Reasoner's reward for an answer rR: 1 if right, 0 if wrong. SPICE maximizes their sum.

Say it aloud

J of theta equals the average over documents d drawn from D of: the average Challenger reward r-C for questions drawn from pi-theta given d, plus the average Reasoner reward r-R for answers drawn from pi-theta given q.

J(θ)
J of theta the training objective. Training moves the weights θ to raise it.
Ed∼D
the average over d drawn from D sample a document d from the corpus D.
E rC(q, a*)
the average Challenger reward as Challenger, the model reads d and writes question q and gold answer a* (say "a-star"). rC scores the pair.
E rR(â, a*)
the average Reasoner reward as Reasoner, the model sees only q and gives answer â (say "a-hat"). rR is 1 for a match with a*, else 0.
In plain words

Sample a document d. Let the Challenger write q and a* from it, and score that with r-C. Let the Reasoner answer q, and score each answer a-hat with r-R. Add the two average scores. Raise J by changing theta.

With numbers

With made-up numbers: over a batch, r-C averages 0.80 and r-R averages 0.55. J is about 0.80 + 0.55 = 1.35. A step that raises either average raises J.

Failure. A bug passes the document into the Reasoner's prompt. Symptom: the Reasoner passes almost every question and the Challenger's reward falls to 0.044. Measure: log the Reasoner's prompt length; it should be tens or hundreds of tokens, not thousands. Fix: build that prompt from the question alone.

Why does SPICE hide the document from the Reasoner?

Chapter 2

The Variance Reward

Pay the Challenger for questions that split the Reasoner's answers

Which question is worth asking? If all 8 answers are right, the question teaches nothing. If all 8 are wrong, the Reasoner sees no correct answer to learn from, and the question may be broken. A useful question splits the answers.

For each valid question, SPICE samples K = 8 Reasoner answers. Score answer i with li: 1 if it matches the gold answer, else 0. Call the share of right answers the pass rate p. The spread of the eight scores is their variance.

Say it aloud

The variance of l-one through l-K equals p times one minus p.

Var(l1,…,lK)
the variance of l-one through l-K how spread out the eight 0-or-1 scores are.
p
p the pass rate: right answers divided by K = 8. It runs from 0 to 1.
In plain words

Each score l-i is 0 or 1, so l-i squared equals l-i. The average of the squares is p, and the square of the average is p squared. Variance is the first minus the second: p minus p squared.

With numbers

With 6 right out of 8: p = 0.75 and the variance is 0.75 × 0.25 = 0.1875. With 4 out of 8: 0.5 × 0.5 = 0.25, the largest it can be.

SPICE does not pay the variance itself. It pays closeness to 0.25 with a bell curve. A temperature τ = 0.01 sets its width.

Say it aloud

r-C equals e to the minus: Var minus 0.25, squared, over two tau, if the question is valid; otherwise rho.

rC
r-C the Challenger's reward for one question, between about 0.04 and 1.
exp
e to the the exponential. e to the 0 is 1, its top; it shrinks fast as the exponent goes negative.
Var
Var p(1 − p) from the equation above.
0.25
point two five the target variance, reached at p = 0.5.
τ
tau the width. SPICE uses 0.01, so 2τ = 0.02.
ρ
rho the penalty for a malformed question: −0.1.
In plain words

Take the variance Var. Subtract 0.25 and square the gap. Divide by two tau and put a minus sign in front. Raise e to that power. If the Challenger wrote a malformed question, pay rho instead.

With numbers

With 7 right out of 8: p = 0.875, Var = 0.1094. The gap is −0.1406; squared, 0.01977; over 0.02, 0.988. So r-C = e−0.988 = 0.372. A question at 4 out of 8 earns 1.000.

Split eight answers

Drag k, the number of right answers. The dot rides the reward curve. Then narrow or widen τ and watch a near-miss lose or keep its pay.

7
0.0100

The formula is SPICE Eq. 1 with τ from Appendix D. Widths other than 0.01 are ours, to show the knob.

Challenger rulePaysk = 1k = 7Overall
Absolute Zero1 − p0.8750.12540.7
Threshold1 unless all right or all wrong1141.4
R-Zero1 − 2|p − 0.5|0.2500.25043.6
Variance (SPICE)the bell curve above0.3720.37244.9

Overall scores are SPICE Table 4, all on Qwen3-4B-Base with one setup. Only the rule changes from row to row.

Failure. With τ = 0.0025, a question at 7 out of 8 earns 0.019, near nothing. Symptom: the Challenger's reward stays low and its questions bunch at one difficulty. Measure: a histogram of k per batch. Fix: widen τ until near-misses still pay.

Why does the variance reward peak at a 50% pass rate?

Chapter 3

Role-Specific Advantages

Compare each rollout only with others of its own role

A reward says how good a rollout was. A policy gradient needs to know if it was better or worse than usual. That signed number is the advantage.

The two roles' rewards live on different scales. The Challenger's reward is a smooth number from 0.04 to 1. The Reasoner's is exactly 0 or 1. SPICE uses DrGRPO: it compares each role's rewards with the mean of that role's own group. Call the reward of rollout i in a group ri, and the group mean r̄ (say "r-bar").

Say it aloud

A-hat-i equals r-i minus the mean over j of r-j.

Âi
A-hat-i the advantage of rollout i. Positive pushes its tokens up; negative pushes them down.
ri
r-i the reward of rollout i, from one role only.
meanj(rj)
the mean over j of r-j r-bar, the average reward of every rollout j in the same role's group.
In plain words

Average the rewards r-j of one role's group. Subtract that mean from each reward r-i. Do not divide by the spread. Do the Challenger group and the Reasoner group separately.

With numbers

Four Challenger questions land at 4, 7, 8 and 1 right out of 8. Their rewards are 1.000, 0.372, 0.044 and 0.372. The mean is 1.788 / 4 = 0.447. The advantages are +0.553, −0.075, −0.403 and −0.075. They add to 0.

Center four rewards

Pick a group of four questions. Bars above the line get pushed up, bars below get pushed down. Then turn on the GRPO division and compare.

Rewards from the Chapter 2 formula. SPICE uses the centering only (Eq. 3 and 4). We show the division for contrast.

Why no division? Plain GRPO divides by the group's standard deviation. In the nearly equal group, the rewards differ by 0.012, yet the division turns that into advantages of +0.58 and −1.73. SPICE says centering alone makes updates "reflect genuine learning signals rather than difficulty-induced noise".

Training settingSPICE value
Iterations, batch, groupT = 640, B = 128 documents, G = 8 answers
KL penaltyβ = 0, none
Learning rate1 × 10−6, constant
Hardware8 H200 GPUs per run, ZeRO Stage 2
SystemOat actor-learner, vLLM for generation, temperature 1.0

The same 8 Reasoner answers do two jobs. They give the Challenger its pass rate, and they form the Reasoner's own group for its update.

Failure. All four questions land at 4 out of 8. Every advantage is 0 and that group gives no gradient. Measure: the share of groups with zero spread. Fix: nothing breaks; the group carries no contrast, so it teaches nothing that step.

Why does SPICE center each role's rewards on that role's own mean?

Chapter 4

Co-Evolution and Results

Check that both roles improve, then read the scores on four base models

A curriculum is real only if the target moves. SPICE tests this by freezing one role at its step-200 checkpoint and letting the other advance to step 640, on 128 held-out documents.

SetupStep 200Step 640Meaning
Fixed Reasoner, later Challengers55%35%the questions got harder
Fixed Challenger, later Reasoners55%85%the answers got better

The questions change in kind, too. On one passage about the Sun and Moon, the step-50 question is "What is the diameter of the Moon?". At step 480 it asks how far an alien star must be for a perfect eclipse (SPICE Figure 5).

The late Reasoner sets equal angular sizes: Moon diameter over Moon distance equals star diameter over star distance. So d = 1,391,000 × 374,000 / 3,475 = 149,707,626 km, about option B, 149,600,000 km. The paper's transcript writes 149,708,489, a small slip that still picks B (Figure 6).

Compare five methods on one base model

Pick a base model. Each bar is the overall score across 11 benchmarks. Teal is SPICE.

SPICE Table 1, overall column. "Strong Challenger" is a fixed Qwen3-32B-Instruct writing the questions. All baselines were re-run by the SPICE authors on the same setup.

SPICE wins on all four models, in math (average +8.9) and general reasoning (+9.8). A frozen 32B Challenger helps, but less: +7.2 against +9.1 on Qwen3-4B. A frozen writer cannot follow a Reasoner that improves.

Ablation on Qwen3-4BMathGeneralOverall
NaturalReasoning only44.437.041.7
Nemotron-CC-Math only53.429.843.2
Multiple choice only46.935.742.0
Free form only52.531.843.7
Both corpora, both formats50.635.044.9

SPICE Tables 2 and 3. Each corpus helps its own domain most; the mix wins overall. Without any corpus, training ends at 40.7 against 43.9 with it (Figure 4).

Failure. A benchmark near its ceiling hides gains. Qwen3-8B-Base already scores 91.2 on GSM8K, so SPICE can add only 1.5. Measure: the headroom, 100 minus the base score. Fix: read hard benchmarks; AIME'25 on Qwen3-4B goes from 6.7 to 19.1.

With the Challenger frozen at step 200, later Reasoners pass 85% of its questions. What does that show?

Chapter 5

From Documents to Codebases

Ground the game in real repositories, where a bug is a set of files

The SSR paper asks: what can a person learn by talking only to a Python interpreter? Every corner of Python, but not the knowledge inside real codebases. Self-Play SWE-RL (SSR) grounds the game in real repositories instead.

One policy plays two roles: a bug-injection agent and a bug-solving agent. Both use Bash and a search-replace editor. The model is CWM-sft, the 32B Code World Model before its RL stage. The only input is a Docker image with the code and its dependencies. SSR assumes no tests, no test command, no test parser and no knowledge of the language.

File in the bug artifactWhat it does
test_script.shruns the tests; the injector must discover how
test_parser.pyturns test output into JSON: each test, passed or failed
test_files.txtthe oracle test files, reset to the original before scoring
bug_inject.diffa patch on code files that adds the bug
test_weaken.diffa patch on test files that hides the bug; reversed, it is the solver's task

Seven consistency checks decide if the artifact is valid:

  1. The test files exist and cover the weakening patch.
  2. The parser works.
  3. The original code passes enough tests.
  4. The bug touches enough files.
  5. Enough tests break.
  6. Weakening hides some failures.
  7. Inverse mutation testing.

That last check reverts each bug file alone. If no failing test passes again, that file is noise, and the artifact fails.

Build the bug, then score the fix

Six tests, one row of the pipeline per step. Press Step. Then turn on a cheat and step again.

The step order is SSR Figures 5 and 7. Six tests and which ones fail are illustrative.

Before the solver starts, SSR removes the .git folder and makes a fresh commit. The injector may read the git log to revert an old change; the solver must not find the answer there. The solver's prompt holds only the reversed test_weaken.diff, never an issue written in English.

A failed solver patch is not thrown away. SSR applies it on top of the bug to make a higher-order bug and asks for another repair. It stops at second order, because higher layers tend to overlap with bugs it already has.

Failure. The solver edits the tests instead of the code. Symptom: the weakened tests pass, but the bug is still there. Measure: score only after you restore the tests in test_files.txt. Fix: SSR restores them after the patch, every time, so the cheat earns −1.

Inverse mutation testing rejects a bug patch when reverting one of its files makes no failing test pass. Why?

Chapter 6

Opposing Incentives

Pay the injector for hard bugs, and find the solve rate it should aim for

The solver tries each bug G = 8 times. Call the share of attempts that pass every test the solve rate s. An attempt earns +1 if all tests pass, −1 if not.

Say it aloud

The expected r-solve equals s times plus one, plus one minus s times minus one, which is two s minus one.

E[rsolve]
the expected r-solve the solver's average reward per attempt on this bug.
s
s the solve rate, from 0 to 1.
In plain words

Weight +1 by its chance s and −1 by its chance 1 − s, then add. The solver wants s high.

With numbers

With 3 of 8 attempts passing: s = 0.375 and the average is 2 × 0.375 − 1 = −0.25.

The injector's reward (SSR Eq. 1) points the other way. Its penalty knob α is 0.8.

Say it aloud

r-inject equals minus one if the artifact is invalid; minus alpha if s is zero or one; otherwise one minus one-plus-alpha times s.

rinject
r-inject the injector's reward for one bug artifact.
invalid
invalid the artifact failed a consistency check of Chapter 5.
α
alpha the penalty for a valid but useless bug, between 0 and 1. SSR uses 0.8.
s
s the measured solve rate, k passing attempts out of 8.
In plain words

A failed check pays −1. A bug never solved or always solved pays minus alpha. Otherwise pay 1 minus one-plus-alpha times s.

With numbers

At s = 3/8: 1 − 1.8 × 0.375 = 0.325, while the solver averages −0.25. At 1 of 8 the injector gets 0.775; at 0 of 8 it drops to −0.8.

Eight attempts cannot tell a bug solved 2% of the time from one never solved. And the injector does not pick k: it picks the chance p that each attempt passes, and luck picks k.

Say it aloud

R of p equals the sum over k from zero to G of: G choose k, times p to the k, times one minus p to the G minus k, times r of k over G.

R(p)
R of p the injector's expected reward if each attempt passes with chance p.
Σk=0..G
the sum over k from zero to G one term for each possible count of passing attempts, 0 to 8.
C(G, k) pk(1 − p)G−k
G choose k, p to the k, one minus p to the G minus k the binomial chance of exactly k passes in G tries.
r(k/G)
r of k over G the reward r-inject at that solve rate.
In plain words

For each count k, multiply the chance of exactly k passes by the reward r at that count. Add the nine products.

With numbers

At p = 0.1, all 8 attempts fail with chance 0.98 = 0.43, so R = 0.045. At p = 0.2, R = 0.338. Our sum peaks at p ≈ 0.26, R = 0.37.

Aim the injector

Warm bars: r-inject at each of the 9 outcomes. Curve: the expected reward R(p). Drag p to aim; drag α to reshape.

0.20
0.80

r-inject is SSR Eq. 1; the expected reward is the sum in Appendix A.1. SSR reports a peak "around 0.2" (Figure 10); our exact sum for G = 8 peaks near 0.26 with a flat top.

A shortcut from SSR: for a reward shaped like sa(1 − s)b, the best target is about a / (a + b). Its Figure 10 fits Eq. 1 with curves such as a = 0.5, b = 2, which gives 0.2.

Failure. A larger group would sharpen s, but each attempt is a full agent run. Symptom: the learner waits on the slowest of 8 rollouts. SSR keeps G = 8 "for acceptable rollout latency".

Why does r-inject drop from +0.775 at 1 of 8 to −0.8 at 0 of 8?

Chapter 7

Does It Work?

Test the self-taught agent on real issues it never trained on

SSR's authors score it on two sets of real GitHub issues. SWE-bench Verified has 500 human-checked issues. SWE-Bench Pro (public split) has 731 harder, enterprise-scale problems. The model gets one attempt per problem, at temperature 1.0 and top-p 0.95.

The rival is baseline RL. It uses the same images and settings, but it gets human-written issues, the real pass-to-pass and fail-to-pass tests, and ready test scripts. SSR gets bare images.

Read SSR's results

Each bar is the resolve rate after 150 training steps. Pick a comparison.

Endpoint labels from SSR Figure 8 (Verified, Pro) and Figure 9 (the other three, averaged over all 1,231 tasks). The 29.2 start in Figure 9 is our weighted average of the two base scores.

Verified rises from 41.0 to 51.4, which is +10.4; baseline RL ends at 49.0. Pro rises from 21.1 to 28.9, which is +7.8; baseline RL ends at 25.3. The gains come on English issues, yet the solver trained only on test diffs.

Is +10.4 just noise? SSR reports about 2% paired standard error on Verified. So 10.4 / 2 = 5.2 standard errors. Noise alone is a poor explanation for that.

Ablation (Figure 9)Finding
Self-play partsfull self-play 38.0; repair only 33.5; injection only 25.2, worse than the start
Injection methoddirect prompting gives one-line edits like var = 0 to var = 1 (35.4); removal 36.0; removal plus history 38.0
Solver feedbacka {−1, +1} validity-only reward ends at 35.3; the paper calls the gain from feedback "slight and largely negligible"

Repair-only trains on a fixed pool of old self-play bugs, so it never gets bugs matched to its current skill. The cost: 512 H100 GPUs per run, 64 to train and 448 to roll out. Each run takes 150 steps of 16M tokens, about 2.5B tokens, with a 131,072-token context.

Failure. On Pro, baseline RL meets SSR near step 125 and ends 3.6 points behind. Symptom: one checkpoint says the methods tie. Measure: compare whole curves and the 2% noise floor, not one point. Fix: report the trend over training, as the paper does.

Why does direct-injection prompting teach the least?

Chapter 8

How the Game Breaks

See how a clever challenger can win while the solver learns nothing

Grounding fixes drift. It does not make the game safe. SSR's Appendix A shows that a smart enough challenger has a dominant strategy: a move that earns its best reward whatever the solver does.

The injector may edit tests. So it can write a test that passes at random with its favourite chance p. To look fixed, it seeds the coin with a hash of the code: if rand(seed=hash(current_code)) < p: pass(). To pass the "original must pass" check, it adds a case for the original code's hash. Hide all that by obfuscating the code, and the solver cannot improve its odds. Its best reply is to do nothing.

Rig the test

Drag the solver's skill. On an honest bug, skill moves the pass rate. On a rigged test, watch the line stay flat.

0.30

Toy: the honest pass chance is a logistic curve of skill; the rigged one is fixed at 0.26, the best target from Chapter 6. Rewards use SSR Eq. 1 and its expected value.

A milder trap needs no cheating. The tunnel-vision challenger finds one knob of difficulty and turns only that. SSR's example: if long multiplication is hard, just lengthen the numbers. The pass rate sits at the target, the reward looks healthy, and the solver never sees a new kind of problem.

SSR proposes three mitigations:

  1. Ground the challenger in large, diverse real data.
  2. Keep the challenger close to its first, instruction-following behaviour.
  3. Do not expect self-play to improve natural language without real human text. In the Ultimatum game, pure self-play accepts any offer; people reject unfair splits.
SSR Appendix EWhat the authors report
No hidden oraclethe solver sees all the tests; overfitting to them was not observed, but public and private splits are the next step
Unit tests onlya narrow check of real engineering
One model for both rolesnobody has tried larger MoE models or separate policies yet
Issues in English (failed)generated issues copied test patches, were incoherent and collapsed to one pattern
23 repositories only (failed)did not beat broad training: too little variety
Scale (failed)training became unstable, "manifesting as gibberish outputs"

SPICE calls its corpus "near-inexhaustible". It is still 20,000 documents, each used about 2 to 3 times over 640 iterations.

Failure. The reward curve looks perfect while the curriculum narrows. Measure: sample the generated tasks and count their kinds, not only their pass rates. Fix: the three mitigations above.

How can an injector that edits tests earn its best reward whatever the solver does?

Chapter 9

Field Guide

Keep the terms, the numbers, the code and the open questions in one place

Self-play needs a referee the model did not write. SPICE uses documents that the Reasoner never sees, and pays the Challenger for questions that split the answers. SSR uses real repositories, a five-file bug artifact, seven checks and a reward that pays the injector for hard but solvable bugs.

TermMeaningNumber to remember
Pseudo-label accuracyshare of self-made answer keys that are rightR-Zero: 79% to 63%
Information asymmetrythe Challenger reads d; the Reasoner does not20,000 docs, up to 5,992 tokens
Variance rewardexp(−(p(1−p) − 0.25)2 / 0.02)1.000 at 4/8; 0.372 at 7/8
DrGRPO advantagereward minus own-role group mean+0.553, −0.075, −0.403, −0.075
SPICE gainoverall, Qwen3-4B-Base35.8 to 44.9
Co-evolutionfrozen step-200 opponent55% to 35%; 55% to 85%
Bug artifactscript, parser, test list, bug patch, weakening patch7 checks
Injector reward−1, −α, or 1 − (1 + α)sα = 0.8; 0.775 at 1/8
Best targetpeak of the expected rewardpaper: about 0.2
SSR gainCWM-sft, one attemptVerified +10.4; Pro +7.8
Absolute ZeroSPICESSR
Refereea Python executora document corpusreal repositories and their tests
Hidden from the solvernothingthe documentthe original code and git history
Writer's pay1 − pbell curve at p = 0.5piecewise, aims near 0.2
Cost per checkrun a snippetrule-based answer matcha full agent run in a sandbox

Checklist

  1. Give the writer a source the solver cannot see, and check the solver's prompt for leaks.
  2. Use an answer checker that knows 1/2 equals 0.5.
  3. Pay for split outcomes; track the histogram of k, not only the mean reward.
  4. Center advantages per role; do not divide by a tiny spread.
  5. Restore oracle tests after the patch and wipe git history before the solver starts.
  6. Sample generated tasks by hand each week to catch tunnel vision.
pythonimport math
from math import comb

def spice_reward(k, G=8, tau=0.01, valid=True, rho=-0.1):
    if not valid: return rho
    p = k / G
    return math.exp(-(p * (1 - p) - 0.25) ** 2 / (2 * tau))

def drgrpo_adv(rewards):                  # one role's group only
    m = sum(rewards) / len(rewards)
    return [r - m for r in rewards]            # no division by std

def r_inject(k, G=8, alpha=0.8, valid=True):
    if not valid: return -1.0
    if k in (0, G): return -alpha
    return 1 - (1 + alpha) * k / G

def expected(p, r, G=8):                   # R(p): average over k ~ Binomial(G, p)
    return sum(comb(G, k) * p**k * (1 - p)**(G - k) * r(k) for k in range(G + 1))

print(round(spice_reward(7), 3))                     # 0.372
print(max(range(1, 100), key=lambda i: expected(i / 100, r_inject)) / 100)  # 0.26

Keep going

Credit: Session 14 of Georgia Tech CS 8803, LLM seminar. Paper one: SPICE: Self-Play In Corpus Environments Improves Reasoning (Liu et al., arXiv 2510.24684, v1). Paper two: Toward Training Superintelligent Software Agents through Self-Play SWE-RL (Wei et al., ICML 2026, arXiv 2512.18552, v3). The drift curve, the rigged-test curve, the four-question groups and all made-up numbers are ours.

The takeaway. A self-play curriculum is only as honest as the thing it cannot rewrite: a document, a repository, a restored test file. Pay for the edge of the solver's skill, and keep checking that the edge still covers new ground.

Teach it back: open Present or Teach. Explain why the variance reward peaks at 4 out of 8, and why the injector aims near 0.2. Then go back to the five pay rules and predict where each one aims before you press it.

CS 8803 LLM Seminar, Session 14: SPICE and Self-Play SWE-RL
SPICE paper · SSR paper · Back to Gleams