A model writes code, fails a test, and gets back one number. SDPO lets the same model read the error message and blame the exact tokens that broke the code.
Learn how a language model can become its own teacher: it re-reads its failed attempt with the feedback in view, and the gap between its two readings becomes a learning signal for every token.
Switch between GRPO and SDPO, then turn the feedback on and off. Watch which tokens take the blame. Then we build, piece by piece, everything underneath: the reward that starves the model, the teacher that is the model itself, the loss, the gradient, the fixes that keep it stable, and the results.
You need a rough idea of what a probability is (a number from 0 to 1 that says how likely something is) and a little Python for the code. We build the rest from zero.
Based on “Reinforcement Learning via Self-Distillation” (arXiv 2601.20802) by Jonas Hübotter, Frederike Lübeck, Lejs Behric, Anton Baumann, Marco Bagatella, Daniel Marta, Ido Hakimi, Idan Shenfeld, Thomas Kleine Buening, Carlos Guestrin and Andreas Krause, from ETH Zurich, the Max Planck Institute for Intelligent Systems, MIT and Stanford. Their code. Every idea is re-taught here in our own words and devices. It is a reading for Model Evolution, a lecture of the MIT AI4AI course.
The question, the answer and the feedback line are the paper’s Figure 4 (Qwen3-8B). The per-token numbers are illustrative: they follow the shape of that figure, which the paper does not print. GRPO uses reward 0 minus a group average of 0.5 (4 of 8 attempts passed, also illustrative). Both modes share one colour scale: red deepens as the advantage falls toward −3.
Chapter 0
See why a pass or fail mark cannot tell a model which word broke its code, and what a richer message changes
Picture a student on a coding site. She submits a solution and the page shows one red word: Wrong Answer. She has no line number, no failing input, no error text. She can only change something and submit again.
Now picture a second student. His page says ZeroDivisionError: division by zero, line 73, last input [[26,30,2],[11,23,1]]. He knows what broke, where, and on which input. He fixes it in one try.
Both students failed the same test. The second one learned far more from the failure. This paper asks a simple question: when we train a language model to write code, why do we treat it like the first student?
Many strong reasoning models are trained with reinforcement learning (RL): the model tries something, gets a score, and changes itself so that high-scoring tries become more likely. Think of a dog learning a trick. It does something, it hears “good” or nothing, and over many tries it repeats what earned the treat.
When the score comes from a program that can check the answer, such as unit tests for code or an answer key for maths, the recipe has a name. It is reinforcement learning with verifiable rewards, or RLVR. The model writes an answer y to a question x. The checker returns a scalar reward r: a single number, often 1 for pass and 0 for fail.
That single number is the whole message. The paper calls it an information bottleneck: a narrow pipe that a lot of useful detail has to squeeze through, and mostly cannot.
A real answer is long. A solution to a coding problem can run to thousands of tokens, where a token is the small piece of text, often a word or part of a word, that a model reads and writes one at a time. If the answer fails, which tokens were at fault?
Deciding who gets the credit or the blame is called credit assignment. Think of a team that ships a late project. The manager says “it failed” to everyone. The one person who forgot to run the tests and the ten who did everything right all hear the same words. A single reward does this to every token.
The paper makes a sharp claim. The key limitation, it says, is not RL itself. It is the information bottleneck that a scalar outcome reward imposes. Many environments already produce much more than a number: runtime errors, failing unit tests, or a written verdict from a judge model. The authors call that rich feedback, and the setting reinforcement learning with rich feedback (RLRF).
Try it with the three scenes the paper uses. Pick a scene, then switch what the environment sends back.
The warm box is a failed attempt. The right box is what the environment returns. Choose a scene, then flip between one number and rich feedback.
Scene 1 is the paper’s Figure 2 (Mars Climate Orbiter, answer 100 lbf-s, reward −1.0). Scene 2 is its Figure 3, a LeetCode-style runtime error. Scene 3 is Figure 4. Word counts are of the feedback text shown here.
In every scene the scalar says the same thing: wrong. The feedback says what to do next. Notice that the feedback is also text. A language model reads text for a living. That is the opening the paper uses.
The method is Self-Distillation Policy Optimization (SDPO). In one sentence: the model reads its own failed attempt again, this time with the feedback in front of it, and every token where that second reading disagrees with the first gets a learning signal.
The headline numbers, all from the paper: on LiveCodeBench v6 with Qwen3-8B, SDPO reaches 48.8% accuracy against 41.2% for a strong GRPO baseline, and gets to the baseline’s final score with 4 times fewer generations. On science and tool-use tasks that return only pass or fail, SDPO reaches 70.2% against 66.6% on aggregate. At test time, on very hard questions, it finds a first solution with about 3 times fewer attempts.
We take these apart one at a time. Before the road, a note on the word distillation: it means training one model to copy the predictions of another. Here the “other” is the same model, so it is self-distillation. Chapter 2 shows why that makes sense.
Chapter 1
Build the standard recipe for reasoning RL from zero, and find the two places where it goes quiet
You run a bakery stall and want a better loaf. You bake eight loaves with small random changes, taste them, and keep the changes behind the best ones. Over many days the recipe improves. You never needed a theory of bread. You needed tries, a score, and a rule for shifting toward what scored well.
RLVR for language models is exactly this. Before we can fix its weak spot, we build it from zero.
A language model reads text and gives every possible next token a probability, as in the LLMs for Builders lesson. In RL this is called a policy, written πθ. The θ stands for all the model’s weights, the numbers training can change. The policy answers a question x by drawing one token at a time until the answer y is done.
One such attempt is a rollout. Its probability is a product of small steps: πθ(y1 | x) times πθ(y2 | x, y1), and so on. The checker then gives the rollout a reward r. For code, r is 1 if all tests pass and 0 if not.
The goal of training is to raise the expected reward: the average score over many rollouts. Written out, J(θ) = E[ r(y | x) ] with y drawn from πθ. In words: “be the policy whose average attempt scores best.”
How do you change the weights to raise the average score? The central idea of policy gradient methods is simple. For each token in a rollout, look at its probability. If the rollout did well, push that probability up. If it did badly, push it down. A small push per token, summed over many rollouts, shifts the whole policy.
Two details matter. The push needs a size and a sign. And the raw reward is a poor size: if every attempt scores around 0.9, pushing up all of them just adds noise. So we subtract a reference level, called a baseline, and push by the difference. That difference is the advantage: how much better than usual this attempt was.
Group Relative Policy Optimization (GRPO) picks the baseline in a neat way. Sample G rollouts for the same question. Score them all. Use the group’s average reward as the baseline. No separate value model is needed.
The update then pushes every token of rollout i by the same amount:
∇J ≈ (1/G) ∑i ∑t Ai · ∇θ log πθ(yi,t | x, yi,<t)
Read it from the right. The gradient of log π says “which way to move the weights to make this token likelier.” The factor Ai says “how hard, and in which direction.” The sums run over all rollouts i and all tokens t. (Real implementations add clipping and length normalisation. The paper’s baseline includes several such improvements; we leave them out to keep the idea clear.)
Now watch it work. Slide the number of passing attempts out of eight.
Each column is one attempt for the same question. Green passed, red failed. The bar is its advantage. Drag how many of the eight passed.
Illustrative: rewards are 1 or 0 and G = 8. The advantage is r minus the group mean, exactly as in the paper’s GRPO line; the rest of the real loss (clipping, length normalisation) is omitted. The 20 cells stand for the tokens of one failed answer.
Take G = 8 with 2 passes. The mean reward is 2/8 = 0.25. Each passing attempt gets 1 − 0.25 = +0.75. Each failing attempt gets 0 − 0.25 = −0.25. The advantages always sum to zero: 2 × 0.75 + 6 × (−0.25) = 0. The group splits into “above average” and “below average”.
Symptom: on a hard question the training curve is flat. Measurement: slide the device to 0 passes. The mean is 0, so every advantage is 0 − 0 = 0. Slide to 8 and the same happens. The paper says it directly: when all rollouts in a group get the same reward, GRPO advantages collapse to zero and learning stalls.
Fix, in the usual toolkit: build a curriculum so each question is neither too hard nor too easy, or sample more. SDPO takes another road: it adds a signal that does not depend on a pass.
Look at the 20 cells under the bars. Every token of a failed answer receives the same −0.25. If the answer is 5,000 tokens long and one wrong line caused the failure, the other 4,999 tokens are pushed down too. Across many rollouts the useful tokens recover, because good ones also appear in passing answers. It takes many samples.
One known alternative is distillation from a strong teacher: a bigger model gives the student a target for every token. That is dense credit, but it needs a stronger model. The paper notes strong teachers are often unavailable when the goal is to push past the best existing model. Table 1 of the paper sorts the options.
| Method | Sampling | Signal | Feedback source |
|---|---|---|---|
| SFT / distillation | off-policy | rich | a strong teacher |
| On-policy distillation | on-policy | rich | a strong teacher |
| RLVR, such as GRPO | on-policy | weak | the environment |
| SDPO (this paper) | on-policy | rich | the environment |
On-policy means the model learns from its own fresh attempts, not from a fixed pile of someone else’s. SDPO is the only row that is on-policy, rich, and needs no stronger teacher. The next chapter shows how it gets there.
Chapter 2
Turn the current model into a teacher by changing only what it reads, then score its old attempt a second time
You write an essay and hand it to a friend. Your friend reads it and says: “Your second paragraph claims the opposite of your first.” You instantly see it. You did not need a new brain. You needed one more piece of information in front of you.
Language models have the same talent. Show a model its own failed answer and a note about the failure, and it can often say what went wrong and propose a fix. The paper builds its whole method on this one habit.
In-context learning means a model changes its behaviour because of what is in its prompt, with no change to its weights. Give it three examples of a task and it does the fourth. Give it an error message and it repairs the code. The prompt is the model’s short-term memory, and it is free to rewrite.
Many earlier methods use this habit by asking the model to retry with the feedback in the prompt. That produces a new attempt. The paper does something different. It does not ask for a new attempt. It asks: given this feedback, how would I have judged each token of the attempt I already made?
The paper defines two roles that share the same weights θ. The student is the policy as we know it: it reads the question x and predicts each next token. The self-teacher is the very same network, reading the question and the feedback f.
The paper expects the teacher to be right more often, because it sees more. It writes the key observation plainly: we can use the same policy in two roles, as the student for the first attempt, and as the teacher to judge the value of actions in hindsight.
The feedback f can hold two kinds of information. The first is environment output: a runtime error, a list of failed tests, a judge model’s comments. The second is a sample solution: a correct attempt by the same student, if another rollout in the same group passed. If the attempt itself passed, it is shown as the correct solution. No expert model is needed.
The feedback goes into a fixed reprompt template (the paper’s Table 2). The user turn holds the question, the correct solution if there is one, the line “The following is feedback from your unsuccessful earlier attempt:” with the environment output, and the instruction “Correctly solve the original question.” Then the assistant turn contains the original attempt. Build one yourself.
Switch parts of the feedback on and off. The box shows the prompt the teacher reads. The bars show what the paper measured for the combinations it tested.
Template wording is the paper’s Table 2; the example question and attempt are its Figure 4. Bars are Table 6 (Qwen3-8B on LCB v6, SDPO training until step 60, 3 seeds): student accuracy after training, and the percentage of cases where the teacher received the same environment output as the student’s first attempt (lower means more varied ideas). Combinations the paper did not test show no highlight. Table 2’s caption says the output paragraph is skipped when a solution is available; Table 6 tests both together.
Here is the data flow, with shapes. Let the answer have T tokens and the vocabulary have V entries.
Steps 3 and 4 are single forward passes over text that already exists, much like reading a prompt. They do not generate anything new. The paper stresses this: the method incurs no sampling overhead. It just recomputes the log-probabilities of the original attempt under the teacher’s longer context. Its measured cost is a few percent of step time (Chapter 5).
Task: write a Python function that returns all numbers from 1 to n. The student answers return list(range(1, n + 1)). The feedback says “Don’t include n.” Now the teacher re-reads those same tokens. At the token +, the student gave it high odds. The teacher, who has read the feedback, expects the closing bracket instead, so it gives + low odds. The paper shows that only a few tokens light up: the rest agree. The model found its own bug with no solution in view.
Symptom: training makes the model less varied. Measurement: the last bar row. When the paper put the student’s own attempt y inside the teacher’s prompt, the “same output” rate jumped to 30.0%, against 10.1% to 13.7% for the other variants, and the average entropy of the student fell from about 0.40 to 0.23. Entropy here measures how spread out the model’s choices are. Fix: leave the attempt out of the prompt. The paper adds that results are not sensitive to the exact wording of the template.
Chapter 3
Measure how far the student’s next-token odds sit from the teacher’s, and shrink that gap token by token
Two weather forecasters look at the same sky. One says 60% chance of rain. The other, who has read tonight’s radar, says 4%. You want a single number for how much they disagree, so that you can ask the first forecaster to move toward the second. That number is what this chapter builds.
At each position a model gives a list of probabilities over its vocabulary. Take just three tokens: “+”, “)” and everything else. The student says (0.60, 0.30, 0.10). The teacher says (0.04, 0.72, 0.24). How far apart are these lists?
The KL divergence (Kullback–Leibler divergence) answers with one number. For two lists p and q it is KL(p ‖ q) = ∑i p(i) · log( p(i) / q(i) ). Each term asks: “how many times more likely did p think token i was than q did?” The log turns that ratio into a size, and the weight p(i) counts the token by how often p expects it.
Work it with natural logs. Token “+”: 0.60 × ln(0.60 / 0.04) = 0.60 × 2.708 = 1.625. Token “)”: 0.30 × ln(0.30 / 0.72) = 0.30 × (−0.875) = −0.263. Other: 0.10 × ln(0.10 / 0.24) = −0.088. Total: 1.625 − 0.263 − 0.088 = 1.27 nats. (A nat is the unit when the log is natural.)
Two facts make KL a good loss. It is never negative. And it is exactly zero only when the two lists are identical. So pushing it down pulls p toward q.
Now put the student in the first slot and the teacher in the second, one position at a time, and add up along the answer.
Play with one position. Drag the student toward the teacher and watch the loss fall to zero.
Warm bars are the student’s odds, purple bars the teacher’s. Drag each side’s chance of “+”. Then try the other two divergences.
Toy numbers: three tokens, with the remaining probability split 3 to 1 between “)” and “other” on both sides. Natural logs. The default 0.60 and 0.04 are illustrative, in the spirit of the paper’s Figure 4. The paper uses reverse KL with rich feedback and test-time training, and Jensen–Shannon for the science and tool-use runs (Table 12).
KL is not symmetric. KL(student ‖ teacher) multiplies each log-ratio by the student’s probability. It is large when the student puts weight on something the teacher thinks is unlikely, like the 0.60 on “+” above. It is mild when the student ignores something the teacher likes. So this direction punishes the student’s own confident mistakes. Because the rollout came from the student, those are the mistakes that matter. Try the second button: the number changes, but the minimum is still at zero.
The Jensen–Shannon divergence is a symmetric cousin. It compares each list to their average m = (p + q) / 2 and averages two KL terms. The paper adopts it in some settings because it was reported to stabilise on-policy distillation from an external teacher.
The teacher and the student share weights θ. A gradient says which way to nudge the weights to lower the loss. If the gradient also flowed through the teacher, the cheapest way to lower the gap would be to make the teacher forget the feedback and look like the student. The loss would fall. Nothing would be learned. The stop-gradient blocks that route: the teacher is a fixed target, the student does all the moving.
Symptom without it: the loss drops quickly but accuracy does not rise. Measurement: compare the teacher’s accuracy on the same batch; it drifts down toward the student’s. Fix: detach the teacher’s log-probabilities.
The paper’s pseudo-code (Figure 14) is short. The comments give the shapes.
pythondef compute_sdpo_loss(batch, teacher_context, loss_mask): logprobs_student = compute_log_prob(batch) # (T, V) keeps its gradient teacher_batch = reprompt(batch, teacher_context) # adds the feedback text logprobs_teacher = compute_log_prob(teacher_batch).detach() # (T, V) stop-gradient per_token_loss = divergence(logprobs_student, logprobs_teacher) # (T,) KL or JS over V return agg_loss(per_token_loss, loss_mask, loss_agg_mode="token-mean")
Each row of the (T, V) table is one position. divergence collapses the V columns to one number per row, giving T numbers, and the mask drops padding. That is the entire loss.
Chapter 4
Derive the update, see the advantage log(teacher / student), and count how many credit numbers each method hands out
A teacher marks an exam two ways. Way one: a single grade on the cover, “62 out of 100”. Way two: a tick or a cross beside every line, and a note on what the answer should have said. A student who gets way two knows what to fix. Chapter 1 showed that GRPO marks like way one. This chapter shows that SDPO, once you unpack its gradient, marks like way two, and that it still plugs into the same training code.
Take one position in the answer and drop the subscript t. The student gives each token ñ a probability π(ñ). The teacher gives q(ñ), treated as a fixed number. The loss at this position is the KL from Chapter 3:
L = ∑ñ π(ñ) · log( π(ñ) / q(ñ) )
Differentiate each term with the product rule. The derivative of π log(π/q) is (∇π) log(π/q) + π · (∇π / π), which is (∇π) log(π/q) + ∇π. Now sum over all tokens. The extra part adds up to ∇ of the sum of all π(ñ), and that sum is always 1. The gradient of the constant 1 is zero. The extra part vanishes.
What is left is ∇L = ∑ (∇π) log(π/q). One more identity helps: ∇π = π · ∇ log π. This lets us write the sum as an average over tokens drawn from the student:
Define A(ñ) = log( q(ñ) / π(ñ) ), the log-ratio flipped. Then ∇L = −E[ A · ∇ log π ]. Gradient descent on L is therefore the same as pushing each token’s log-probability up in proportion to A. That is exactly the shape of the GRPO update in Chapter 1. Only the advantage differs:
| GRPO | SDPO | |
|---|---|---|
| Advantage | ri − mean(r) | log( teacher / student ) |
| Changes along the answer? | No, constant for the whole rollout | Yes, different at every position |
| Applied to | the sampled token only | every candidate token (top K + tail) |
| Zero when | the whole group has the same reward | student and teacher agree exactly |
The sign carries the meaning. If the teacher likes a token more than the student does, A is positive and the token is pushed up. If the teacher likes it less, A is negative and the token is pushed down. Because A is a log-ratio, a token the teacher almost rules out gets a large negative number.
The student has just written “range(1, n” and must choose the next token. Four candidates, with toy odds: the closing bracket (student 0.25, teacher 0.90), “+” (0.60, 0.04), “−” (0.08, 0.03) and “,” (0.07, 0.03). Compute A = ln(q / π) for each.
Now see how much of this each style of credit assignment keeps. Pick a granularity.
The student sampled “+”. Each column is a candidate next token. Bars show the advantage that candidate receives under the style you pick.
The four candidates and their odds are toy values. The sequence-level scalar is the mean of the hero’s illustrative per-token advantages (about −0.51). The counts follow the paper: sequence level gives one number per answer, token level |y|, logit level |y| × (K + 1) with K = 100 (top K plus a tail term). 764 is the length of the SDPO answer in the paper’s Figure 7.
The paper ran exactly these three granularities on LiveCodeBench (its Figure 10, left). The order was logit level best, then token level, then sequence level. And even the sequence-level version beat GRPO. So there are two separate gains: using rich feedback at all, and spreading it densely. Chapter 7 gives the numbers.
Because the update has the GRPO shape, you do not write a new training loop. The paper says it takes minor changes to a standard RLVR pipeline: swap out the advantages. In GRPO the advantage is a tensor of shape (G,) expanded over tokens. In SDPO it is (T, K+1) per rollout.
The price: SDPO’s advantages are biased with respect to the true reward objective, since they come from a model’s opinion and not a measured outcome. GRPO’s are unbiased but noisy. The paper therefore tests a mix, A = λ AGRPO + (1 − λ) ASDPO, and finds it helps small models. Symptom: on a very small model SDPO underperforms. Measurement: the Qwen2.5-1.5B run. Fix: mix in some GRPO.
Chapter 5
Keep only the top tokens in memory, slow the teacher down, and pick a divergence that does not blow up
A recipe that works on a whiteboard still has to run on a real GPU, for days, without blowing up. A cook can describe a soufflé in one line. Making it rise takes oven control, timing and a steady hand. This chapter is the oven control of SDPO: three practical changes the paper makes so the idea fits in memory and stays stable.
The loss compares a student table and a teacher table, each of shape T × V. Take an answer of T = 8,192 tokens, the maximum response length in the paper’s runs, and a vocabulary of V = 150,000 (a typical size, used here only for illustration). One table in 32-bit numbers is 8,192 × 150,000 × 4 bytes, about 4.9 GB. Two tables are nearly 10 GB, and the student’s also needs gradients.
The fix is top-K distillation. At each position, keep only the student’s K most likely tokens, and the teacher’s odds for those same tokens. Fold everything else into one lump, the tail. The paper uses K = 100.
Now each table has K + 1 = 101 columns. The same answer needs 8,192 × 101 × 4 bytes, about 3.3 MB. That is roughly 1,500 times smaller. The paper reports that this avoids virtually any memory overhead and keeps most of the information, since most vocabulary entries carry almost no probability at a given moment.
In ordinary distillation the teacher is fixed. Here the teacher shares the student’s weights, so it moves every step. That helps, because the target can improve. It hurts too: a noisy student update makes a noisy teacher, which makes a noisier target, and training can diverge. The paper confirms it: the unregularised teacher eventually diverges (Table 4).
The remedy is a regularised teacher, one that is held near where it started. The paper gives two versions. The first is an exponential moving average (EMA): keep a second copy of the weights, θ′, and nudge it toward the student each step: θ′ ← (1 − α) θ′ + α θ. A small α means a slow teacher. The paper uses α = 0.01 for rich feedback and test-time runs and 0.05 for the no-feedback runs. The second is a trust-region teacher: its next-token odds are the geometric blend q ∝ exp( (1 − α) log qref + α log qθ ), where qref is the teacher at the initial weights.
The trade-off is practical. The EMA copy needs extra GPU memory but no extra compute. The trust-region version needs an extra log-probability pass with the reference weights but no extra copy. See the toy below: move the teacher’s update rate and watch the target.
The warm line is a noisy student weight over 90 training steps. The purple line is the teacher that follows it at rate α. Choose a rate.
Pure toy: one made-up weight, a rising trend plus seeded noise, and the EMA rule from the paper. It shows smoothness against lag only. The paper’s Table 4 reports, on LiveCodeBench v6, best accuracy up to step 90: unregularised 36.1 (and it eventually diverges), frozen at the initial teacher 48.8, EMA 49.3, trust-region 50.6 (α = 0.01).
Read the two ends. At α = 1 the teacher is the student and inherits every wiggle. At α = 0 it never moves and never improves. The paper’s numbers say the middle wins, though not by a large margin: even the frozen teacher does well (48.8), while the unregularised one does badly (36.1). The paper adds that the teacher does improve with the student, and the final student passes the initial teacher’s accuracy (Chapter 7).
The paper also uses the symmetric Jensen–Shannon divergence in the science and tool-use runs, because on-policy distillation from an external teacher has been reported to be steadier with it. For rich-feedback code runs and test-time training, its Table 12 lists reverse KL.
The only compute SDPO adds over GRPO is the teacher’s forward pass over the longer prompt. These passes can be run in parallel, and they are far quicker than generating tokens one by one. The paper’s Figure 5 shows SDPO’s time per step to be between 5.8% and 17.1% above GRPO’s, with a micro-batch size of 2. The paper warns it may weigh more for smaller models with shorter outputs, where generation time is small to begin with.
Other settings from Table 12, for the rich-feedback runs: AdamW, learning rate 1×10−6, 8 rollouts per question, sampling temperature 1.0, top-K 100, EMA rate 0.01.
Chapter 6
Use a sibling’s correct answer as the feedback, and read what that does to accuracy, speed and answer length
Back to the two students. The first got only “Wrong Answer”. Suppose a classmate sitting nearby solved the same problem. The first student can now compare her attempt with the classmate’s working one. She still has no error message, yet she has something to learn from.
This is the trick of the paper’s first experiment. Many RL environments give only a score. There is no runtime error to read. Can SDPO still help?
In GRPO training, each question already gets a group of G rollouts. If some pass and some fail, SDPO takes a passing rollout and places it in the teacher’s prompt as the “correct solution” (Chapter 2). The self-teacher then re-reads each failed attempt knowing what a correct attempt looks like. The paper calls the passing attempt implicit feedback. No expert model supplies it. It comes from the student’s own batch.
This leaves the old problem of groups where nobody passed. There, no sibling exists and SDPO has nothing extra to show the teacher. The method then matches the student, and the advantage is near zero, as with GRPO. Chapters 7 and 8 show how environment output rescues that case.
Tasks are tests the models were not specifically fine-tuned for. Science Q&A uses the reasoning subsets of SciKnowEval, in Chemistry, Physics, Biology and Materials science. Tool use uses ToolAlpaca: map a tool’s API specification and a user request to the correct call. Models are Qwen3-8B and Olmo3-7B-Instruct. Metric: avg@16, the average accuracy over 16 samples per question, plotted against wall-clock time.
The baseline is a strong, improved GRPO (asymmetric clipping, no biased normalisation, a correction for off-policy data), with its learning rate swept. The paper also reports on-policy GRPO, one gradient step per batch like SDPO. The default GRPO takes 4 off-policy mini-batch steps per batch. Each run used a node with four NVIDIA GH200 GPUs and took about 6 hours including setup.
Table 3 of the paper gives, for each cell, the best accuracy reached within 1 hour and within 5 hours. Explore it.
Pick a model, a task and a training budget. Bars show avg@16 accuracy.
Numbers are the paper’s Table 3 (hyperparameters picked per method for 5-hour accuracy, 3 seeds in the paper). The base model has one number and no training budget.
Over the ten cells at 5 hours, SDPO beats on-policy GRPO in all ten. Against the tuned off-policy GRPO, SDPO wins seven and loses three (Qwen3-8B on Biology, Olmo3-7B on Biology, Olmo3-7B on tool use). Try Biology at 5 hours to see a loss. The paper’s aggregate claim is 70.2% against 66.6%.
The big wins come from speed and from Chemistry. With Olmo3-7B on Chemistry, SDPO reaches GRPO’s 5-hour accuracy in 50 minutes, a 6 times speed-up, and its own 5-hour accuracy (80.0%) is more than 10 points higher than GRPO’s (56.7%). In several cells, SDPO after one hour matches GRPO after five.
A fairness note the paper makes itself: SDPO ran strictly on-policy, one step per batch. Off-policy methods that reuse each batch for several steps are known to be more efficient, so the authors expect extra gains from SDPO with off-policy updates, and leave that for future work.
The paper then found something it had not set out to find. SDPO answers are much shorter. Averaged over the tasks, GRPO answers run 820.8 tokens for Qwen3-8B and 1,095.4 for Olmo3-7B. SDPO answers run 255.8 and 343.9: a 3.2 times reduction on both (Table 8). On Olmo3 Chemistry the reduction reaches 11 times at higher accuracy.
Look at the paper’s Figure 7, one chemistry question (the logD of a molecule) after 50 training steps. GRPO wrote 5,549 tokens, with 25 “Wait”, 9 “No.” and 5 “Hmm”, and even the phrase “Wait I’m going in circles”. It repeated one calculation four times and picked the wrong option B. SDPO wrote 764 tokens, kept to the chemistry, and picked the right option C.
Why? Think about credit. GRPO gives the same advantage to every token of a rollout, so filler such as “Wait” rides along with the useful tokens that came before the pass. A long rambling answer that happens to succeed gets all its filler rewarded. SDPO's per-token advantages (the paper's Figure 21 shows them to be sparse) can single out the loops. The authors suggest that reasoning can be improved by refining how the model reasons, not only how long it reasons.
Symptom: answers grow longer and fuller of “Hmm” during RL. Measurement: response length against wall-clock time (the paper’s Figure 6 right). Fix: a per-token signal, which SDPO supplies, and which a single scalar cannot.
Chapter 7
Check SDPO on competitive programming, then take the method apart with the paper’s ablations
Coding is the natural home for rich feedback. Every contest site tells you which test failed and why. A model that trains on that text should learn faster than one that sees only pass or fail. This chapter checks that claim, and then takes SDPO apart piece by piece to see which parts carry the gain.
The benchmark is LiveCodeBench (LCB), contest-style coding problems from easy to competition level. The authors use the newest slice, LCB v6: 131 questions released between February and May 2025. They split the unit tests the way coding platforms do. Public tests (a random half of the private tests) give the training signal and the feedback. Private tests measure progress. The default model is Qwen3-8B, accuracy is averaged over 4 rollouts, and the GRPO baseline is the same improved version as before.
SDPO reaches 48.8% accuracy. GRPO reaches 41.2%. SDPO also reaches GRPO’s final accuracy with 4 times fewer generations (Figure 1). For scale, the paper lists the strongest instruct models on the public LCB v6 leaderboard: Claude Sonnet 4 at 40.5% and Claude Opus 4 at 39.7%. An 8B model trained with SDPO sits above both. Other RLVR variants land with GRPO (Table 9): a high-entropy-token variant 37.8%, GSPO 40.1%, CISPO 41.2%.
The gain is not spread evenly. Split the questions by difficulty and SDPO adds 2% (relative) on easy, 23% on medium and 63% on hard ones. Easy problems were mostly solved already. The extra signal helps most where credit is scarce.
Use the explorer below to see the main figures and the ablations. Switch between the four views.
Choose a view. Each bar is a number from the paper’s tables, on Qwen3-8B unless it says otherwise.
Numbers are copied from the paper. Accuracy and Table 9 are LCB v6 at step 80; the two Claude numbers come from the public leaderboard slice Feb to May 2025. Difficulty is the average accuracy until step 80. Table 4 is the best accuracy until step 90, with the teacher frozen at its start (“initial”), not regularised, trust-region or EMA. Table 5’s holdout average covers IFEval, ArenaHard-v2 (two parts) and MMLU-Pro.
The paper tried Qwen3 at 0.6B, 1.7B, 4B and 8B (Figure 8). SDPO beats GRPO clearly on the larger models and only slightly on the small ones. A second study on Qwen2.5-Instruct (Figure 17) shows SDPO winning at 7B, matching at the larger size and losing at 1.5B. The authors read this as an emergent ability: just as in-context learning grows with scale, so does the model’s skill at reading feedback and finding its own mistake. Symptom: SDPO lags on a small model. Fix tried: mix in GRPO, below.
Dense credit versus rich feedback. Sequence-level SDPO uses the feedback but gives one scalar. Token-level gives one number per sampled token. Logit-level gives all top-K candidates. The order was logit > token > sequence (Figure 10, left), and sequence-level SDPO still beat GRPO. So the feedback and its density each add something.
The teacher improves. Measure the teacher's own accuracy on the training batch as training goes on (Figure 10, right). It rises, and the final student passes the accuracy of the initial teacher. The model did not just copy a better version of itself. It bootstrapped from a weaker one. A regularised teacher helps (the Teacher type view): unregularised 36.1 against 48.8 to 50.6 for the others. A teacher frozen at its start still does well, which suggests that most of the gain comes from reading the feedback, not from teacher drift.
Which feedback? The sample solution and the environment output are complementary (Table 6, Chapter 2). Leaving the original attempt out of the teacher prompt keeps varied exploration.
GRPO plus SDPO. A blend with λ = 0.9 on the GRPO side helped the 0.6B model and slightly hurt the 8B model (Figure 11). The authors suggest a scalar reward signal can even hurt when the starting model is strong.
Training on code can erode other skills. Table 5 tests the final checkpoints on IFEval, ArenaHard-v2 and MMLU-Pro. All methods lose a little; SDPO loses least (holdout average 42.4 against GRPO’s 41.8 and a base of 43.5). The paper also tried the older route, supervised fine-tuning on the self-teacher’s successful answers. It reached 42.7 on LCB, lost more elsewhere (41.4), and needed twice as many generations because both student and teacher must generate. This matches earlier findings that off-policy imitation is less stable.
Chapter 8
Train on a single hard question, and watch weights absorb the lesson that a growing prompt cannot hold
You are stuck on one puzzle in a contest. You have 2,000 tries, no hints, and a judge that says only “no” until you are right. You could guess blindly. Or you could read the judge’s detailed error message after every try and slowly steer toward the answer. The first strategy needs luck. The second needs a way to keep what you learn.
This is the paper’s third experiment. The goal is no longer to train a general model. It is to solve one hard question as fast as possible, at the moment you are asked it.
The discovery time is the number of attempts needed until one earns reward 1. The measure of how good a method is: discovery@k, the chance that a solution has been found within k attempts.
For plain best-of-k sampling this is the familiar pass@k. Each try is independent from the same fixed model, so if one try passes with chance p, the chance that at least one of k passes is 1 − (1 − p)k. The new metric extends this to methods whose later attempts depend on earlier ones.
Why not RLVR here? A binary reward gives no signal until the first success, and a first success is exactly what is missing. The paper notes RLVR on a single question does no better than best-of-k. Curricula of solvable questions get around this in training, but a test-time user has only one question. SDPO sidesteps the issue by learning from the error text after every failed batch.
Play with a toy version. It uses one question and two strategies, so you can feel why learning between tries bends the curve.
Warm line: sampling a fixed model. Purple line: a model whose odds grow a little after every round of 16 attempts. Drag how much each round helps, and how many attempts you allow.
Toy, not the paper’s data. One question, a per-attempt success chance of 0.02% for the fixed model (chosen so best-of-k lands near the paper’s 41.5% at 2,750 attempts), and a learner whose chance multiplies by (1 + gain) after every 16 attempts. A real teacher’s gain is not constant; the paper measures discovery per question over 5 seeds. Multi-turn is left out of the toy; the paper’s numbers for it are in the text.
The authors pick questions where Qwen3-8B is at its ceiling. Hard tasks have pass@64 below 0.5 and very hard tasks below 0.03. They keep questions that at least one method solves within 512 steps over 5 seeds: 19 hard and 9 very hard. SDPO uses a batch of 16. Best-of-k uses the standard pass@k estimate from 2,944 independent rollouts.
On the very hard questions, by 2,750 attempts multi-turn has found a solution in 35.6% of cases and best-of-k in 41.5%. SDPO reaches 53.2%. To reach 22% discovery, SDPO needs about 3 times fewer generations than either. On the hard questions SDPO reaches 78%, and reaches 67% about 2.4 times faster. Multi-turn solves only 68.4% of questions overall and best-of-k 72.3%. One question, Q3, is solved only by SDPO, first after 321 attempts, which is 20 SDPO steps of 16.
Why does multi-turn level off? It runs out of room. The window fills after about 837 steps (± 466) on hard questions and 1,007 (± 349) on very hard ones. Weights have no such limit. The paper also found that keeping only past feedback beats keeping past attempts and feedback.
One more fact is worth pausing on. The initial self-teacher solves almost nothing: its accuracy is below 1% on nearly all questions and exactly 0% on 78% of them. A single round of in-context feedback is not enough. Yet the repeated small corrections add up. Symptom that would worry you: a teacher that never gets a question right. Measurement: Table 11. A plausible reason it still works: the signal says which tokens to move, so it does not require the teacher to solve the question outright. The paper reports the effect and does not isolate the cause.
Chapter 9
Keep the numbers, the terms, the checklist and the core code of the paper on one page
You can now rebuild the paper from memory. A model attempts a task. The environment returns a score and, often, text. The model re-reads its own attempt with that text in view. The gap between the two readings becomes a number for every token. A standard policy-gradient update uses those numbers. This chapter keeps the pieces you will want to look up later.
RLVR methods such as GRPO learn from one scalar reward per attempt, so every token of a rollout gets the same advantage, and learning stalls when a whole group gets the same reward. RLRF names the richer setting where the environment returns tokenised feedback. SDPO samples rollouts from the student, gets feedback, and re-scores each rollout with the same model conditioned on that feedback (the self-teacher). It minimises the KL from the student’s next-token odds to the stop-gradient teacher’s. That is a policy gradient whose advantage is log(teacher / student) at every candidate token. Top-K distillation fits it in memory, and an EMA or trust-region teacher keeps it stable. With only pass or fail, a passing sibling plays the feedback.
| What | Number | Where |
|---|---|---|
| LCB v6, Qwen3-8B | SDPO 48.8% vs GRPO 41.2%; 4× fewer generations | Figure 1, Section 4 |
| Same benchmark, instruct models | Claude Sonnet 4 40.5%, Claude Opus 4 39.7% | Section 4 |
| Science and tool use, aggregate | SDPO 70.2% vs GRPO 66.6% | Section 1 summary |
| Olmo3-7B Chemistry | 80.0% vs 56.7% at 5 h; GRPO’s 5 h score in 50 min (6×) | Table 3, Figure 6 |
| Answer length | 3.2× shorter on average; up to 11×; 764 vs 5,549 tokens in Figure 7 | Table 8, Figures 6 and 7 |
| By difficulty (relative gain) | easy +2%, medium +23%, hard +63% | Figure 15 |
| Teacher type (best acc.) | none 36.1, frozen 48.8, EMA 49.3, trust-region 50.6 | Table 4 |
| Holdout average | base 43.5, SFT 41.4, GRPO 41.8, SDPO 42.4 | Table 5 |
| Best teacher prompt | output + solution: 48.3%; adding the attempt: same output 30.0% | Table 6 |
| Extra compute vs GRPO | 5.8% to 17.1% per step | Figure 5 |
| Test time, very hard questions | discovery@2750: SDPO 53.2%, best-of-k 41.5%, multi-turn 35.6% | Section 5 |
| Test time, hard questions | SDPO 78%; 67% reached 2.4× faster | Section 5 |
| Initial self-teacher | below 1% on almost all questions, 0% on 78% | Table 11 |
| Settings | top-K 100, EMA rate 0.01 (0.05 without feedback), 8 rollouts, lr 1×10−6 | Table 12 |
| Term | Plain meaning |
|---|---|
| Policy πθ | The model, seen as a rule that gives next-token odds. |
| Rollout | One full sampled attempt at a question. |
| Advantage | How much better than usual a token or attempt was; the size and sign of a push. |
| Credit assignment | Deciding which tokens deserve the blame or the credit. |
| RLVR / RLRF | RL with a checkable reward / RL with tokenised feedback. |
| Self-teacher | The same weights, with the feedback added to the prompt. |
| Stop-gradient | Treat the teacher’s numbers as fixed targets. |
| Top-K plus tail | Keep K tokens per position and one lump for the rest. |
| discovery@k | Chance of a first solution within k attempts. |
This is a sketch of one SDPO step with the shapes in the comments. policy, env, reprompt and the helpers stand for your own stack; the paper builds on the verl library. It follows the paper’s Algorithm 1 and Appendix A.3.
pythondef sdpo_step(policy, teacher, x, env, G=8, K=100, alpha=0.01): ys = policy.generate(x, n=G) # G rollouts, each (T,) token ids rewards, feedback = env.score(x, ys) # (G,) and G strings (errors, judge text) loss = 0 for i, y in enumerate(ys): sib = a_passing_sibling(ys, rewards, skip=i) # None if the whole group failed t_prompt = reprompt(x, solution=sib, feedback=feedback[i]) # Table 2; the attempt itself is left out s_lp = policy.logprobs(x, y) # (T, V), keeps its gradient top = s_lp.topk(K, dim=-1).indices # (T, K): the student's top K per position with torch.no_grad(): # stop-gradient on the teacher t_lp = teacher.logprobs(t_prompt, y) # (T, V): same y, longer prompt s_k, t_k = s_lp.gather(-1, top), t_lp.gather(-1, top) # (T, K) each s_tail = log1mexp(s_k.logsumexp(-1)) # (T,) log of the odds left outside the top K t_tail = log1mexp(t_k.logsumexp(-1)) s = torch.cat([s_k, s_tail[:, None]], -1) # (T, K+1) t = torch.cat([t_k, t_tail[:, None]], -1) loss += (s.exp() * (s - t)).sum(-1).mean() # reverse KL per token, then token-mean (loss / G).backward(); opt.step(); opt.zero_grad() ema_update(teacher, policy, alpha) # teacher ← (1 - alpha) * teacher + alpha * policy
Compare it with GRPO: the generate and score lines are the same, and the loss line is replaced. Everything else, the optimiser, the batching and the logging, stays.
The authors name three. SDPO depends on the model’s in-context learning, so it suits stronger base models and can lose to GRPO on weaker ones. It depends on the quality of the feedback: uninformative or misleading text gives the teacher nothing to use. And it adds a small cost, the teacher’s log-probabilities, which can matter more for small models with short outputs.
We add what the evidence covers. The rich-feedback results come from one coding benchmark and models up to 8B. The paper lists long-horizon agent tasks, large multi-task runs, tasks with text feedback but no verifier, and the shorter-reasoning effect as open work. Treat the claims at larger scale as untested.
The lecture Model Evolution asks how models improve themselves over time. SDPO is one concrete answer: a model that turns its own failures into dense training signal. It sits between on-policy distillation (dense signal, but from an external teacher) and RLVR such as GRPO (no teacher, but sparse signal). Related work the authors cite includes process reward models, expert iteration and in-context self-refinement; SDPO differs by training the policy itself on the retrospective model’s odds.
The method, the experiments and the figures belong to Jonas Hübotter, Frederike Lübeck, Lejs Behric, Anton Baumann, Marco Bagatella, Daniel Marta, Ido Hakimi, Idan Shenfeld, Thomas Kleine Buening, Carlos Guestrin and Andreas Krause. Read the original: arXiv 2601.20802. Code: github.com/lasgroup/SDPO. Everything here is our re-telling; toy numbers are labelled as such.
Now press Present or Teach and explain the method from memory: why one number hides the blame, how the same weights become a teacher, what the loss compares, why the gradient is a policy gradient, and what keeps it stable. Then go back to the twelve tokens at the top, turn the feedback on, and say which tokens SDPO blames and why.