# Miles

> Enterprise RL post-training on SGLang rollout and Megatron-LM training, built for trillion-parameter runs

- Category: Training & Fine-Tuning / RLHF & Alignment
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/radixark/miles
- Website: https://miles.radixark.com
- Canonical page: https://ai-tldr.dev/tools/miles/
- Updated: 2026-09-08

## In short

Miles is an open-source reinforcement-learning framework from RadixArk for post-training large language and vision-language models. It sits in the RLHF & Alignment category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0. To get started: check the machine first.

## Overview

Miles is an open-source reinforcement-learning framework from RadixArk for post-training large language and vision-language models. The project describes it as "a high-performance, enterprise-ready reinforcement learning framework for large-scale model post-training" that combines SGLang for rollout with Megatron-LM for training, adding the precision, stability and observability an RL run needs at trillion-parameter scale. It is a fork of THUDM's slime and, in RadixArk's words, co-evolves with it rather than replacing it.

The design point is asynchrony. Rollout workers and training workers are decoupled and run fully async, so generation does not stall while a gradient step runs. Tokens pass between the two halves directly — the project calls this token-in-token-out, or TITO — which removes a detokenize/retokenize round trip and the subtle mismatches it can introduce. Updated weights reach the inference engines in seconds even at trillion-parameter scale, and a mechanism called Rollout Routing Replay (R3) removes mixture-of-experts routing mismatches between the rollout and training copies of a model.

Beyond the core loop, Miles covers the parts of an RL run that break in production. Low-precision training spans MXFP8, NVFP4, FP8, INT4 quantization-aware training, BF16 and FP16. LoRA and multi-LoRA work at frontier scale, so a run does not have to update every parameter. SGLang engines that die are recovered automatically, and the rollout path does its own request routing and health-checking. Training runs on Megatron-LM as the primary backend or PyTorch FSDP2 as an alternative.

Hardware and model coverage are unusually broad for RL training code. NVIDIA GB300, GB200, B300, B200, H200, H100 and A100 are supported, as are AMD MI300X, MI325, MI350 and MI355X through ROCm, with a separate ROCm Docker image. Day-zero model support covers DeepSeek-V4, Kimi-K3, GLM-5.2, Inkling and Nemotron, with wider compatibility including Kimi-K2.6 and Qwen3.5. The recipe set spans GRPO, GSPO, PPO, REINFORCE++, supervised fine-tuning and on-policy distillation.

## What it does

- Fully asynchronous RL — rollout and training workers are decoupled, so generation does not block on gradient steps
- Token-in-token-out (TITO) passes tokens straight between rollout and training, with no detokenize/retokenize cycle
- Weight updates that reach the inference engines in seconds even for trillion-parameter models
- Low-precision training across MXFP8, NVFP4, FP8, INT4 QAT, BF16 and FP16, plus LoRA and multi-LoRA at frontier scale
- Rollout Routing Replay (R3) removes mixture-of-experts routing mismatches between rollout and training
- Runs on both NVIDIA (GB300 through A100) and AMD (MI300X through MI355X) accelerators, with fault tolerance that restarts failed SGLang engines

## Getting started

Docker is the recommended path — the image ships the patched SGLang and Megatron dependencies. The quick start runs a complete GRPO loop on Qwen3-4B with a math dataset and AIME as the evaluation set.

1. Check the machine first

   Confirm the GPUs are visible to both the host and Docker, and that there is disk space where Docker stores images.

```bash
nvidia-smi -L
docker run --rm --gpus all ubuntu nvidia-smi
df -h $(docker info -f '{{.DockerRootDir}}')
```

2. Pull and start the container

   Pull the prebuilt image and start it with GPUs attached and enough shared memory. AMD users pull rlsys/miles:MI350-355-latest (or MI300-latest) instead, with the ROCm device mounts.

```bash
docker pull radixark/miles:latest

docker run --rm --gpus all --ipc=host --shm-size=32g \
  -it radixark/miles:latest /bin/bash
```

3. Update Miles inside the image

   Miles is preinstalled in the image; pull the newest revision and reinstall in editable mode so the container matches the current main branch.

```bash
cd /root/miles
git pull --rebase
pip install -e . --no-deps

python -c "import miles; print('Miles import OK')"
```

4. Install from source instead (optional)

   If Docker is not an option, install from a clone. The documentation warns that this risks version mismatches with the patched dependencies the image ships.

```bash
git clone https://github.com/radixark/miles.git
cd miles
pip install -r requirements.txt
pip install -e . --no-deps
```

5. Download the model and datasets, then convert

   The quick start uses Qwen3-4B with a math training set and an AIME evaluation set, then converts the Hugging Face weights into Megatron's sharded torch_dist format with convert_hf_to_torch_dist.py.

```bash
# three `hf download` commands fetch the model, the math
# training set and the AIME eval set, then:
python tools/convert_hf_to_torch_dist.py ${MODEL_ARGS[@]} \
  --hf-checkpoint /root/Qwen3-4B \
  --save /root/Qwen3-4B_torch_dist
```

6. Launch the training job

   The launch script starts a local Ray cluster and submits the job. Checkpointing and evaluation run automatically from there.

```bash
python scripts/run_qwen3_dense.py --model-name Qwen3-4B
```

## When to use it

- Reach for it when you are running RL post-training at frontier scale and need rollout and training to run asynchronously rather than in lockstep
- Reach for it when your cluster is AMD — Miles ships a ROCm image and supports MI300X through MI355X, which most RL training code does not
- Reach for it when you want GRPO, GSPO, PPO, REINFORCE++, SFT and on-policy distillation from one framework instead of several projects stitched together
- Reach for it when a mixture-of-experts model is drifting between rollout and training — Rollout Routing Replay exists specifically for that mismatch

## Version history

- 2026-09-08 v0.1: RadixArk published the Miles v0.1 technical report, a 12-author paper describing the full post-training stack: async rollout engines, Megatron-LM and FSDP2 trainer backends, LoRA RL and low-precision training. The case study post-trains a GLM-5.2 744B-A40B model.
