Files
prime-rl/examples/basic/reverse-text/README.md
T
faresobeidandGitHub f42630873d chore: remove Kubernetes deployment path (Helm chart, trainer metrics server) (#3767)
Removes the Kubernetes deployment path. The Helm chart has had no
functional change since its initial additions (last own change
2026-08-12 was a docs fix), and supported multi-node deployment is SLURM
(see docs/scaling.md). The trainer `metrics_server` (Prometheus
`/metrics` + `/health`) only existed to serve the chart's
liveness/readiness probes.

## Removed
- `k8s/` Helm chart (and `COPY k8s` from `Dockerfile.cuda`)
- `src/prime_rl/utils/metrics_server.py` (`MetricsServer`,
`HealthServer`) and its unit test
- `MetricsServerConfig` (configs/shared.py), trainer `metrics_server`
field, and its setup/update/teardown in `trainer/rl/train.py`
- Kubernetes sections/mentions in README,
`examples/basic/reverse-text/README.md`, `docs/training.md`; `k8s/`
TOMLs dropped from `test_configs.py`
- Inference `liveness_timeout_seconds` docstring reworded neutrally; the
`/liveness` endpoint stays (used by SLURM/router health checks)

`prometheus-client` stays in `pyproject.toml`:
`orchestrator/inference_metrics.py` still uses its parser.

## Breaking changes
- Trainer configs that set `metrics_server` now fail validation.
- The Helm chart and `/app/k8s` in the image are gone.

## Validation
- `pytest tests/unit/test_configs.py -m "not gpu"` (205 passed)
- `ruff check .` and `ruff format --check .`
- No GPU on the machine used; GPU/integration tests not run.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Breaking for anyone using the Helm chart or trainer `metrics_server`
config; training/runtime core paths are unchanged but deployment and
observability options shrink.
> 
> **Overview**
> **Removes the Kubernetes/Helm deployment path** and related trainer
observability that existed mainly for chart probes.
> 
> The entire `k8s/` Helm chart (StatefulSets, services, PVC,
reverse-text example values/TOMLs, and `k8s/README.md`) is deleted.
**`Dockerfile.cuda`** no longer copies `k8s/` into the image, and
docs/README/example copy now describe **Slurm-only** multi-node
deployment (K8s sections dropped from `reverse-text` README).
> 
> **Trainer Prometheus/health HTTP server is removed:**
`MetricsServerConfig`, the `metrics_server` trainer config field,
`src/prime_rl/utils/metrics_server.py`, RL trainer
startup/update/shutdown hooks, and unit tests. Configs that still set
`metrics_server` will fail validation.
> 
> **Minor doc tweaks:** inference `liveness_timeout_seconds` help text
is generic (not K8s-specific); `env-server` docs refer to externally
managed hosts instead of pods. Config validation tests only scan
`configs/` and `examples/` TOMLs, not `k8s/`.
> 
> Inference `/liveness` and `prometheus-client` elsewhere (e.g.
orchestrator) are unchanged.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
42e89b437dc19ae11abd0172672b89b9f03e6c30. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-10-04 23:49:24 +01:00

3.8 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 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 taskset is included through the Verifiers workspace. After syncing the repository, verify it with:

uv run python -c "import reverse_text"

We'll use two terminals: one for the inference server, one for everything else. To watch the run while it trains — metrics, resolved configs, rollout traces, and logs in one place — start the local dashboard and open http://localhost:7788:

uv run dashboard

Let's check how well Qwen3-0.6B does out-of-the-box on the reverse-text environment.

# Run this in the inference terminal
uv run inference --vllm.model Qwen/Qwen3-0.6B
# Run this in the other terminal
uv run eval @ examples/basic/reverse-text/eval.toml

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

# Run this in the other terminal
uv run sft @ examples/basic/reverse-text/sft.toml \
  --run.name sft \
  --monitors.wandb.project ... \
  --monitors.wandb.name ...

To train on multiple GPUs, run

# Run this in the other terminal
uv run torchrun \
  --local-ranks-filter 0 \
  --nproc-per-node ... \
  src/prime_rl/trainer/sft/train.py @ examples/basic/reverse-text/sft.toml \
  --monitors.wandb.project ... \
  --monitors.wandb.name ...

This should write a DCP checkpoint in outputs/sft/checkpoints/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 other terminal
uv run rl @ examples/basic/reverse-text/rl.toml \
  --model.name ... \
  --run.name rl \
  --monitors.wandb.project ... \
  --monitors.wandb.name ...

This will write a DCP checkpoint in outputs/rl/checkpoints/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 terminal
uv run inference --vllm.model PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL
# Run this in the other terminal
uv run eval @ examples/basic/reverse-text/eval.toml -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL

Way better! Now we get an average reward of ~0.8.