Repository navigation
Update the Sudoku example to start from an SFT model with a progress reward - #8097
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
albertvillanova
left a comment
There was a problem hiding this comment.
Thanks, this reads well and the script stays aligned with the Wordle example. A few nits:
docs/source/openenv.md: no OpenEnv release raisesSessionLostErroryet. It's only on OpenEnvmain(openenv/OpenEnv@22ca1ab2), and v0.11.0 still reconnects silently. Could you say "the next OpenEnv release" or "OpenEnvmain" instead of "newer clients"?docs/source/openenv.md: the new "Long runs against a Space" section recommends a new client per episode, butgrpo_wordle.pydoesn't do this, and its run (~2h15) is longer than the ~2h drop interval. Should Wordle get the samereset()change in a follow-up PR?- The notebook says a game "reaches about 13k tokens", and the script comment says "games reach 16k tokens". Please use one number.
- The notebook config has
save_total_limit=1(like the Wordle notebook), but the script doesn't. Intended? - README §4:
puzzles_c55.jsonisn't linked, so readers can't find it. Please link it in the OpenEnv repo. - Notebook inference uses
max_new_tokens=384withenable_thinking=True(Wordle uses 512). If the thinking is cut off,play_sudokustops at the first missing tool call. Is 384 enough?
…t, puzzles link, 512 new tokens
|
Thanks! All addressed in 7d5a0d1: "the next OpenEnv release" for |
…hips in OpenEnv 0.12.0
albertvillanova
left a comment
There was a problem hiding this comment.
Thanks, all addressed. I checked the .sync() change: a plain client's close() doesn't stop its background loop thread (one thread leaked per episode with a new client per game), so .sync() is needed here, and in the Wordle follow-up too.
Optional nit: a one-line comment in reset() pointing to https://huggingface.co/docs/trl/openenv#long-runs-against-a-space would explain why the client is replaced each game.
Updates the Sudoku example to the pattern of the Wordle one (#7932): it starts from an SFT model (
openenv/Qwen3-1.7B-Sudoku-SFT) and trains with two reward terms, 1 for a solved puzzle plus the fraction of empty cells filled.examples/grpo_sudoku/grpo_sudoku.py: rewritten aroundenvironment_factoryand aplace(row, col, number)tool, about 200 lines.sudoku_prompt.txtis gone, since the prompt now fits in the script.examples/grpo_sudoku/grpo_sudoku.ipynb: rebuilt from the Wordle notebook.examples/grpo_sudoku/README.md: the example told as a story, like Rewrite the gpt-oss example: fine-tune on chess puzzles, then back to MXFP4 #8085: what the base model does, the SFT warmup (linking the OpenEnv tutorial for it), GRPO against the environment with the Space setup and the training curve, and the results with the GIF. Thegrpo_sudokurow in the examples index says the same in one line.docs/source/openenv.md: the rewards tip now says to make sure the games in a group differ, and a new "Long runs against a Space" section covers WebSocket drops in multi-hour runs.On the same 30 puzzles with 26 empty cells, the SFT model solves 10 and SFT + GRPO (75 steps) solves 22. The full pipeline is in the OpenEnv tutorial: https://huggingface.co/docs/openenv/tutorials/sudoku-grpo
Note
Low Risk
Changes are limited to example scripts, notebooks, and documentation; no TRL trainer or library behavior is modified.
Overview
The grpo_sudoku example is reworked to match the Wordle/OpenEnv pattern: training starts from
openenv/Qwen3-1.7B-Sudoku-SFTinstead of the base model, with two GRPO rewards (1.0 if solved + fraction of empty cells filled) replacing the previous five shaped reward terms and heavy in-env hint/board parsing.grpo_sudoku.pyand the notebook shrink to a slimSudokuEnv(TextArena via--env-url,reset()reconnects per game for Space WebSocket drops), a short inline prompt, and tunedGRPOConfig(thinking on, 16 generations, longmax_completion_length,token_truncateIS).sudoku_prompt.txtis removed.A new
README.mddocuments baseline → SFT → GRPO results (e.g. 10/30 → 22/30 puzzles at 26 empty cells).example_overview.mdandopenenv.mdare updated with richer Sudoku blurb, reward-group guidance, and a “Long runs against a Space” section.Reviewed by Cursor Bugbot for commit 9d3809a. Bugbot is set up for automated code reviews on this repo. Configure here.