* chore: overhaul public configs/ and examples/
Restructure the public configs/ and examples/ trees for clarity.
- examples/: split into basic/ (core-env tutorials) and advanced/
(folder-per-model: qwen3-30b-a3b, glm-4.5-air, glm-5.2, minimax-m2.5,
nemotron-3-super, intellect-3.1), each with a README; drop multinode/
and the example screenshots.
- configs/: add basic/ (small 2-GPU dev mirrors of the core envs, one folder
+ README each, validated at 1 step); rename debug/algorithms -> debug/algo;
move debug/{rl,sft} -> debug/fake/{rl,sft}.toml; remove stale/internal
configs (gsm8k, nemotron_*, hendrycks_math, general_agent, elastic,
debug/v1, debug/{infer,orch,multimodal}.toml, debug/{hendrycks_sanity,moe,multi_env}).
- Remove the k8s/ Helm chart and its docs.
- Repoint README, docs/, nightly tests, and CI to the new paths; lowercase
prime-rl throughout docs and READMEs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore: drop per-model READMEs in examples/advanced
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(k8s): keep Helm chart, refresh reverse-text example configs
Keep the k8s/ Helm chart (undo its removal earlier in this branch) and bring
its reverse-text example back in sync with the current config layout.
The chart invoked examples/reverse_text/rl/{orch,infer,train}.toml — a split
config layout flattened into a single rl.toml months ago (#1859), so the
shipped example had pointed at non-existent files. Add current, validated
orch/infer/train configs under k8s/prime-rl/examples/reverse-text/ (split from
examples/basic/reverse_text/rl.toml), point the chart and docs at them, and
COPY k8s/ into the CUDA image so /app/k8s/... resolves at runtime.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(configs): hyphenate all directory names in configs/, examples/, k8s/
Normalize directory naming to hyphens, matching the model dirs and logical
ids (reverse-text-v1, prime-rl). Renames the env/task dirs that still used
underscores:
examples/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
configs/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
configs/ci/integration/reverse_text{,_lora,_moe,_multi_run,_rl_opd,_rl_sft,_sft,_sft_lora}
to the same names with hyphens, and updates every path reference (README,
docs, skills, nightly + integration test path args, the cpu_tests
config-import check). Python test files/modules and *.toml filenames keep
underscores.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(examples): eval CLI migration, SLURM cleanup, batch sizes, glm-5.2 layout
- Migrate every eval command in examples/basic READMEs from `vf-eval` to the v1
`eval` CLI (pydantic-config): `-b` -> `--client.base-url`, `--max-tokens`/`-t`
-> `--sampling.max-tokens`, `--env-args` -> `--args`, plus `-r 3` (v1 defaults
to 1 rollout; these READMEs report 20x3), `--harness.id null` (these envs train
with the null harness), and `--no-push`. Drop the now-dead vf-eval skip in
tests/unit/test_configs.py.
- Remove all SLURM overlays (slurm_rl.toml, slurm_sft.toml) from examples/basic.
Move the slim-wheel SFT+[slurm] parse fixture to configs/ci/slim_sft.toml and
repoint cpu_tests.yaml; drop the SLURM section from the hendrycks-sanity README
and the SLURM line from the start-run skill.
- Tune basic example batch/group sizes: alphabet-sort 256/16, wordle 512/16
(wiki-search already 512/16).
- Restructure examples/advanced/glm-5.2: inference configs ->
infer/{pd,pd-llmd}.toml, RL configs -> {swe,swe-llmd}.toml; repoint docs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* docs: fix outdated docs/skills/configs surfaced by v1 audit
Swept docs/, skills/, READMEs, and config TOMLs for outdated content (special
focus on v0->v1 drift). Verified every fix against current code.
docs/
- configuration.md: repoint 5 dead Basic example links to examples/basic/<hyphen>;
scope the "each dir has a README" claim to basic (advanced dirs are config-only).
- algorithms.md: opd reference-model field is `teacher` not `model`; renderer names
`glm-5`/`glm-4.5` (were invalid `glm5`/`glm4.5`); rewrite the per-env algorithm
example in the v1 taskset/harness form (was the v0 bare-`id` form).
- development.md: drop invalid `--data.type null` (SFT DataConfig has no such type).
- inference.md: fix "Dissagregation" typo + dead P/D anchor.
- overview.md: token-in route is `/inference/v1/generate`.
skills/
- monitor-run: correct the metric tables to the real
{scope}/{subset}/<metric>/<stat> scheme (num_total_tokens, has_error,
time/wait_for_policy, dispatcher/*); the old seq_len / errored_rollouts /
scheduler/* / generate_completions names never existed.
- install: drop the deep-gemm mention (no such section) from the description.
READMEs
- examples/README.md: basic runs on 1-8 GPUs (not 2); hyphenate env names.
- configs/README.md: drop stale "standalone entrypoint configs"; hyphenate.
- wiki-search: eval inference uses `--model.*` (not `--inference.model.*`) and drops
the auto-derived `enable_auto_tool_choice` flag; "native V1 tools" not "MCP".
- reverse-text: fix dead sft/train.toml path -> sft.toml.
- hyphenate configs/basic/* README headings.
configs/
- qwen3-30b-a3b/tool.toml: move `min_tier` into the taskset (was under a v0
`[...env.args]` block a v1 taskset never reads); group_size alias.
- glm-5.2/swe-llmd.toml: rollouts_per_example -> group_size.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(configs): use prime-qwen3 renderer for reverse-text (was default)
The reverse-text configs run PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT, whose
`-SFT` suffix misses MODEL_RENDERER_MAP's exact-match lookup and so fell back to
the DefaultRenderer. reverse-text is single-turn and always sends a system
prompt ([system, user, assistant]); the prime-qwen3 renderer is token-for-token
identical to the model's apply_chat_template for that shape (verified via
render_ids parity), and unlike the stock qwen3 renderer it does not inject an
empty <think></think> block. Switch the 7 standard + 3 distill reverse-text
configs to prime-qwen3.
Kept `default` where no hand-coded renderer fits (each errors on the model's
tokenizer): hendrycks-sanity (DeepSeek-R1-Distill-Qwen-1.5B), reverse-text-moe
(samsja/mini-glm-moe), intellect-3.1 (INTELLECT-3-Base).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(configs): use prime-qwen3 (not qwen3) for PrimeIntellect Qwen3 configs
The stock `qwen3` renderer injects an empty <think></think> block the
PrimeIntellect Qwen3 template never emits, so it mismatches these models'
apply_chat_template — single-turn for reverse-text, and every multi-turn shape
for wordle (verified via render_ids parity) — corrupting training tokenization.
- configs/basic/wordle/rl.toml: qwen3 + thinking_retention="all" -> prime-qwen3,
matching the tutorial examples/basic/wordle (which already uses prime-qwen3).
- configs/debug/algo/{echo,grpo,max_rl,self_distill,mixed_grpo_opd,opd,opd_lora}.toml
and configs/ci/integration/reverse-text-rl-opd/start.toml: qwen3 -> prime-qwen3
(all run PrimeIntellect/Qwen3-0.6B-Reverse-Text-{SFT,RL}).
prime-qwen3 handles the PI template's think retention natively, so the explicit
thinking_retention="all" is dropped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(k8s): use prime-qwen3 renderer in reverse-text orch config
The k8s reverse-text orchestrator config was split from the reverse-text example
before that example migrated to prime-qwen3, and the renderer migration was
scoped to configs/ and examples/ — so this one kept the stale `default`. Align
it with the source (PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT → prime-qwen3).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(k8s): drop redundant renderer comment in reverse-text orch config
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
8.0 KiB
Reverse Text
We demonstrate how to train Qwen3-0.6B to reverse a small chunk of text. We will use a SFT warmup to learn the skill of text reversal on longer documents and then a quick RL run on the reverse-text-v1 taskset. We use a similar setup in our CI and for development.
The commands in this example were designed to be run on 2 GPUs (one trainer and one inference GPU). It is possible to run on less or more GPUs using different deployment strategies. If you run on a different setup, you may need to adjust the start commands.
Setup
The reverse-text-v1 taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
uv run python -c "import reverse_text_v1"
First, let's start a tmux session which we will use throughout the experiment.
bash scripts/tmux.sh
Let's check how well Qwen3-0.6B does out-of-the-box on the reverse-text environment.
# Run this in the `Inference` pane
uv run inference --model.name Qwen/Qwen3-0.6B
# Run this in the `Trainer` pane
uv run eval reverse-text-v1 --harness.id null -m Qwen/Qwen3-0.6B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
This is of course just a quick vibe check and no full-fledged evaluation, but we can see that the model struggles with this task. In this specific instance, we got an average reward of ~0.05 across the 20x3 rollouts. Let's do some training!
SFT
We will fine-tune PrimeIntellect/Qwen3-0.6B (HF), which is a clone of Qwen/Qwen3-0.6B (HF) with a chat template suitable for multi-turn RL, on willcb/R1-reverse-wikipedia-paragraphs-v1-1000 (HF) which contains 1K examples of reversals of small paragraphs.
Check out the logs of the SFT run on W&B.
To train on a single GPU, run
# In the `Trainer` pane
uv run sft @ examples/basic/reverse-text/sft.toml \
--wandb.project ... \
--wandb.name ...
To train on multiple GPUs, run
# In the `Trainer` pane
uv run torchrun \
--local-ranks-filter 0 \
--nproc-per-node ... \
src/prime_rl/trainer/sft/train.py @ examples/basic/reverse-text/sft.toml \
--wandb.project ... \
--wandb.name ...
This should write a weight checkpoint in outputs/weights/step_100. Upload it to HF to be able to use it as the base model for RL.
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT outputs/weights/step_100
We have uploaded the final model as PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT.
RL
For the RL we will only do 20 steps at 8x16 rollouts, for a total batch size of 128 and sequence length 128. Because of the small context, training should be extremely quick.
Check out the logs of the RL run on W&B.
# Run this in the `Trainer` pane
uv run rl @ examples/basic/reverse-text/rl.toml \
--model.name ... \
--wandb.project ... \
--wandb.name ...
This will write a weight checkpoint in outputs/weights/step_20. As before, let's upload it to HF.
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-RL outputs/weights/step_20
We have uploaded the final model as PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL.
Evals
Let's see how our final RL checkpoints perform on the reverse-text environment.
# Run this in the `Inference` pane
uv run inference --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL
# Run this in the `Trainer` pane
uv run eval reverse-text-v1 --harness.id null -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
Way better! Now we get an average reward of ~0.8.
Kubernetes Deployment
If you're running on Kubernetes, you can deploy this example using the provided Helm chart. The Helm chart automatically configures all components with proper networking and shared storage.
Step 1: Deploy for SFT Training
The reverse-text example is configured with autoStart: true for RL training, but we need to run SFT first. Deploy with autoStart disabled:
cd k8s
helm install my-exp ./prime-rl -f ./prime-rl/examples/reverse-text.yaml \
--set orchestrator.autoStart=false \
--set inference.autoStart=false \
--set trainer.autoStart=false
# Check pods are ready
kubectl get pods -l app=prime-rl,example=reverse-text
# All pods should show 1/1 Running
Step 2: Run SFT Training
Exec into the trainer pod and run SFT:
kubectl exec -it my-exp-trainer-0 -- bash
uv run sft @ /app/examples/basic/reverse-text/sft.toml --output-dir /data/outputs
# This will save checkpoints to /data/outputs/weights/step_100
Upload the checkpoint to HuggingFace or use it directly from shared storage:
# Option 1: Upload to HuggingFace (from within the pod)
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT /data/outputs/weights/step_100
# Option 2: Use local checkpoint path in RL config
# Update the model.name in the RL configs to point to /data/outputs/weights/step_100
Step 3: Deploy RL Training
Now upgrade the deployment to enable autoStart (uses the default autoStart: true from reverse-text.yaml):
# Exit the pod first (Ctrl+D)
cd k8s
helm upgrade my-exp ./prime-rl -f ./prime-rl/examples/reverse-text.yaml
# Check pods have restarted
kubectl get pods -l app=prime-rl,example=reverse-text
The RL components will automatically start. Monitor the logs:
# View inference server logs
kubectl logs -f my-exp-inference-0
# View orchestrator logs
kubectl logs -f my-exp-orchestrator-0
# View trainer logs
kubectl logs -f my-exp-trainer-0
Alternative: Manual RL Training
If you prefer to run RL components manually, keep autoStart: false and exec into each pod:
# Terminal 1 - Inference
kubectl exec -it my-exp-inference-0 -- bash
uv run inference @ /app/k8s/prime-rl/examples/reverse-text/infer.toml
# Terminal 2 - Orchestrator
kubectl exec -it my-exp-orchestrator-0 -- bash
uv run orchestrator @ /app/k8s/prime-rl/examples/reverse-text/orch.toml --output-dir /data/outputs --client.base-url '["'$INFERENCE_URL'"]'
# Terminal 3 - Trainer
kubectl exec -it my-exp-trainer-0 -- bash
uv run trainer @ /app/k8s/prime-rl/examples/reverse-text/train.toml --output-dir /data/outputs
Access Outputs and Checkpoints
All outputs are written to /data/outputs on the shared NFS storage:
# Exec into any pod to access outputs
kubectl exec -it my-exp-trainer-0 -- bash
ls -lh /data/outputs/weights/
ls -lh /data/outputs/rollouts/
Step 4: Run Evaluation
To evaluate the trained RL model:
# Exec into trainer pod
kubectl exec -it my-exp-trainer-0 -- bash
# If inference server isn't running with the RL model, start it in another terminal:
kubectl exec -it my-exp-inference-0 -- bash
uv run inference --model.name /data/outputs/weights/step_20
# Back in trainer pod, run evaluation
uv run eval reverse-text-v1 --harness.id null \
-m /data/outputs/weights/step_20 \
--client.base-url $INFERENCE_URL \
-n 20 -r 3 --sampling.max-tokens 1024 --no-push
Clean Up
helm uninstall my-exp
# Optionally delete shared data:
kubectl delete pvc prime-rl-shared-data
What the Helm chart provides:
- Predictably named pods:
<release-name>-trainer-0,<release-name>-inference-0,<release-name>-orchestrator-0 - Shared NFS storage at
/datafor model checkpoints and outputs - GPU resources (1 GPU per inference/trainer pod)
- Kubernetes services for component communication
- Auto-start capability with proper networking configured
See the K8s deployment guide for more details on scaling, distributed training, and advanced configurations.