Skip to content

Train a Sudoku agent: SFT, then GRPO - #1554

Open
sergiopaniego wants to merge 2 commits into
openenv:mainfrom
sergiopaniego:sudoku-example
Open

sergiopaniego wants to merge 2 commits into
openenv:mainfrom
sergiopaniego:sudoku-example

Conversation

@sergiopaniego

@sergiopaniego sergiopaniego commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a Sudoku tutorial that follows the Wordle one (#1479): Qwen3-1.7B, an SFT warmup on solver-played games, then GRPO against the TextArena Sudoku-v0 environment, with one place(row, col, number) tool call per cell.

  • examples/sudoku/: puzzles, SFT data, SFT, GRPO, evaluation, summary and GIF scripts, plus the 30 fixed evaluation puzzles at 26 and 16 empty cells.
  • docs/source/tutorials/sudoku-grpo.md: the whole pipeline with the numbers, hardware and cost of our run (about $42 in total on Hugging Face Jobs).

Results on the same 30 puzzles, greedy:

Model 26 empty cells: solved cells filled 16 empty cells: solved cells filled
Qwen3-1.7B 0/30 0.1% 0/30 1.9%
SFT 10/30 55.8% 19/30 79.1%
SFT + GRPO (75 steps) 22/30 83.2% 26/30 87.5%

Models, data and curves: SFT, SFT + GRPO, dataset, trackio.

The "Long runs against a Space" section explains the mid-game reconnects we hit during GRPO, which led to #1536.

The two images point to huggingface/documentation-images (openenv/sudoku-progress.gif and openenv/sudoku-grpo-curve.png).


Note

Low Risk
Changes are limited to documentation and standalone example scripts; no core OpenEnv runtime or training library code is modified in this diff.

Overview
Adds an end-to-end Train a Sudoku Agent path parallel to the Wordle tutorial: docs navigation and a long-form guide (sudoku-grpo.md), plus a new examples/sudoku/ package.

The example wires Qwen3-1.7B to TextArena Sudoku-v0 with one place(row, col, number) tool call per cell. Scripts cover puzzle generation, solver-driven SFT dataset export, SFT and GRPO (TRL GRPOTrainer + environment_factory against a duplicated HF Space), greedy evaluation on fixed puzzles_c55.json / puzzles_c65.json, summarization, and a side-by-side GIF helper. GRPO uses dual rewards (solved + cells-filled progress), memory-safe batching for ~16k-token games, and closes/reopens the Space client on every game to avoid mid-episode WebSocket drops corrupting training (documented alongside #1536).

Doc updates link the tutorial from the Training sidebar and the tutorials index table; the guide includes run costs, hardware, and operational notes (Space env vars, Trackio, Hub artifacts).

Reviewed by Cursor Bugbot for commit a54055a. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a2dd4ef. Configure here.

Comment thread examples/sudoku/evaluate.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant