Evaluation
How to run the held-out evaluations with Megatron's inference engine inside a time limit, read greedy, pass@8 and avg@8, compare two models with paired tests, and measure the evaluation's own noise.
What you will do
- Run the held-out evaluations through Megatron’s RL inference engine in inference-only mode, within a time limit.
- Measure the hold-out perplexity after each stage, to track forgetting.
- Compare two checkpoints on the same problems with paired statistics.
- Measure the evaluation’s own noise by evaluating the same weights twice.
Hardware and time
Evaluate on the machine that trained the model: 8×H100 for the mixture of experts, one H100 for the control run’s 1.5B model. Our evaluations took 10–20 minutes each:
| Evaluation | Time |
|---|---|
| Before SFT: the subset pass, 1,430 problems, against a 600 s limit | 686.7 s |
| After SFT: the subset pass, then SVAMP and ASDiv whole | 1,147 s |
| Control run, MATH-500, base model | 586 s |
| Control run, five other sets: base / update 100 | 1,012 s / 923 s |
Three ways to read accuracy
- Greedy: one answer per problem, always the most likely next token.
- pass@8: the share of problems with at least one right answer among 8 samples at temperature 1.
- avg@8: the share of right answers among those 8 samples, averaged over problems.
Samples use temperature 1 with no top-k or top-p cut, as in training.
where \(N\) is the number of problems, \(k\) the samples per problem (8 here), and \(c_i\) how many of problem \(i\)’s samples are right.
In words: avg@8 is the accuracy of a typical sample, and pass@8 counts the problems the model can solve at all.
Which one to report. avg@8 averages 8 samples, so it carries far less noise than one greedy answer. Our control run evaluated the same weights twice: avg@8 moved by −0.33 points, while greedy moved from 68.8% to 67.0%, and only 198 of 500 greedy texts were identical. Greedy decoding is not repeatable here, because Megatron’s dynamic batching changes the bf16 arithmetic with each batch’s makeup, which flips near-tie tokens. So greedy accuracy carried about ±2 points of run-to-run noise.
Compare checkpoints problem by problem. A paired test cancels the problems’ own difficulty:
where \(a_i\) and \(b_i\) are problem \(i\)’s avg@8 after and before, \(s_d\) the standard deviation of the differences, and \(\mathrm{SE}\) the standard error of their mean.
In words: average each problem’s change, and divide by how much that average would wobble by chance.
Our control run on MATH-500, base to update 100: \(\bar{d} = +32.17\) points, \(\mathrm{SE} = 1.41\), \(t = 22.9\).
For greedy answers, which are right or wrong, McNemar’s exact test counts the problems that went wrong → right against right → wrong.
Free-score floors. A model that always gives the most common answer still scores on some sets. Report gains next to these floors: SVAMP 8.33%, MultiArith 7.78%, ASDiv 4.91%, GSM8K 3.03%, MATH 2.96%, MAWPS 0.96%.
Steps
1. The stage evaluations, within a time limit
code/scripts/eval_budget.py runs a fixed subset first: 200 problems per set by hash, and all 180 of MultiArith. Then it runs whole sets, smallest first, while the time limit lasts.
A set’s whole-set number is reported only if that set finished. The subset pass is never cut short.
python -I code/scripts/eval_budget.py --name eval_base --ckpt /workspace/ckpt/pretrain \
--config code/rl/curriculum_env.yaml --budget-min 10
python -I code/scripts/eval_budget.py --name eval_sft --ckpt /workspace/ckpt/sft \
--config code/rl/heldout_eval_env.yaml --budget-min 15
python -I code/scripts/eval_budget.py --name eval_gspo --ckpt /workspace/ckpt/gspo \
--config code/rl/heldout_eval_env.yaml --budget-min 15
Before SFT the config is curriculum_env.yaml: greedy everywhere, plus pass@1–8 on GSM8K’s first 50 problems. After
SFT and GSPO, heldout_eval_env.yaml adds the 8 samples on every set.
Expect the before-SFT pass to overrun its limit: the base model runs every answer to the 1,536-token stop.
2. One evaluation run
eval_budget.py calls code/scripts/megatron/eval.sh, which you can also run
yourself. It needs EVAL_CKPT, EVAL_CONFIG and EVAL_PROMPTS: 200 is the subset, and 5000 means every set in
full.
EVAL_CKPT_STEP picks a saved step other than the latest.
This is the per-epoch format check from the SFT guide:
for e in 35 70 104; do
EVAL_CKPT=/workspace/ckpt/sft EVAL_CKPT_STEP=$e EVAL_CONFIG=code/rl/dev_eval_env.yaml EVAL_PROMPTS=100 \
run sft_epoch_$e bash $M/eval.sh
done
And this is the control run’s base reading on all of MATH-500, outside the run helper:
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
Each run writes eval_results.jsonl, one record per problem with the greedy answer’s text. It also writes the
rollouts and step summary of one curriculum batch, which inference-only mode collects before it evaluates.
The means also go to the log, TensorBoard and W&B, under eval_only/.
3. The hold-out perplexity
One validation pass over the pretraining hold-out, about the whole 26M tokens once. No weights change.
LM_EVAL_CKPT=/workspace/ckpt/sft run lm_sft bash $M/lm_eval.sh
Ours: 20.97 before SFT, 22.74 after SFT, and 22.76 after GSPO. SFT caused the 8.4% rise; RL added none.
4. Compare two evaluations
code/scripts/analyze_control.py needs no torch, so it runs on a laptop
too. These are the control run’s commands, where <runs> is your runs folder:
python3 code/scripts/analyze_control.py eval <runs>/control_base/eval_results.jsonl \
<runs>/control_gspo/eval_results.jsonl --after-eval 1 # update 50; --after-eval 2 for update 100
python3 code/scripts/analyze_control.py train <runs>/control_gspo/step_stats.jsonl
In-run evaluations append to one file, and their rows carry no update number, so the script splits the file where a problem repeats. It prints, per test set, the paired avg@8 (standard error, t, sign-flip p and a bootstrap interval), greedy with McNemar’s test, and the median answer length; then the training trend.
5. Measure the noise floor
Evaluate the same weights twice and compare, exactly as you would compare two models. Our control run got this for free: Megatron validates once more after its last update, which wrote a third block to the same file.
python3 code/scripts/analyze_control.py eval <runs>/control_gspo/eval_results.jsonl \
<runs>/control_gspo/eval_results.jsonl --before-eval 2 --after-eval 3
| MATH-500 | First | Repeat | Paired |
|---|---|---|---|
| avg@8 | 53.95% | 53.62% | −0.33 points (SE 0.86, p 0.72) |
| greedy | 68.80% | 67.00% | 9 wrong → right, 18 right → wrong (McNemar p 0.12) |
| pass@8 | 84.0% | 83.6% | 22 newly reached, 21 no longer |
The paired test finds nothing between identical weights, as it should. A gain smaller than this floor is not a gain.
What to expect
Our base model, before SFT: 0.000 on every set, and no answer format. Its median answer ran 1,474–1,528 tokens, to the sequence stop. The answers are on-topic English that falls into repetition loops. After SFT and after GSPO, see the tables in the SFT guide and the RL guide.
The control run, MATH-500:
| Base | Update 50 | Update 100 | |
|---|---|---|---|
| avg@8 | 21.77% | 41.42% | 53.95% |
| greedy | 33.60% | 65.40% | 68.80% |
| pass@8 | 69.6% | 83.2% | 84.0% |
Check that it worked
-
The log shows the checkpoint loading, and no “will start from random”. Every evaluation launch has
--exit-on-missing-checkpoint, so a wrong path stops the run. -
eval_results.jsonlhas one row per problem, with the answer text. Read ten answers yourself. -
If the model’s folder came from Hugging Face,
grep "Sampling defaults"in the log showstop_k=0, nottop_k=1. -
Format compliance clears its stage’s threshold: above 50% at the RL gate, 80% after SFT, 90% during RL.
-
Every gain is read against the free-score floor and the noise floor.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
| pass@k would read near 0 although answers are right (found in Megatron’s code, before any run) | Megatron counts a pass only at reward exactly 1.0; a right, well-formatted answer of ours scores 1.1 | our evaluation agents judge correctness, not the reward |
| an evaluation reports loss 11.85 and exits 0 | the checkpoint path was wrong, so Megatron started from random weights | --exit-on-missing-checkpoint on every load |
float(None) in the learning-rate scheduler |
Megatron builds the scheduler even with --skip-train |
--lr 0 in eval.sh |
add_scalar('max_attention_logit', None) after the curriculum batch |
inference-only mode has no training forward | the flag is left out of eval.sh |
| every “sample” of a group is the same text | the model folder’s generation_config.json turned sampling into greedy decoding |
leave that file out of the folder Megatron loads |
| greedy accuracy moves by about 2 points between identical evaluations | batch-dependent bf16 arithmetic flips near-ties | report avg@8; compare by paired tests |
OSError: [Errno 9] Bad file descriptor at the end |
the text server closes a socket twice at shutdown | harmless: the exit code is 0 |
| a 4-bit checkpoint hangs | ModelOpt’s attention cannot run in the dynamic engine | eval.sh refuses EVAL_MODELOPT=1; see 4-bit |
Read more
- Part 13: evaluation explains greedy, pass@k and avg@k, noise floors and paired tests.
- Code: code/scripts/megatron/eval.sh, code/scripts/eval_budget.py, code/scripts/megatron/lm_eval.sh, code/scripts/analyze_control.py, code/rl/stats.py, code/rl/boxed_grader.py.