feat(tutorial): add a CPU-first RL walkthrough - #7
Conversation
Signed-off-by: Yann Ge <geyanqiqi@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a CPU-only, single-process RL tutorial path under examples/tutorial/ to make Molt’s reward-to-update flow easier to understand and debug locally without Ray/vLLM/FSDP/CUDA.
Changes:
- Added an end-to-end CPU RL walkthrough script that reuses Molt’s real dataset/rollout/experience/loss code while stubbing Ray + vLLM boundaries.
- Added English and Chinese tutorial documentation describing scope, source correspondence, and a suggested debugging/breakpoint order.
- Added a pinned CPU-only requirements file for running the tutorial in an isolated environment.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| examples/tutorial/WALKTHROUGH.md | English detailed walkthrough of the CPU learning path, scope, and execution chain. |
| examples/tutorial/WALKTHROUGH_CN.md | Chinese version of the detailed walkthrough. |
| examples/tutorial/requirements-cpu.txt | Pinned CPU-only dependency set for the tutorial environment. |
| examples/tutorial/README.md | English design/scope overview for the CPU-first tutorial directory. |
| examples/tutorial/README_CN.md | Chinese design/scope overview. |
| examples/tutorial/cpu_rl_walkthrough.py | Linear CPU-only executable walkthrough that stubs Ray/vLLM and runs real Molt RL components end-to-end. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/claude review |
|
LGTM Light review of the new examples/tutorial/ CPU RL walkthrough (6 new files, no production-code changes). Verified the Python entry point against current Molt source:
The script carries its own end-to-end assertions (rewards, shape alignment, KL-stub guards, before/after log-prob margin), so coverage for the changed code is inherent. No critical bugs, typos, or inaccurate docs found. |
Motivation
Molt is already designed as a lightweight, hackable RL framework that makes
experimentation and modification easier than larger training stacks. However,
its production RL path still necessarily combines the learning algorithm with
Ray, vLLM, FSDP, CUDA, and distributed model execution, so inspecting or
changing the core reward-to-update logic still requires access to a GPU
environment.
This PR takes Molt's lightweight philosophy one step further by adding a
single-process CPU learning path. It lets contributors understand, debug, and
validate lightweight algorithm or data-flow changes locally, then transfer the
same changes to the GPU/distributed production path with a smaller and clearer
validation gap.
What this adds
backward, and optimizer update.
Embedding -> Linearpolicy and local generation transport.Scope
The tutorial directly reuses Molt's dataset, agent, environment, trajectory,
experience, advantage, replay-buffer, and loss implementations.
Only Ray scheduling, vLLM serving, AutoModel/FSDP/CUDA execution, and
distributed weight synchronization are replaced.
This is a learning and debugging harness, not a production CPU backend.
Validation
Follow-up
A companion skill is planned to help users and coding agents prototype against
this CPU path and transfer changes to the GPU/distributed implementation.