The task
The puzzles are generated in the environment, so there is no dataset licence to
consider, and every puzzle is solvable by construction: 3 or 4 numbers, a whole-number
target from 1 to 999. Training and evaluation use different seeds.
Reward: 1 when the expression in <answer>...</answer> uses exactly the given
numbers and equals the target, else 0.
Can the base model do it?
No. It skips the working and guesses an expression, often with a wrong value written
next to it:
Numbers: 2, 8, 20, 31 · Target: 252
Before: <answer>(20 + 31) * 2 - 8</answer> (that is 94)
Run it
CUDA_VISIBLE_DEVICES=0 surogate grpo-colocate \ --train examples/kits/aha/train.yaml \ --infer examples/kits/aha/infer.yaml \ --orch examples/kits/aha/orch.yaml
16 puzzles × 8 rollouts a step, answers up to 1,536 tokens, thinking off, LoRA rank 16.
67 minutes for 80 steps on one L40S.
Measure again
Table with columns: Solved, 200 held-out puzzles | Solved, 200 held-out puzzles |
|---|
| Base Qwen3.5-0.8B | 1.0% |
| After 20 steps | 61.5% |
| After 40 steps | 54.0% |
| After 60 steps | 62.0% |
| After 80 steps | 69.5% |
Greedy decoding, the same prompt and budget as training, one run. The dip at step 40
is real; it recovered.
Checked outside the engine with plain transformers + peft on the first 24 held-out
puzzles: 0% before, 66.7% after.
What changed
The trained model works the puzzle in plain text before it answers:
Numbers: 2, 8, 20, 31 · Target: 252
After:
- (31 - 2) = 29- 29 * 8 = 232- 232 + 20 = 252Expression: (31 - 2) * 8 + 20<answer>(31 - 2) * 8 + 20</answer>
The token budget matters
A first run cut answers at 1,024 tokens. It reached 61% and then fell to 48.5%: long
attempts were cut off before the answer, scored 0, and the model learned that working
things out does not pay. At 1,536 tokens it kept improving to the end.
Use the adapter
from transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModel tok = AutoTokenizer.from_pretrained("Qwen/Qwen3.5-0.8B")base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B", torch_dtype="bfloat16")model = PeftModel.from_pretrained(base, "cetusian/qwen3.5-0.8b-countdown-grpo")stop = [tok.convert_tokens_to_ids(t) for t in ("<|im_end|>", "<|endoftext|>")]# model.generate(..., eos_token_id=stop)
Use the system prompt from environments/countdown
and enable_thinking=False. This adapter ends its turn with <|endoftext|>, so stop on
both tokens as above; the Surogate server does that already.
Limits
- Countdown only. It is a clean test of whether RL can teach a small model to reason,
not a general maths model.
- About 30% of puzzles are still wrong, mostly the four-number ones (in the 24-puzzle
check: 11 of 12 three-number puzzles solved, 5 of 12 four-number ones).
- One run, one seed.
Trained with the Surogate Engine (Apache-2.0), surogate grpo-colocate on one GPU. Configs and environment: examples/kits/aha.