Cheat sheets

RL Post-Training with Miles

Run GRPO on one GPU, watch the run, stop a dead engine and fix the common failures.

  • Concepts and terms
  • Tasks and commands
  • Annotated code
  • Diagrams
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Run layout on one GPU#

runrolloutsampleslinesstoppausestartclientHostdocker runprocessContainerradixark/milesgpuRollout engineSGLang, mem 0.4gpuTrainerFSDP on one GPUprocessHeat guardpause at 84 CqueueWatchdog10 checksprocessLauncherexecute_trainstoreRun logstep linesrunrolloutsampleslinesstoppausestartclientHostdocker runprocessContainerradixark/milesgpuRollout engineSGLang, mem 0.4gpuTrainerFSDP on one GPUprocessHeat guardpause at 84 CqueueWatchdog10 checksprocessLauncherexecute_trainstoreRun logstep lines

One GRPO step#

1Rolloutthe engine writes 8 answers for each of 32prompts.2Reward--rm-type math scores each answer.3Trainone update on 256 samples.4Watchthe watchdog counts 503 errors every 30 s.

First run, four commands#

docker pull radixark/miles:latestthe tag moves, so record the digest
mkdir -p ~/miles-lab/runs ~/.cache/huggingfacelab folder and model cache
docker run --rm --name miles-plain --gpus allstart the container with the GPUs
grep -o "'rollout/raw_reward': [0-9.]*" runs/plain.logreward of each step

Run and check a step#

TaskCode
Pull the imagedocker pull radixark/miles:latest
Make the lab foldermkdir -p ~/miles-lab/runs ~/.cache/huggingface
Start a rundocker run --rm --name miles-plain --gpus all
Read the rewardgrep -o "'rollout/raw_reward': [0-9.]*" runs/plain.log
Set the step count-e MILES_NUM_ROLLOUT=<steps>
Name the run-e MILES_RUN=<name>
Fix the seed-e MILES_SEED=<seed>
Add Miles flags-e MILES_EXTRA_ARGS="<flags>"

Stop and guard#

CommandWhat it does
docker stop "$name"The watchdog stops the run after the strike count is reached.
docker pause "$c"The heat guard pauses the container at 84 C.

Defaults that matter#

SettingDefaultNote
MILES_NUM_ROLLOUT12Steps in one run
MILES_MODELQwen3-0.6BModel the launcher downloads
--rollout-batch-size32Prompts per step
--n-samples-per-prompt8Answers per prompt
--sglang-mem-fraction-static0.4Engine share of GPU memory
--update-weight-buffer-size536870912Bucket size in bytes
Watchdog limit100Errors in 60 s that count as a strike
Watchdog checks10Strikes in a row before the stop

Signals in the scripts#

Heat guard
pauses the container when the GPU reaches 84 C.
Resume rule
the guard resumes at 74 C or below after 45 s, or after 120 s at most.
Strike
one check that counts more than 100 lines of 503 Service Unavailable.
Errors
the 503 lines counted in the last 60 s of the container log.
Done file
the guard stops when queue2.done exists.

Questions#

Why is the limit 100?
It is the default errors per 60 s. Errors above it count as a strike.
Why 10 checks?
Ten strikes in a row stop the run.
Why 30 s?
Each watchdog check waits 30 s.
Why does the guard wait before it resumes?
It resumes at 74 C after 45 s, or after 120 s at most.

Fix the common failures#

SymptomCauseFix
Watchdog exits with 2Docker ps failed, so the watchdog cannot see the runStart Docker, then restart the watchdog
Watchdog prints docker logs failedOne check could not read the logsThe check does not count. Confirm the container name
Run keeps going with 503 errorsThe rollout engine died and the trainer keeps sending requestsThe watchdog stops it after 10 strikes. Read the engine lines above the first 503
Heat guard never pausesThe container image is not radixark/miles:latestStart the run with radixark/miles:latest
Heat guard exits at onceThe done file exists from an earlier sessionRemove queue2.done if no queue uses it
Container stays pausedThe guard stopped while it held a pauseThe guard resumes the container on exit. Start the guard again
Heat guard does not resumeGPU stays above 74 CIt resumes after 120 s at most. Check the GPU temperature
Start fails with a memory errorThe engine memory share is too high for the GPULower --sglang-mem-fraction-static

Tips#

  • Give each run a unique MILES_RUN name.
  • Keep 32 prompts times 8 answers equal to the global batch of 256.
  • Set MILES_SEED for repeat runs.
  • Start the watchdog with the same container name as the run.
  • Remove queue2.done before you start the guard, if no queue uses it.