Minimalist R1-Zero RL on Qwen2.5-Math-7B with unbiased Dr. GRPO on MATH level 3-5 (Oat-Zero-7B)
harbor run -t ale/dr-grpo-qwen-math-7bharbor download ale/dr-grpo-qwen-math-7bReproduce the minimalist R1-Zero recipe: RL-tune the Qwen2.5-Math-7B base model with the unbiased Dr. GRPO algorithm on MATH level 3-5 questions, with no supervised fine-tuning. The trained model corresponds to Oat-Zero-7B, which reaches 43.3% on AIME 2024 with only ~27 hours on 8×A100.
This is a full-stack pipeline task. The primary goal is to stand up and run the complete R1-Zero loop — environment → assets → data → rollout ↔ train closed loop → evaluation — from the base model and produce a genuinely trained checkpoint. Hitting the exact target accuracy is secondary to demonstrating that the whole pipeline actually works.
The verifier assigns a continuous reward in [0, 1] based on how far through the pipeline you get and how well the trained model performs. Write nothing to /app/result.txt directly — the verifier inspects real training artifacts and evaluation output (see "Deliverables" below). Reward breakdown:
| Stage | What must be true | Reward |
|---|---|---|
| Environment + assets | RL framework importable; Qwen2.5-Math-7B + MATH training data downloaded |
0.15 |
| Data prepared | MATH level 3-5 converted to the RL trainer's format with the Qwen-Math template and Math-Verify reward wired | +0.10 |
| Rollout ↔ train closed loop | a real training run: checkpoint(s) + optimizer state written, training log shows ≥ 300 gradient steps with a non-trivial, increasing train reward | +0.35 |
| Evaluation ran | AIME 2024 + MATH500 evaluated with the specified protocol; scores produced | +0.10 |
| Accuracy | AIME 2024 pass@1 above the Qwen2.5-Math-7B base baseline, scaling up to the target |
+0.30 |
The heaviest weight is on the rollout ↔ train closed loop — a trained checkpoint with a climbing reward curve is worth more than a high number you cannot back up with artifacts.
Accuracy sub-score is linear on AIME 2024 pass@1:
< base → 0.0base → 43% → scales 0.0 → 0.30≥ 43% → 0.30 (full) — Oat-Zero-7B reaches ≈43.3% AIME 2024Qwen2.5-Math-7B (HuggingFace) — RL trains directly from this base with NO SFT.Dr. GRPO fixes two optimization biases in vanilla GRPO by removing two normalization terms. Vanilla GRPO is:
J_GRPO(θ) = E [ (1/G) Σ_i (1/|o_i|) Σ_t min( r_{i,t} Â_{i,t}, clip(r_{i,t}, 1−ε, 1+ε) Â_{i,t} ) ]
with Â_{i,t} = (R(q,o_i) − mean({R})) / std({R})
Dr. GRPO makes exactly two changes:
1/|o_i|: this term causes a length bias (shorter correct responses get larger gradients; longer incorrect responses get penalized less, inflating response length). Sum over tokens without dividing by |o_i| (equivalently, normalize by a constant generation budget, not the per-response length).Â_i = R(q,o_i) − mean({R(q,o_1),...,R(q,o_G)}) without dividing by std({R}). The std term causes a question-level difficulty bias (too-easy/too-hard questions with low reward variance get over-weighted).Everything else follows a standard PPO-style clipped objective. These two removals recover the unbiased PPO objective with a Monte-Carlo advantage baseline.
Verification-based, binary — implemented with Math-Verify (huggingface/Math-Verify):
R(q, o) = 1 if o contains the correct final answer to q, else 0
No format reward, no partial credit, no LLM judge.
The minimalist recipe uses the Qwen-Math template (not the R1 <think>/<answer> template — Qwen2.5-Math base models answer best with their native math template):
<|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
| Hyperparameter | Value |
|---|---|
| Algorithm | Dr. GRPO (no length norm, no std norm) |
| Base model | Qwen2.5-Math-7B |
| Max response length | 3,000 tokens |
| Sampling temperature | 1.0 |
| (top-p, top-k) | (1.0, −1) |
| Responses per question (G) | 8 |
| Optimizer | AdamW (β1=0.9, β2=0.95) |
| Weight decay | 0.0 |
| Gradient norm clipping | 1.0 |
| Learning rate | 1×10⁻⁶ (constant) |
| Inner proximal update epoch | 1 |
| KL loss coefficient | 0.0 |
| KL penalty coefficient | 0.0 |
| Policy clipping (ε) | 0.2 |
The paper runs on 8 × A100 GPUs, finishing in ~27 hours (≈1 day), using actor-learner collocation. Configure the rollout ↔ train loop across the available GPUs.
GPU Configuration: TODO — set to the available cluster (the paper used 8×A100).
Qwen2.5-Math-7B and the MATH training data.1/|o_i| length normalization and no std normalization in the advantage; KL coefficient 0; policy clip 0.2.\boxed{...} and score with Math-Verify.Qwen2.5-Math-7B base model under the identical protocol, so the improvement is measurable.Write all of the following so the graded verifier can confirm the pipeline ran:
/app/checkpoints/ — trained checkpoint(s) including model weights and optimizer state./app/logs/train.jsonl (or the framework's native log) — per-step metrics including step and train_reward (or equivalent), showing the reward trajectory./app/eval/results.json — evaluation output containing at least:
{"trained_aime2024_pass@1": <float 0-100>, "base_aime2024_pass@1": <float 0-100>, "math500_pass@1": <float 0-100>}
/app/result.txt — the trained AIME 2024 pass@1 as a single float (e.g. 43.3), consistent with results.json.Qwen2.5-Math-7B base is much lower → Oat-Zero-7B reaches ≈43.3%; five-benchmark average ≈51.4%.