TL;DR
RL barely moved my own model: in PocketRL’s metric, the six-set avg@8, it went from 1.46% to 2.04%. So I ran my GSPO pipeline, with its own learning rate, KL penalty and clipping, on PocketRL’s base model, Qwen2.5-Math-1.5B, with their data, prompt and grader, on one H100. The pass bar, written before the run, was a MATH-500 avg@8 gain of at least 11.5 points by update 50; the run gained 19.65.
By update 100, MATH-500 avg@8 rose from 21.8% to 54.0% and the six-set mean from 9.7% to 23.2%. Both match PocketRL’s Dense arm at the same point, as read off their plots: the pipeline works, and my weak base was the problem.
What you’ll learn
- How a control experiment separates “my RL code is broken” from “my model is weak”, with a pass bar fixed before the data.
- How to check a converted checkpoint against Hugging Face, and how a copied
generation_config.jsonsilently made RL decode greedily. - How avg@8, pass@8 and a paired t-test read an RL gain, and how noisy an evaluation is when the same weights run twice.
- Why RL needs a base model that is sometimes right, in one formula: the chance that a group of answers carries any learning signal.
The puzzle: a small gain, and two suspects
In Part 9 I trained my own model with GSPO, a reinforcement-learning (RL) method for language models. It is a mixture of experts (each token uses a few of many expert sub-networks), with 6.86B parameters, 1.22B active per token. I pretrained it on 2.6B tokens of FineWeb-Edu and fine-tuned it on worked answers (SFT, supervised fine-tuning). RL then lifted its avg@8, averaged over six test sets, from 1.46% to 2.04%: real (p = 0.002), but small.
Then I read PocketRL, by Chung and Du [1]. Its RL update is close to mine: 128 answers per update, a constant learning rate of 1e-6, and gradient clipping. Its gains are not: on their six sets, their method took a 1.5B model from 10.0% to 32.9%. Only the metric is shared, though: my sets are word problems plus MATH, theirs are competition math.
Two suspects could explain the gap:
- The pipeline: my Megatron-LM patch for GSPO, my reward code, the sampling or the evaluation could lose the learning signal.
- The base model: mine read 2.6B tokens of web text and no math corpus. Qwen2.5 read about 18 trillion tokens, about 7,000 times more, and its Math models then trained further on math [2, 5].
Both predict the same small gain on my model, so rerunning my model cannot separate them.
How I score a model: avg@8 and pass@8
For each test problem, the model samples \(k = 8\) answers at temperature 1, and a grader marks each one right or wrong.
Here \(N\) is the number of test problems, \(c_i\) the number of right answers to problem \(i\), and \(a_i\) that problem’s share of right answers.
In words: avg@8 is how often the model is right on a typical try.
Here \(\mathbf{1}[\cdot]\) equals one when its condition holds and zero otherwise.
In words: pass@8 is the share of problems the model solves at least once in 8 tries.
I also report greedy accuracy, from one answer per problem that always takes the most likely token. Reach is the share of problems solved in any of 9 tries: the 8 samples plus the greedy answer. Because avg@8 uses every sample, it detects smaller changes: my model’s RL gain had p = 0.002 in avg@8, but 0.038 in pass@8. Part 13 compares these metrics in depth.
The idea: change one thing
The way out is a control experiment. Think of my RL pipeline as a coach and the base model as a student. My student did not improve, so I give my coach a student whose progress under another coach is on record. If that student keeps the recorded pace, the coach is fine; if it stalls, the coach is not.
PocketRL provides the record: the learning curve of Qwen2.5-Math-1.5B under full Adam with fp32 master weights, an arm it calls Dense. My pipeline uses the same optimizer, which keeps a 32-bit copy of the weights. So I kept my pipeline exactly as it was and gave it PocketRL’s model, training data, prompt and grader.
Against their Dense curve, what differs is my RL code, including its loss: GSPO with a small KL penalty, where they use Dr. GRPO [3]. A KL penalty keeps the model close to its start; Dr. GRPO is a variant of GRPO, the group-based method GSPO also builds on.
The pass bar, written before the run
A control needs its verdict fixed before the data, or any result can be read as a success. I wrote the rule on 30 November, before the run. The measure is the avg@8 gain on MATH-500, 500 competition problems, at update 50 over my own base reading. The yardstick is PocketRL’s Dense arm: ~22% to ~45% by update 50 in their Figure 4a.
Here \(\text{avg@8}_u\) is MATH-500 avg@8 after \(u\) RL updates, each one optimizer step on 128 answers, and \(u = 0\) is the base model.
In words: \(\Delta_{50}\) is how many points of avg@8 my pipeline adds in 50 updates.
Here \(\Delta^{\text{Dense}}_{50}\) is the Dense arm’s gain at update 50 in points, read off their plot, so it is approximate.
In words: my pipeline passes if it gets at least half of the published gain in the same number of updates.
A gain of 5.75 points or less, a quarter of Dense’s, would fail my pipeline; a gain in between meant running on to update 100. With the base at 21.8%, the bar became concrete: 33.3% or more at update 50 to pass.
How I built it
Everything ran on one H100. The table shows what stayed mine and what I matched to PocketRL.
| Setting | |
|---|---|
| Mine, unchanged | |
| Training code | Megatron-LM, NVIDIA’s training library [4], at commit d6316eb45, with my GSPO patch |
| Loss | GSPO, with a KL penalty of 0.01 to the starting model |
| Optimizer | full Adam with fp32 master weights; learning rate 1e-6, constant; gradient clipping at 1.0 |
| Checks | my metrics, reports and first-update ratio check |
| Matched to PocketRL | |
| Model | Qwen2.5-Math-1.5B [5] |
| Training data | 8,552 MATH problems of difficulty levels 3–5, from their pinned sources |
| Prompt and reward | their Qwen-Math prompt; Dr. GRPO’s \boxed{} grader, 1 if right and 0 if not |
| Batch | 16 problems × 8 answers per step, one update per step |
| Sampling | temperature 1, top-p 1, up to 3,000 new tokens |
Some settings still differ from their Dense run: my KL penalty, a 5-update warm-up, and a 3,584-token sequence cap instead of their 4,096-token context. The cap still gives 99% of the training prompts their full 3,000 answer tokens.
GSPO in two equations
GSPO [6] samples a group of \(G\) answers per problem and gives each answer an advantage: how much better it did than its group.
Here \(r_j\) is answer \(j\)’s reward, 1 if right and 0 if wrong. \(\bar r\) and \(\sigma_r\) are the group’s mean and standard deviation, and \(\epsilon\) avoids division by zero.
In words: answers that beat their group’s average are pushed up, and answers below it are pushed down.
If a group is all right or all wrong, every \(r_j\) equals \(\bar r\), so every advantage is 0; my patch also zeroes such groups explicitly. This matters later.
Here \(x\) is the prompt, and answer \(y_j\) has tokens \(y_{j,t}\), length \(|y_j|\), and \(y_{j,<t}\) before token \(t\). \(\pi_\theta\) is the model being trained and \(\pi_{\text{old}}\) the model that sampled the answer.
In words: \(s_j\) says how much more likely the current model finds the whole answer than the model that wrote it, per token.
GSPO maximizes the mean of \(\min\big(s_j A_j,\ \mathrm{clip}(s_j, 1-\varepsilon_{\text{low}}, 1+\varepsilon_{\text{high}})\,A_j\big)\), minus 0.01 times a KL estimate. With one update per step, the update scores the weights that sampled, so \(s_j = 1\) by construction and the clip only guards numerical noise. On one GPU this held exactly: at the first update the ratio alarm stayed silent, and the KL to the starting model read 0.0000. My main run on 8 GPUs, with the experts split across them, had failed this check (median \(\lvert \log s_j \rvert\) 0.0049).
Data, prompt and grader
My port of PocketRL’s data pipeline matched every pinned SHA-256 checksum. It gave their 8,552 training problems and six test sets with 1,547 problems in all. The prompt is their Qwen-Math template, verbatim:
<|im_start|>system
Please reason step by step, and put your final answer within \boxed{}.<|im_end|>
<|im_start|>user
{question}<|im_end|>
<|im_start|>assistant
The grader, from the Dr. GRPO paper in PocketRL’s version, is copied byte for byte; Part 8 covers graders. It reads only the last \boxed{}, then tries normalization, sympy equality and Math-Verify, each under a 1-second alarm. In training, an answer that has not ended within 3,000 tokens scores 0.
Converting the model, and checking the conversion
Megatron-LM at my pinned commit cannot load Qwen’s Hugging Face checkpoint, so I wrote a converter. One iteration of Megatron’s pretrain_gpt.py at Qwen’s shape saves a skeleton checkpoint; a PyTorch script then swaps in each mapped tensor. It replaced 198 tensors, and the strict check of every key and shape passed the first time.
My first check compared greedy answers with Hugging Face’s and failed: 11 of 20 agreed on their first 200 characters, against the 16 I required. But the splits came at near-ties, like “To solve the problem” against “To solve the given problem”, which a wrong mapping does not produce. So I replaced it with a better-calibrated check, its thresholds fixed before its data.
The new check compares log-probabilities, the logs of the probabilities each model gives each token. Megatron scores the tokens it sampled; Hugging Face scores the same tokens in the same context. It passes when the mean absolute difference, \(\frac{1}{T}\sum_{t=1}^{T} \lvert \log p^{\text{Meg}}_t - \log p^{\text{HF}}_t \rvert\), is at most 0.05 nats per token. Here \(T\) is the number of tokens, \(p^{\text{Meg}}_t\) and \(p^{\text{HF}}_t\) are the two models’ probabilities of token \(t\), and nats are natural-log units.
Over 63,278 tokens, the mean difference was 0.034 nats, and 0.92% of tokens differed by more than 0.5, inside the 1% limit. That is bf16 rounding (bf16 is the model’s 16-bit number format), so the conversion is right. The base model’s score confirms it: 21.8% avg@8 on MATH-500, where PocketRL reports 21.9%. A mistake anywhere in the conversion, tokenizer, prompt, grader or sampling would have shown here.
What happened
Update 50: the pass bar
At update 50, the run’s own evaluation put MATH-500 avg@8 at 41.42%, up from 21.77%. So \(\Delta_{50} = 41.42 - 21.77 = 19.65\) points, above the 11.5-point bar: by the rule, my pipeline works. Dense gained ~23 points by then, so mine reached about 85% of theirs.
Update 100: level with Dense
I let the run continue to update 100, as planned. MATH-500 avg@8 reached 53.95%, +32.17 points over the base. Dense reads ~53.5% there in their Figure 4a, a gain of ~31.5, so my pipeline was level with theirs.
| MATH-500 | base | update 50 | update 100 |
|---|---|---|---|
| avg@8, mine | 21.77% | 41.42% | 53.95% |
| avg@8, PocketRL Dense (read off their Fig. 4a) | ~22% | ~45% | ~53.5% |
| greedy | 33.6% | 65.4% | 68.8% |
| pass@8 | 69.6% | 83.2% | 84.0% |
| median greedy answer (tokens) | 1,030.5 | 517.5 | 534 |
Is the gain real? A paired test
Each problem is scored before and after RL, so I compare each problem with itself. That removes the large differences in difficulty between problems.
Here \(a_i^{(u)}\) is problem \(i\)’s avg@8 after \(u\) updates, from (1). \(s_d\) is the sample standard deviation of the \(d_i\) (dividing by \(N-1\)), \(N = 500\), and SE is the standard error of \(\bar d\).
In words: \(t\) counts how many standard errors the average per-problem change sits from zero.
From the base to update 100, \(\bar d = +32.17\) points with SE 1.41, so \(t = 22.9\). Resampling the problems (a bootstrap) gives a 95% interval of [+29.45, +35.00]. A sign-flip test, which flips the sign of each \(d_i\) at random, gives p = 0.00005, the smallest value its 20,000 flips can produce. The statistics primer explains all three.
PocketRL’s six test sets
PocketRL reports six sets, so I evaluated the base and the update-100 model on the other five too. Their six-set mean is the unweighted average of the sets’ avg@8.
| Set (problems) | PocketRL base | my base | my update 100 | gain, points (t) | PocketRL Dense, update 700 |
|---|---|---|---|---|---|
| MATH-500 (500) | 21.9% | 21.77% | 53.95% | +32.17 (22.9) | 64.5% |
| AIME 2024 (30) | 2.5% | 4.17% | 7.92% | +3.75 (1.7) | 13.2% |
| AIME 2025 (30) | 1.7% | 0.42% | 2.50% | +2.08 (1.5) | 5.7% |
| AMC 2023 (40) | 16.3% | 12.81% | 34.38% | +21.56 (5.1) | 44.5% |
| Minerva (272) | 5.4% | 5.88% | 16.36% | +10.48 (8.4) | 24.8% |
| OlympiadBench (675) | 12.6% | 12.98% | 24.19% | +11.20 (12.6) | 29.3% |
| Six-set mean | 10.0% | 9.67% | 23.21% | +13.54 (15.2) | 30.3% |
My base matches theirs set by set, within what 30 or 40 problems allow: one AIME problem moves avg@8 by 3.3 points. At update 100, Dense’s six-set mean is ~23% in their Figure 4b; mine is 23.21%, level again. The gains are significant on four sets, but not on the two AIME sets, where the base was near zero. Every set is still below Dense’s value at update 700, the end of their run.
On Minerva, the median greedy answer fell from 3,237.5 to 711 tokens: the base rambled into the length cap; after RL it answered and stopped. PocketRL’s own low-memory arms were ahead of Dense at update 100, at ~27–28%; I matched the arm that shares my optimizer.
Why the base matters
Equation (5) gives zero advantage to a group that is all right or all wrong. So how often is a group mixed?
Here \(p\) is the chance that one sampled answer is right and \(G\) is the group size, with independent samples. \((1-p)^G\) is the chance that all \(G\) are wrong, and \(p^G\) that all are right.
In words: a group carries a learning signal only if it holds at least one right and one wrong answer.
Illustrative values at \(G = 8\): \(p = 0.5\) gives 99.2%, \(p = 0.25\) gives 90.0%, and \(p = 0.01\) gives 7.7%. Bigger groups help rare successes: at \(p = 0.01\), \(G = 64\) gives 47.4%, as Fu also computes [7]. But no group size helps a problem with \(p = 0\).
Now the two base models, before RL:
- Qwen. On MATH-500 it was right at least once in 8 tries on 69.6% of problems, and all 8 times on just 2 of 500. So 69.2% of problems gave a mixed group: 69.6% minus the 0.4% always right. In training, 71% of groups were mixed in the first 10 updates.
- My model. After SFT, it got 0 of 16 right on 1,487 of 1,905 medium-difficulty training problems: 78%. There \(p = 0\) by estimate, and (8) gives 0 at every \(G\). On its easy problems, with groups of 8, just 1 group in 64 was mixed (1.6%), at a 0.2% solve rate.
Plugging solve rates into (8) shows one more effect. For my model, \(p = 0.002\) and \(G = 8\) give 1.6%, matching the measurement. For Qwen, its first-10-update solve rate, \(p = 0.241\), gives 89%, well above the measured 71%. The gap comes from averaging over \(N\) problems of different difficulty:
Here \(p_i\) is problem \(i\)’s own success rate and \(\bar p\) their mean. It holds because \(P_{\text{mixed}}\) is concave in \(p\), with second derivative \(-G(G-1)\big[(1-p)^{G-2} + p^{G-2}\big] < 0\) (Jensen’s inequality).
In words: problems that are always or never solved add nothing, so the average success rate overstates how many groups carry signal.
My main run fought exactly this: moving to medium problems and groups of 32 lifted the mixed share to about 40%. The gate’s one batch read 43.8%, two more draws from the same weights gave 31.3% and 12.5%, and GSPO-A’s first 13 steps averaged 38–39%. Even then, each 128-answer update held about 3 right answers. Liu et al. note that “The Qwen2.5-Math-1.5B base model already possesses strong math-solving capabilities” [3]. Kyars states the rule: “RLVR needs a capable starting policy in the sparse-reward regime” [8], where RLVR is RL from verifiable rewards.
What RL actually did: mostly sharpening
RL can widen reach, solving problems the model never solved before. Or it can sharpen, moving probability onto answers the model could already find. avg@8 rises in both cases, but reach rises only in the first.
| MATH-500 | base | update 50 | update 100 |
|---|---|---|---|
| avg@8 | 21.8% | 41.4% | 54.0% |
| greedy | 33.6% | 65.4% | 68.8% |
| pass@8 | 69.6% | 83.2% | 84.0% |
| reach: any of 9 tries | 73.4% | 85.6% | 85.8% |
| problems with all 8 samples right | 2 | 17 | 63 |
From the base to update 100, avg@8 rose 32 points but reach only 12. In problems, 80 were newly reached and 18 lost; between two evaluations of identical weights, 22 and 21 change this way. So the meaningful figure is the net: about +62 problems.
The two halves did different jobs:
- Updates 1–50: answer well, and briefly. Greedy accuracy nearly doubled, the median greedy answer halved, and all the added reach came here.
- Updates 51–100: sharpen. Greedy rose 3.4 points and avg@8 12.5, closing the gap between them from 24 points to 15. Reach did not move (24 problems newly reached, 23 lost), and problems right in all 8 samples went from 17 to 63.
Training improved throughout: the solve rate rose from 24.1% in updates 1–10 to 53.8% in updates 91–100.
How much of this is noise?
The same weights, evaluated twice
After the last update, Megatron ran its validation again on the same update-100 weights with new samples: a free measure of evaluation noise.
| MATH-500, update 100 | first | repeat | paired |
|---|---|---|---|
| avg@8 | 53.95% | 53.62% | −0.33 points (SE 0.86, t −0.4, p 0.72) |
| greedy | 68.8% | 67.0% | 9 wrong → right, 18 right → wrong |
| pass@8 | 84.0% | 83.6% | any of 9 tries: 22 newly reached, 21 lost |
| identical greedy texts | 198 of 500 |
The paired test finds nothing between identical weights, as it should. Yet only 198 of 500 greedy answers came out as the same text. Megatron batches requests dynamically, and each batch’s makeup changes the bf16 arithmetic enough to flip near-tie tokens. So greedy accuracy carries about ±2 points of run-to-run noise, while avg@8 averages it away.
Thinking Machines show the same effect at scale: 1,000 temperature-0 completions of one prompt gave 80 distinct texts [9]. This noise also fits the failure of my greedy-text conversion check. The rules: report avg@8, and check conversions by log-probabilities.
The saved weights are the model the run evaluated
The run evaluated its weights in memory, but what I keep is a saved checkpoint. On the dev split, 166 held-out training-style problems graded greedily, the two agree as closely as two evaluations of the same weights do.
| Dev split, 166 problems, greedy | accuracy | answers changed | identical texts |
|---|---|---|---|
| saved weights vs the run’s evaluation | 67.47% vs 66.87% | 9 | 75 |
| the run’s evaluation vs its repeat (same weights) | 66.87% vs 67.47% | 5 | 63 |
The copied weights also matched their originals by SHA-256 checksum.
What went wrong, and the fixes
Bug 1: a copied config file made Megatron decode greedily
The first rollouts, batches of sampled answers, looked healthy. But groups of 8 answers sampled at temperature 1 held only 1.44 distinct texts on average. GRPO and GSPO learn from differences inside a group, so this run would have starved every update while looking normal.
My first suspect was CUDA graphs (recorded GPU work, replayed to save launch time), the feature I had just switched on. A rerun without them showed the same 1.4375 distinct texts per group, which refuted it.
The cause was a file. Megatron fills any sampling setting a request leaves out from the model’s generation_config.json. Qwen2.5-Math’s file says do_sample: false, which Megatron turns into top_k = 1: greedy decoding, keeping only the most likely token. My tokenizer script had copied that file, and Megatron even logged the result:
Sampling defaults: generation_config={'temperature': None, 'top_p': None, 'top_k': None, 'do_sample': False} -> defaults={'top_k': 1}; first request resolved to temperature=1.0 top_p=1.0 top_k=1
The fix: make_qwen_tokenizer.py never copies the file, and a test checks it. Afterwards the log showed top_k=0, and the first batch had 8.0 distinct texts per group of 8. The lessons: count distinct answers per group before trusting any rollout, and test a hypothesis rather than blame the last change.
Bug 2: the grader hung training at update 16
The first GSPO run stalled after update 16, with the process alive and the GPU idle. My log watch stayed silent, because it only matched the lines it expected. The main thread sat at 99.9% of a CPU core, busy rather than waiting. The grader’s sympy path has no timeout, and Megatron runs the reward code on the thread that drives generation.
I added two guards, keeping PocketRL’s reward for every answer graded normally:
- Unfinished training answers are not graded. They score 0 anyway, and are the degenerate loops most likely to trip the grader.
- Each grading gets 10 seconds of CPU time. The timer re-fires every 0.5 s, since the grader’s bare
except:clauses swallow one interrupt.
The run restarted from the beginning, and in all 100 updates the limit never fired. The lessons: a watch must report silence, and untimed third-party reward code needs a time limit.
A gradient spike, caught and clipped
At update 36 the gradient norm jumped to 5.77, against 0.18 to 1.04 for updates 25 to 52. Megatron’s rerun check repeated the step and got the same value, so the batch caused it, not the GPU. Clipping at 1.0 scaled that update down about 6×, and the solve rate kept rising.
What this does not show
- One seed. PocketRL reports three seeds per arm; I ran one.
- Values read off a plot. Dense at updates 50 and 100 is my reading of their Figure 4, not a printed number.
- Settings that differ. The algorithm (GSPO against Dr. GRPO), my KL penalty, the warm-up or the sequence cap could explain the few points I trailed at update 50.
- A dense model on one GPU. The control never ran expert parallelism or the router, the parts only my MoE uses.
- 100 updates, not 700. Whether my pipeline keeps pace to Dense’s 30.3% is untested.
- Not the cure. It shows the base is the bottleneck, not that a better base would make my own model gain.
What it means
My RL pipeline is not the bottleneck: on a base whose RL curve is on record, it reproduced the curve. My own model’s small gain came from its base.
At this scale, RL amplifies what a model can already sometimes do. Before RL, Qwen was right at least once in 8 tries on 70% of MATH-500 problems. My model got 0 of 16 right on 78% of its medium-tier training problems.
The next lever is the base, not the RL code. The proposal: continue pretraining my checkpoint with math in the mix, about 10B tokens or ~14.5 hours on 8×H100. Part 15 collects what I would change.
Run it yourself
Hardware and time. One H100 SXM, a 100 GB volume and NVIDIA’s container nvcr.io/nvidia/pytorch:26.08-py3, on a host with CUDA 13 or newer. The measured times:
| Step | What it does | Time |
|---|---|---|
| C1 | setup and checks | ~5 min for pod_setup.sh, plus the code copy |
| C2 | PocketRL’s data | 4 s |
| C3 | model and tokenizer | 15 s + 5 s |
| C4 | the skeleton checkpoint | 46 s |
| C5 | the conversion | 23 s |
| C6 | the base model on MATH-500 | 586 s |
| C7 | the log-probability check | ~3 min (estimate) |
| C8 | GSPO, 100 updates, evaluated at 50 and 100 | 7,681 s (~70 s per update) |
| C9b | the five other sets, base and update 100 | 1,012 s + 923 s |
The whole run, with its two false starts, took about 4.1 hours from start to shutdown. The commands run from the repository root, with /workspace as the work folder.
Setup (C1). pod_setup.sh checks the GPU, installs Megatron-LM at the pinned commit with my patch and the grader’s packages, and checks every launch flag.
CONTROL_ONLY=1 EXPECT_GPUS=1 MIN_FREE_GB=80 WORKDIR=/workspace bash code/scripts/pod_setup.sh
source /workspace/env.sh # MODEL_FAMILY=qwen2p5_math_1p5b and the control's folders
export WANDB_MODE=offline
mkdir -p /workspace/runs /workspace/qwen
Data, model, skeleton and conversion (C2–C5):
python -I code/scripts/prepare_control_data.py "$CURRICULUM_DIR"
hf download Qwen/Qwen2.5-Math-1.5B --revision 4a83ca6e4526a4f2da3aa259ec36c259f66b2ab2 --local-dir "$QWEN_HF_DIR"
python -I code/scripts/make_qwen_tokenizer.py "$QWEN_HF_DIR" "$TOKENIZER_DIR"
RUN_DIR=/workspace/runs/qwen_skeleton bash code/scripts/megatron/qwen_skeleton.sh > /workspace/runs/qwen_skeleton.log 2>&1
PYTHONPATH="$MEGATRON_PATH" python code/scripts/megatron/convert_qwen2_hf.py /workspace/runs/qwen_skeleton/skeleton \
"$QWEN_HF_DIR" /workspace/qwen/megatron
The base model on MATH-500 (C6), then the sampling check:
RUN_DIR=/workspace/runs/control_base RUN_NAME=control_base EVAL_CKPT=/workspace/qwen/megatron \
EVAL_CONFIG=code/rl/control_eval500_env.yaml EVAL_PROMPTS=500 EVAL_COLLECT_PROMPTS=16 RL_SEQ=3584 RL_CUDA_GRAPHS=1 \
bash code/scripts/megatron/eval.sh > /workspace/runs/control_base.log 2>&1
grep "Sampling defaults" /workspace/runs/control_base.log # must show top_k=0, not top_k=1
The first batch in /workspace/runs/control_base/step_stats.jsonl must also show about 8 distinct_texts_per_group.
The conversion check (C7). GSPO starts only on a PASS.
python code/scripts/qwen_logprob_parity.py "$QWEN_HF_DIR" "$TOKENIZER_DIR" /workspace/runs/control_base/rollouts.jsonl \
/workspace/runs/control_base/rollout_logprobs.jsonl --n 64 --out /workspace/runs/control_base/logprob_parity.json
GSPO (C8). 12,800 samples make 100 updates of 128 answers.
EVAL_RESULTS=/workspace/runs/control_gspo/eval_results.jsonl \
RUN_DIR=/workspace/runs/control_gspo RUN_NAME=control_gspo SFT_CKPT=/workspace/qwen/megatron GSPO_LR=1e-6 \
PROMPTS_PER_STEP=16 GROUP_SIZE=8 UPDATES_PER_STEP=1 RL_PROMPTS_PER_EVAL=500 RL_SEQ=3584 RL_CUDA_GRAPHS=1 \
RL_ENV_CONFIG=code/rl/control_env.yaml GSPO_SAMPLES=12800 EXIT_MINS=420 \
bash code/scripts/megatron/gspo.sh > /workspace/runs/control_gspo.log 2>&1
The five other test sets (C9b), after GSPO has exited:
COMMON=(EVAL_CONFIG=code/rl/control_eval5_env.yaml EVAL_PROMPTS=675 EVAL_COLLECT_PROMPTS=16 RL_SEQ=3584 RL_CUDA_GRAPHS=1)
env RUN_DIR=/workspace/runs/control_base_sets RUN_NAME=control_base_sets EVAL_CKPT=/workspace/qwen/megatron \
"${COMMON[@]}" bash code/scripts/megatron/eval.sh > /workspace/runs/c9_base_sets.log 2>&1
env RUN_DIR=/workspace/runs/control_final_sets RUN_NAME=control_final_sets \
EVAL_CKPT=/workspace/runs/control_gspo/ckpt EVAL_CKPT_STEP=100 \
"${COMMON[@]}" bash code/scripts/megatron/eval.sh > /workspace/runs/c9_final_sets.log 2>&1
The analysis (C9). It needs neither a GPU nor PyTorch:
R=/workspace/runs
A=code/scripts/analyze_control.py
python3 $A eval $R/control_base/eval_results.jsonl $R/control_gspo/eval_results.jsonl --after-eval 1 # update 50
python3 $A eval $R/control_base/eval_results.jsonl $R/control_gspo/eval_results.jsonl --after-eval 2 # update 100
python3 $A eval $R/control_gspo/eval_results.jsonl $R/control_gspo/eval_results.jsonl \
--before-eval 2 --after-eval 3 # the same weights, twice
python3 $A eval $R/control_gspo/eval_results.jsonl $R/control_final_sets/eval_results.jsonl \
--before-eval 2 # the saved weights
python3 $A sets --before $R/control_base/eval_results.jsonl --before $R/control_base_sets/eval_results.jsonl \
--after $R/control_gspo/eval_results.jsonl@2 --after $R/control_final_sets/eval_results.jsonl
python3 $A train $R/control_gspo/step_stats.jsonl --block 10
Config files: code/rl/control_env.yaml (training and the in-run MATH-500 evaluation), code/rl/control_eval500_env.yaml (MATH-500 alone) and code/rl/control_eval5_env.yaml (the five other sets).
Results to expect (mine, from one seed):
- base: MATH-500 avg@8 21.77% (PocketRL: 21.9%), greedy 33.6%, pass@8 69.6%;
- update 50: avg@8 41.42%; update 100: avg@8 53.95%, six-set mean 23.21% from 9.67%;
- 8 distinct texts per group of 8, and no grader timeouts.
Code:
- conversion: code/scripts/megatron/convert_qwen2_hf.py, code/scripts/megatron/qwen_skeleton.sh, code/scripts/qwen_logprob_parity.py, code/scripts/make_qwen_tokenizer.py;
- data and reward: code/scripts/prepare_control_data.py, code/rl/boxed_grader.py, code/rl/rewards.py;
- training: code/rl/gspo.py, code/patches/megatron-d6316eb45.patch, code/scripts/megatron/gspo.sh, code/scripts/megatron/eval.sh, code/scripts/pod_setup.sh;
- analysis: code/scripts/analyze_control.py, code/rl/stats.py;
- tests: code/tests/test_score_boxed_guards.py, code/tests/test_make_qwen_tokenizer.py, code/tests/test_analyze_control.py.
The control-run guide has the same steps in more detail, and the converting-checkpoints guide covers the converter.
What to take away
- To tell “my code is broken” from “my model is weak”, keep the code and swap in a model with a published result. Fix the pass bar before the data.
- My GSPO pipeline matched PocketRL’s Dense arm on Qwen2.5-Math-1.5B: MATH-500 avg@8 went from 21.8% to 54.0% in 100 updates.
- RL learns only from mixed groups, with chance \(P_{\text{mixed}} = 1-(1-p)^G-p^G\), so a base that is never right gives it nothing at any group size.
- Here RL mostly sharpened: avg@8 rose 32 points and reach 12, with all the reach in the first 50 updates.
- Check what a healthy-looking run can hide: distinct answers per group, log-probabilities for conversions, and a repeat evaluation of the same weights.
References
- Stephen Chung and Wenyu Du. “PocketRL: Training a 7B Language Model with Reinforcement Learning on One RTX 5090.” arXiv:2611.37942, 2026. Code: github.com/dualverse-ai/pocketrl.
- Qwen Team. “Qwen2.5 Technical Report.” arXiv:2412.15115.
- Zichen Liu et al. “Understanding R1-Zero-Like Training: A Critical Perspective” (Dr. GRPO). COLM 2025. arXiv:2503.20783.
- NVIDIA. Megatron-LM. github.com/NVIDIA/Megatron-LM.
- An Yang et al. “Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvement.” arXiv:2409.12122, 2024. Model: Qwen/Qwen2.5-Math-1.5B.
- Chujie Zheng et al. “Group Sequence Policy Optimization.” arXiv:2507.18071, 2025.
- Zhoutong Fu. “Entropy in LLM RL: Dynamics and Control.” Blog post, 2026.
- Kian Kyars. Reinforcement Learning from Verifiable Rewards, Chapter 5, “Turning Checks into Training Signal.” rlvrbook.com, v1 of 2026-09-26, accessed 2026-12-03.
- Horace He and Thinking Machines Lab. “Defeating Nondeterminism in LLM Inference.” Thinking Machines blog, 2025.
Cite this
@misc{aboagye2026minidsv4part14,
author = {Aboagye, Prince Osei},
title = {Mini DeepSeek V4, Part 14: The control run: was it the model or the RL code?},
year = {2026},
howpublished = {\url{https://poaboagye.github.io/blog/14-control-run/}}
}