Repository navigation
feat: grpo single gpu example - #80
Merged
Merged
Conversation
Provide a self-contained GRPO training script and validation docs so users can reproduce the RL-Kernel logp path on one GPU without distributed infrastructure. Signed-off-by: inaniloquentee <[email protected]> Co-authored-by: Cursor <[email protected]>
Drop plan.md because the user-facing documentation already lives in docs/usage/grpo-single-gpu-example.md. Signed-off-by: inaniloquentee <[email protected]> Co-authored-by: Cursor <[email protected]>
Collaborator
|
LGTM, Thank you for your contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #76.
This PR adds a minimal, reproducible single-GPU GRPO training example under
examples/. The repository previously had no runnable examples in that directory; this change introduces a self-contained script that demonstrates the RL-Kernel GRPO training path on one device without multi-GPU infrastructure.What users get
examples/grpo_single_gpu.py— end-to-end toy GRPO loop on a single GPU (or CPU for smoke tests)docs/usage/grpo-single-gpu-example.md— run instructions, validation notes, and test commandstests/test_grpo_single_gpu_example.py— subprocess smoke tests suitable for CIWhat this PR does not include
Motivation
Issue #76 requests expanding
examples/with a script that:This example is intentionally small so new users and CI can validate the workflow without standing up rollout services or large models.
Implementation overview
End-to-end pipeline
Key design choices
make_synthetic_rl_kernel_batch()samples_per_promptkernel_registryon CUDA,NativeLogpOpon CPU--require-fused-logploss.backward()while still validating fused output driftCLI highlights
python examples/grpo_single_gpu.py \ --device {auto,cuda,cpu} \ --steps 4 \ --num-prompts 2 \ --samples-per-prompt 4 \ --require-fused-logp # optional: enforce fused CUDA backendPer-step logs include:
loss,policy_loss,kl,train_logp_source,kernel_max_abs_error, and active token count.Issue alignment checklist
examples/grpo_single_gpu.py--device auto/--device cuda; validated on A100make_synthetic_rl_kernel_batch, no external dataHow to run
1. CPU smoke test (CI-friendly)
Expected: prints
completed grpo_single_gpuanddevice=cpu.2. Single-GPU strict fused path (A100 / CUDA)
Expected (with built
_Cextension):3. Example pytest
Test plan
pre-commit run --all-filespython -m mypy --ignore-missing-imports rl_engine/python -m pytest rl_engine/tests/test_dispatch.py -vpython -m pytest tests/test_grpo_single_gpu_example.py -vmkdocs build --strict -f mkdocs.yamlMAX_JOBS=2 python setup.py build_ext --inplacepython examples/grpo_single_gpu.py --device cuda --require-fused-logp ...on A100Validation results (local)
rl_engine/)rl_engine/tests/test_dispatch.py)FusedLogpGenericOp, 2 steps completedkernel_max_abs_error ≈ 2.38e-07Known limitations / reviewer notes
docs/usage/grpo-single-gpu-example.mdand logged astrain_logp_source=autograd_reference.--require-fused-logprequires a built CUDA extension (pip install -e .orpython setup.py build_ext --inplace). Without_C, CUDA may fall back toNativeLogpOpand strict mode will fail by design.sys.pathsopython examples/grpo_single_gpu.pyworks without priorpip install -e .(with# noqa: E402on the deferred import).