[LMSYS Official] Miles v0.1: Production-level Post-training

LMSYS Miles v0.1 是面向前沿后训练的全栈生产级系统:全异步 RL 循环、SGLang agentic rollout、TITO 逐 token 保真、R3 路由重放、Blackwell 低精度训练、P2P/磁盘增量权重更新,以及扩散模型与多硬件支持。

src/pages/articles/_md/AI/Infra/Post-Training/RL/Miles/Official/lmsys-official-miles-v0-1.md

原文 Miles v0.1: Production-level Post-training · 作者 Miles Team · 来源 LMSYS Blog · 原文发布 2026-08-18 · 中英对照·AI 译 2026-08-19 翻译为 AI 初稿 + 人工校对,如有出入以原文为准。


We present Miles v0.1, a full-stack production-ready system for frontier post-training, the successor to our first Miles release [1]. Building upon slime’s clean design, Miles optimizes every stage in the RL training loop around a simple principle: verified, clean, and customizable everywhere. With accuracy, efficiency, reliability, and scalability as first-class goals, Miles aims to make frontier-scale RL accessible to researchers and developers alike. In this blog post, we will walk through Miles end-to-end.

译: 我们发布 Miles v0.1,一套面向前沿后训练(post-training)的全栈生产级系统,也是首个 Miles 版本的继任者 [1]。基于 slime 的简洁设计,Miles 围绕一个简单原则优化 RL 训练循环中的每一个环节:处处可验证、处处保持洁净、处处可定制。以准确性、效率、可靠性和可扩展性为一等目标,Miles 旨在让前沿规模的 RL 对研究者和开发者都触手可及。本文将端到端地走查 Miles。

The Miles RL Loop

An RL training job in Miles is a loop over the following stages:

译: Miles 中的一个 RL 训练作业是以下阶段的循环:

  • Rollout — SGLang engines generate trajectories. In agentic RL, each multi-turn rollout session interacts with its own isolated environment that executes actions and produces the reward.
  • Training — completed trajectory groups are consumed by the trainer (NVIDIA Megatron-LM or FSDP), which computes the RL loss and updates the policy.
  • Weight update — new weights are synchronized back to the rollout fleet with minimal interruption to in-flight rollouts.

译:

  • Rollout(采样) — SGLang 引擎生成轨迹。在 agentic RL 中,每个多轮采样会话与自身隔离的环境交互,该环境执行动作并产生奖励。
  • Training(训练) — 完成的轨迹组被训练器(NVIDIA Megatron-LM 或 FSDP)消费,训练器计算 RL 损失并更新策略。
  • Weight update(权重更新) — 新权重同步回采样集群,对进行中的采样造成最小打断。

In what follows, we will go through each element in the loop to highlight how we make Miles accurate, efficient, reliable, and scalable.

The Miles fully async RL loop.
The Miles fully async RL loop.

译: 接下来我们将逐一走查循环中的每个环节,重点说明我们如何让 Miles 准确、高效、可靠且可扩展。

Rollout

Every rollout in Miles is generated by SGLang. Building upon SGLang’s native inference efficiency, Miles unlocks the full agentic training workflow: multi-turn sessions, tool execution, sandboxed environments, and token-faithful trajectory capture.

译: Miles 中的每次采样都由 SGLang 生成。基于 SGLang 原生的推理效率,Miles 解锁了完整的 agentic 训练工作流:多轮会话、工具执行、沙箱环境以及逐 token 忠实的轨迹捕获。

Fast Agentic Rollout by SGLang

Miles provides fast agentic rollout by natively integrating SGLang, which is optimized for long, multi-turn generation. Agentic trajectories vary widely in length, and each new turn reuses most of the previous context. By default, Miles uses the SGLang router, which keeps all turns of a session on the same SGLang engine and DP rank (if DP attention is enabled) to reuse the cached prefix, while assigning new sessions to the least-loaded rank so that a few long trajectories do not overload part of the fleet. The SGLang router also reserves KV-cache capacity for long sessions beforehand. These features ensure a balanced and stable rollout concurrency, keeping cache-hit rate high in agentic training.

译: Miles 通过原生集成 SGLang 提供快速的 agentic 采样,后者针对长上下文、多轮生成做了优化。Agentic 轨迹长度差异很大,且每一新轮都会复用上一轮的大部分上下文。默认情况下,Miles 使用 SGLang router,它会将一个会话的所有轮次保持在同一 SGLang 引擎和 DP rank(若启用 DP attention)上以复用已缓存的前缀,同时将新会话分配给负载最低的 rank,避免少数长轨迹使集群的一部分过载。SGLang router 还会提前为长会话预留 KV-cache 容量。这些特性保证了均衡且稳定的采样并发,使 agentic 训练中的 cache 命中率保持在高位。

Fully Async RL

For long-context, tool-use, and agentic workloads, rollout time is mainly determined by a handful of stragglers. A synchronous schedule exacerbates the straggler issue, because the trainer has to sit idle until the slowest trajectory in the batch returns, and the rollout engines have to wait until the optimizer finishes model update. Miles’ fully asynchronous RL eliminates such mutual-blocking by allowing rollout engines to generate persistently: rollout generation stays continuously in flight while the trainer consumes completed groups and updates the model. Neither side is blocked by the other.

How fully async RL handles the long tails. Different colors indicate different weight versions; the green fragments represent tool-call time.
How fully async RL handles the long tails. Different colors indicate different weight versions; the green fragments represent tool-call time.

译: 对于长上下文、工具调用和 agentic 工作负载,采样时间主要由少数几个”拖尾”(straggler)决定。同步调度会加剧拖尾问题:训练器必须空等直到该批中最慢的轨迹返回,采样引擎也必须等优化器完成模型更新。Miles 的全异步 RL 通过允许采样引擎持续生成来消除这种相互阻塞:采样生成持续在途,训练器同时消费已完成的组并更新模型,双方互不阻塞。

Scheduling operates at sample granularity: each completed trajectory immediately frees a slot, keeping generation concurrency stable despite large differences in trajectory length. Completed groups enter a bounded data buffer that decouples rollout throughput from training cadence. This buffer also forms a customizable policy boundary where users decide which samples to keep, retry, discard, or reject as stale without modifying scheduling or execution.

译: 调度以样本为粒度运作:每条完成的轨迹立即释放一个槽位,使生成并发在轨迹长度差异很大时仍保持稳定。已完成的组进入一个有界数据缓冲区,将采样吞吐与训练节奏解耦。该缓冲区也构成一个可定制的策略边界——用户无需修改调度或执行即可决定保留、重试、丢弃哪些样本,或将哪些样本作为过期样本拒绝。

To make evaluation asynchronous, Miles provides three evaluation modes, distinguished by where model weights come from.

译: 为使评估也异步化,Miles 提供三种评估模式,按模型权重的来源区分:

  • Shared-engine evaluation uses the rollout fleet and temporarily pauses new submissions, making it suitable for small debug sets without extra GPUs.
  • Dedicated evaluation uses a separate GPU fleet loaded from checkpoint snapshots, allowing training and rollout to continue uninterrupted.
  • External evaluation passes a checkpoint directory to any user-provided evaluator, including non-SGLang services.

译:

  • 共享引擎评估(Shared-engine evaluation) — 使用采样集群,临时暂停新提交,适合无额外 GPU 的小型调试集。
  • 专用评估(Dedicated evaluation) — 使用从 checkpoint 快照加载的独立 GPU 集群,训练和采样可不受干扰地继续。
  • 外部评估(External evaluation) — 将一个 checkpoint 目录传给任意用户自备的评估器,包括非 SGLang 服务。

All three modes associate results with the checkpoint and training step that produced them. If evaluation finishes several steps later, Miles reports that lag rather than misattributing the result; failures skip the evaluation point instead of terminating training.

Evaluation modes: sharing the rollout engines gates generation, while a checkpoint snapshot hands the eval to a dedicated fleet or an external service without stopping training.
Evaluation modes: sharing the rollout engines gates generation, while a checkpoint snapshot hands the eval to a dedicated fleet or an external service without stopping training.

译: 三种模式都会将结果与产生它的 checkpoint 和训练步关联。如果评估在若干步之后才完成,Miles 会如实报告这一滞后,而不是把结果错误归因;失败时会跳过该评估点而非终止训练。

Agentic Environments

In agentic RL, much of the work happens in an isolated environment. Training a coding agent, for example, means giving the model its own sandbox for each task: it runs commands, edits files, reads what comes back, and a test suite at the end decides whether the task was solved. The environment holds that state, executes the actions, and runs the verifier that produces the reward. Miles runs many such episodes at once, records each trajectory in a form the trainer can learn from, and carries the verifier’s result through as the reward.

译: 在 agentic RL 中,大量工作发生在隔离环境中。例如训练一个编程 agent,意味着为每个任务给模型一个专属沙箱:它运行命令、编辑文件、读取返回结果,最后由一组测试判定任务是否解决。环境持有状态、执行动作,并运行产生奖励的验证器。Miles 同时运行许多这样的 episode,将每条轨迹以训练器可学习的形式记录,并把验证器的结果作为奖励贯穿传递。

An environment reaches Miles through a plug-in point. Miles offers multiple plug-in points at different levels of the rollout stack, so an environment can take over as much or as little of the rollout as it needs. We ship integrations for existing ecosystems, including Harbor, HUD, NeMo Gym, OpenEnv, and Prime Intellect Verifiers. You can even bring your own environments, which plug in through the same points.

译: 环境通过插件点接入 Miles。Miles 在采样栈的不同层级提供多个插件点,因此一个环境可以按需接管采样流程的多或少。我们为现有生态内置了集成,包括 Harbor、HUD、NeMo Gym、OpenEnv 和 Prime Intellect Verifiers。你也可以接入自定义环境,方式与上述相同——通过同样的插件点接入。

The sandboxes run on any backend of your choosing. We support several, including AgentENV, Daytona, E2B, and Modal. Each episode gets a fresh sandbox, built from that task’s own image, so nothing is shared between episodes and nothing stays resident after a run.

译: 沙箱可运行在任意你选定的后端上。我们支持多种后端,包括 AgentENV、Daytona、E2B 和 Modal。每个 episode 都获得一个全新的沙箱,由该任务自身的镜像构建,因此 episode 之间无任何共享,运行结束后无任何驻留。

Miles v0.1 ships maintained end-to-end recipes for agentic coding and terminal tasks. They are validated on real hardware and can be launched as they stand.

译: Miles v0.1 附带维护良好的 agentic 编程与终端任务端到端配方。它们已在真实硬件上验证,可直接启动运行。

Token-In-Token-Out (TITO)

In multi-turn agentic RL, model outputs pass through message parsing, tool execution, and chat-template rendering before entering the next turn. This process can change tokenization, prune historical reasoning, or reserialize tool calls, causing the trainer to see a different token context from the one actually used during rollout.

译: 在多轮 agentic RL 中,模型输出在进入下一轮之前会经过消息解析、工具执行和 chat-template 渲染。这一过程可能改变 tokenization、裁剪历史推理或重新序列化工具调用,导致训练器看到的 token 上下文与采样时实际使用的不一致。

The TITO session server in Miles [6] preserves the exact token IDs generated by the model. On each new turn, it tokenizes only the newly appended messages and merges them with the existing prefix. This allows the complete trajectory to be assembled into one contiguous training sample, preserving the original rollout log probabilities while loss-masking tokens that are not generated by the model. For each model family, TITO is validated through CPU round-trip tests and real SGLang GPU sessions, safeguarding the token-level exactness necessary for R3, OPD, and zero-KL alignment.

译: Miles 中的 TITO 会话服务器 [6] 保存模型生成的精确 token ID。在每一新轮,它只对新追加的消息做 tokenize,并与已有前缀合并。这样就能将完整轨迹组装为一条连续的训练样本,保留采样时的原始 log probabilities,同时对非模型生成的 token 做 loss 掩除(loss-masking)。针对每个模型家族,TITO 都通过 CPU 往返测试和真实 SGLang GPU 会话验证,守护 R3、OPD 和 zero-KL 对齐所需的 token 级精确性。

Building on TITO, Miles is developing a training recipe for black-box agent harnesses such as Claude Code and Codex. These harnesses spawn subagents and compact context at runtime, so the number of trajectories per task is dynamic and unknown in advance. Miles therefore records the full trajectory tree through the session server, and on the training side applies the loss normalization required for varying batch sizes, keeping gradient scale consistent.

Token-in, token-out. The session server keeps the exact token ids the engines produced, so the trainer sees the tokens the model actually generated even when the harness is an opaque black box.
Token-in, token-out. The session server keeps the exact token ids the engines produced, so the trainer sees the tokens the model actually generated even when the harness is an opaque black box.

译: 在 TITO 基础上,Miles 正在为 Claude Code、Codex 等黑盒 agent harness 开发训练配方。这些 harness 会在运行时派生子 agent 并压缩上下文,因此每个任务的轨迹数量是动态的、事先未知的。Miles 据此通过会话服务器记录完整的轨迹树,并在训练侧应用变 batch size 所需的 loss 归一化,保持梯度尺度一致。

Efficient Rollout Routing Replay (R3)

MoE RL is sensitive to tiny numerical differences between rollout and training: a single top-k routing flip changes both the token computation and the expert weights that receive the gradients. To resolve this issue, Miles’ Rollout Routing Replay (R3) records SGLang’s expert routing results during rollout and replays them during training. Such replay is handled efficiently in SGLang, adding only minimal overhead compared with normal routing.

译: MoE RL 对采样与训练之间的微小数值差异极为敏感:一次 top-k 路由翻转会同时改变该 token 的计算和接收梯度的专家权重。为解决此问题,Miles 的 Rollout Routing Replay (R3) 在采样时记录 SGLang 的专家路由结果,并在训练时重放。该重放在 SGLang 中高效完成,相比正常路由只增加极小开销。

Training

Trainer is the backbone of RL. In Miles, we ship numerous trainer optimizations that make RL stable, fast, and resource-efficient.

译: 训练器是 RL 的骨干。Miles 附带大量训练器优化,使 RL 稳定、快速且资源高效。

Low-precision Training

Miles supports rollouts in NVFP4, MXFP4, MXFP8, and FP8; end-to-end training recipes for NVFP4, MXFP8, and FP8; and INT4 quantization-aware training (QAT) [3] for most models. Earlier posts cover the FP8 [2] and INT4 QAT [3] recipes in depth.

译: Miles 支持 NVFP4、MXFP4、MXFP8 和 FP8 采样;NVFP4、MXFP8 和 FP8 的端到端训练配方;以及面向多数模型的 INT4 量化感知训练(QAT)[3]。早期文章已深入介绍 FP8 [2] 和 INT4 QAT [3] 配方。

Capturing Blackwell’s low-precision throughput in RL requires more than swapping GEMM dtypes: quantization on the rollout and training sides must agree, or the mismatch accumulates across weight updates into policy divergence. To this end, we build the Blackwell-native MXFP8 and NVFP4 recipes [9] as end-to-end precision contracts across the stack: MXFP8 runs rollout, forward, and both gradient GEMMs with hardware blockwise scaling; NVFP4 quantizes MoE expert weights per-token with online activation scaling to avoid batch-dependent quantization artifacts; a bit-exact quantizer contract keeps training and rollout kernels seeing the same quantized values, with fine-grained flags to keep sensitive layers in BF16. The recipes are verified with low KL divergence between SGLang and Megatron-LM. All low-precision configurations keep reward curves closely tracking the BF16 baseline while reducing rollout time.

译: 要在 RL 中获得 Blackwell 的低精度吞吐,仅仅更换 GEMM 数据类型是不够的:采样侧与训练侧的量化必须一致,否则不匹配会随权重更新累积,最终导致策略发散。为此,我们将 Blackwell 原生的 MXFP8 和 NVFP4 配方 [9] 构建为跨全栈的端到端精度契约:MXFP8 用硬件分块缩放运行 rollout、前向和两个梯度 GEMM;NVFP4 以 per-token 在线激活缩放量化 MoE 专家权重,避免依赖 batch 的量化伪影;逐位精确的量化器契约保证训练和采样 kernel 看到相同的量化值,并提供精细标志让敏感层保持 BF16。这些配方以 SGLang 与 Megatron-LM 之间的低 KL 散度验证通过。所有低精度配置在缩短采样时间的同时,使 reward 曲线紧密贴合 BF16 基线。

Memory Efficiency & Disk Offload

Training a 744B-parameter model asynchronously on 16 nodes poses a significant memory issue. Miles ships with sophisticated memory optimization that large-scale runs depend on, starting with the optimizer: optimizer states can be offloaded to CPU or node-local NVMe and streamed back per bucket during each optimizer step, so they never need to be resident on the GPU at once. In the example that we demonstrate at the end of this blog post, this NVMe optimizer-state streaming is what lets the GLM-5.2 optimizer fit alongside the training engine on 32 GB300 GPUs. Beyond offloading, Miles also enables a series of other GPU and CPU memory footprint reductions, saving 30+ GB HBM memory per GPU in the example GLM-5.2 run, and hundreds of GB of CPU memory per node when the trainer is colocated with the rollout engines.

译: 在 16 个节点上异步训练 744B 参数模型会带来显著的显存问题。Miles 附带大规模运行所依赖的精细内存优化,首先从优化器入手:优化器状态可被 offload 到 CPU 或节点本地 NVMe,并在每次优化器步骤中按 bucket 流式回读,因此无需同时常驻 GPU。在本文末尾展示的示例中,正是这一 NVMe 优化器状态流式传输让 GLM-5.2 的优化器能与训练引擎共存在 32 张 GB300 GPU 上。除 offload 外,Miles 还启用了一系列其他 GPU 与 CPU 内存占用缩减,在该 GLM-5.2 示例运行中每张 GPU 节省 30+ GB HBM,并在训练器与采样引擎共置时每节点节省数百 GB CPU 内存。

Two Training Backends

Miles supports two training backends behind one interface: NVIDIA Megatron-LM and PyTorch FSDP. A single launch flag picks which of them owns the model on the GPU; a backend implements five methods, and nothing above that line changes.

译: Miles 在同一接口下支持两种训练后端:NVIDIA Megatron-LM 和 PyTorch FSDP。一个启动标志即可选定由谁在 GPU 上持有模型;后端只需实现五个方法,此线之上的任何东西都不需改动。

  • Megatron-LM is the default, and the backend the model recipes are written against. It splits the model internally across tensor, pipeline, context, expert and expert-tensor parallelism, and supports CPU and NVMe optimizer offload, per-bucket optimizer state streaming, and checkpoints that are parallelism-agnostic, so the layout can change later without reconverting.
  • FSDP trains the model’s own HuggingFace implementation under PyTorch FSDP2. Config and weights load straight from the HuggingFace directory, so there is no conversion step and no architecture flags to write, and parallelism is data parallel only. Architectures that need small corrections register them as adaptation specs rather than forking the model code.

译:

  • Megatron-LM(默认)— 模型配方所针对编写的后端。它在内部将模型切分到 tensor、pipeline、context、expert 和 expert-tensor 并行,支持 CPU 和 NVMe 优化器 offload、按 bucket 的优化器状态流式传输,以及与并行策略无关的 checkpoint,使得布局日后可变更而无需重新转换。
  • FSDP — 在 PyTorch FSDP2 下训练模型自带的 HuggingFace 实现。配置和权重直接从 HuggingFace 目录加载,无需转换步骤、无需编写架构标志,且并行仅限数据并行。需要小幅修正的架构以”适配规格(adaptation specs)“形式注册,而非 fork 模型代码。

Weight Update

In each training step, after the optimizer updates the model weights, the new weights have to be synchronized across all rollout engines. When training and rollout run on different GPUs, weight synchronization can become a major pipeline bottleneck. Miles provides two optimized paths for diverse deployment settings. With P2P weight transfer [5], training ranks re-shard each weight bucket for the target SGLang layout and write only the required shards directly into rollout-rank memory over RDMA. This avoids broadcasting the full model to every rank and uses multiple training ranks as senders in parallel. The benefit grows with model size and expert parallelism: for Kimi-K2 1T, P2P reduced weight-update time from 53.3 seconds to 7.2 seconds.

译: 每个训练步中,优化器更新模型权重后,新权重必须同步到所有采样引擎。当训练和采样运行在不同 GPU 上时,权重同步可能成为主要的流水线瓶颈。Miles 为多种部署场景提供两条优化路径。其一是 P2P 权重传输 [5]:训练 rank 为目标 SGLang 布局对每个权重 bucket 重新分片,并仅将所需 shard 经 RDMA 直接写入采样 rank 的内存。这避免向每个 rank 广播完整模型,并并行使用多个训练 rank 作为发送方。收益随模型规模和专家并行度增长:对 Kimi-K2 1T,P2P 将权重更新时间从 53.3 降至 7.2 秒。

For rollout fleets without direct NCCL or RDMA connectivity, Miles supports disk-delta updates. Consecutive RL steps often change only a small fraction of the model’s bytes, so Miles only needs to publish the delta-weights against the previous policy version instead of transferring a full checkpoint. Rollout engines apply and verify the delta-weights while generation continues, then pause only to load the combined weights into SGLang. Usually only 2% of parameters are included in the delta-weights for BF16 rollout, and 0.5% for FP4 rollout. In a GLM-4.7-Flash run, this reduces the per-update payload from 62.4 GB to 0.69–0.83 GB while keeping the generation pause within 3–5 seconds.

译: 对于无直接 NCCL 或 RDMA 连接的采样集群,Miles 支持磁盘增量(disk-delta)更新。连续的 RL 步往往只改变模型字节的一小部分,因此 Miles 只需发布相对上一策略版本的增量权重,而非传输完整 checkpoint。采样引擎在生成继续的同时应用并校验增量权重,随后仅暂停以将合并后的权重加载进 SGLang。通常 BF16 采样的增量权重只含 2% 的参数,FP4 采样为 0.5%。在一次 GLM-4.7-Flash 运行中,这使每次更新的载荷从 62.4 GB 降至 0.69–0.83 GB,同时将生成暂停控制在 3–5 秒内。

Verified Day-0 Model Support

Miles lands new frontier models on the day their weights become public, together with SGLang. Kimi-K3 [13], DeepSeek-V4 [10], Inkling [12], Qwen3.8 [14] and NVIDIA Nemotron 3 Ultra [11] were all trainable in Miles on release day, because the inference path in SGLang and the RL recipe in Miles are brought up in parallel rather than one after the other. Day-0 coverage is not limited to one architecture family either: it spans dense and MoE models, hybrid attention, and multimodal inputs. Beyond day 0, almost every open frontier model runs on Miles, including DeepSeek-V3.2, Kimi-K2.6, Qwen3.8, GLM-5.2, Gemma-4, GPT-OSS and so on. For each supported model, we ship CI-guarded recipes in Miles. The full list can be found here.

译: Miles 在新前沿模型权重公开当日即与 SGLang 同步落地支持。Kimi-K3 [13]、DeepSeek-V4 [10]、Inkling [12]、Qwen3.8 [14] 和 NVIDIA Nemotron 3 Ultra [11] 都在发布当日即可在 Miles 中训练,因为 SGLang 中的推理路径与 Miles 中的 RL 配方是并行推进的,而非先后串行。Day-0 覆盖也不限于某一架构家族:横跨稠密与 MoE 模型、混合注意力以及多模态输入。Day 0 之外,几乎每个开源前沿模型都能在 Miles 上运行,包括 DeepSeek-V3.2、Kimi-K2.6、Qwen3.8、GLM-5.2、Gemma-4、GPT-OSS 等。对每个支持的模型,我们都在 Miles 中提供 CI 守护的配方。完整列表见此处。

Other Post-Training Recipes

Beyond the core RL loop, Miles is a general post-training platform. The rollout engines, trainer, and weight-update paths described above are shared components rather than RL-specific machinery, and they compose into other training paradigms: LoRA RL, on-policy distillation (OPD), and supervised fine-tuning (SFT), which runs the same trainer with an SFT loss and no rollout engine at all. This section walks through LoRA RL and OPD, where most of the Miles-specific work lives, and closes with Zero-KL Alignment, which eliminates the numerical mismatch between rollout and training so that on-policy data is genuinely on-policy.

译: 除核心 RL 循环外,Miles 还是一个通用的后训练平台。上文所述的采样引擎、训练器和权重更新路径是共享组件,而非 RL 专用机制,它们可组合成其他训练范式:LoRA RL、on-policy distillation(OPD)以及 supervised fine-tuning(SFT)——后者用同一训练器跑 SFT 损失、完全不使用采样引擎。本节走查 LoRA RL 和 OPD(Miles 专属工作主要集中于此),最后以 Zero-KL Alignment 收尾——它消除采样与训练之间的数值不匹配,使 on-policy 数据名副其实。

LoRA RL

Miles enables end-to-end LoRA reinforcement learning across training, weight synchronization, and SGLang rollout, for both LLMs and diffusion models. The base model remains frozen and resident, while Miles trains and synchronizes only the adapters, and SGLang applies the latest adapter during rollout.

译: Miles 为 LLM 和扩散模型实现跨训练、权重同步和 SGLang 采样的端到端 LoRA 强化学习。基座模型保持冻结与常驻,Miles 只训练和同步 adapter,SGLang 在采样时应用最新 adapter。

Miles supports dense and MoE models including GPT-OSS, GLM, Kimi K2/K3, and Inkling. For GLM-5.2 744B-A40B, the trainable parameters occupy just 212 MB, around 0.014% of the size of the model’s BF16 base weights—significantly reducing training costs.

译: Miles 支持稠密和 MoE 模型,包括 GPT-OSS、GLM、Kimi K2/K3 和 Inkling。对 GLM-5.2 744B-A40B,可训练参数仅占 212 MB,约为模型 BF16 基座权重的 0.014%,显著降低训练成本。

Alongside saving memory, LoRA also brings efficiency advantages in RL training:

译: 除节省显存外,LoRA 在 RL 训练中也带来效率优势:

  • Less time for each trainer step: the trainer computes weight gradients and optimizer updates only for the small low-rank adapters, reducing gradient computation, optimizer workload, memory traffic, and distributed communication, thereby improving overall training efficiency.
  • Lightweight and efficient weight synchronization: Miles only needs to synchronize the updated LoRA adapter. It packs distributed TP and EP fragments into a small number of flat collectives, then transfers the serving-ready tensors directly to colocated SGLang workers, without staging them in host memory. Because only the LoRA weights are transferred, this approach significantly reduces transfer time.

译:

  • 每步训练器耗时更少 — 训练器只为小型低秩 adapter 计算权重梯度和优化器更新,减少梯度计算、优化器工作负载、内存搬运和分布式通信,从而提升整体训练效率。
  • 轻量高效的权重同步 — Miles 只需同步更新后的 LoRA adapter。它将分布式的 TP 和 EP 分片打包为少量扁平集合通信,再把已就绪可服务的 tensor 直接传输给共置的 SGLang worker,无需在 host 内存中暂存。由于只传输 LoRA 权重,此方式显著缩短传输时间。

Miles also provides a multi-LoRA RL backend for training and serving independently configured LoRA adapters on a shared base model. This experimental backend updates only changed adapters and routes mixed-adapter rollouts through SGLang, laying the foundation for a Tinker-compatible platform with lower compute, memory, communication, and operational cost.

译: Miles 还提供多 LoRA RL 后端,用于在共享基座模型上训练并服务各自独立配置的 LoRA adapter。该实验性后端只更新发生变化的 adapter,并通过 SGLang 路由混合 adapter 的采样,为兼容 Tinker 的平台奠定基础,带来更低的计算、内存、通信和运维成本。

On-Policy Distillation (OPD)

Miles supports on-policy distillation [8], which allows a student to learn from teacher guidance on its own rollout distribution. The reverse KL is implemented as a “reward,” so users can optionally complement the distillation with conventional GRPO/PPO-style rewards. In terms of how the reverse KL is approximated, users can also choose between computing only from the student’s sampled token, or from a set of tokens with top-K probabilities.

译: Miles 支持 on-policy distillation [8],允许学生模型在自身采样分布上从教师引导中学习。reverse KL 被实现为一种”奖励”,因此用户可选择性地辅以常规 GRPO/PPO 式奖励。在 reverse KL 的近似方式上,用户还可选择仅从学生采样到的 token 计算,或从 top-K 概率的 token 集合计算。

For long-context workloads, Miles uses sparse per-position teacher scoring: the teacher scores only the candidate tokens required at each generated position. This avoids unnecessary construction, communication, and parsing overhead. Miles also offers configurable candidate selection and weighting strategies for a range of OPD recipes.

译: 对于长上下文工作负载,Miles 使用稀疏的逐位置教师打分:教师只对每个生成位置所需的候选 token 打分。这避免了不必要的构造、通信和解析开销。Miles 还提供可配置的候选选择与加权策略,以适应一系列 OPD 配方。

In a Qwen3.5-35B-A3B self-distillation experiment on a B200 node, with only the reverse KL “reward”, OPD reduced the average rollout length from 18.6K to ~6K tokens, while improving held-out DAPO performance from 84.6% to 89.5%. This demonstrates OPD’s ability to transfer behaviors with minimal effect on benchmark performance.

On-policy distillation. The teacher scores the tokens the student generated, and the reverse-KL signal drives the update, optionally alongside a task reward.
On-policy distillation. The teacher scores the tokens the student generated, and the reverse-KL signal drives the update, optionally alongside a task reward.

译: 在一个 B200 节点上的 Qwen3.5-35B-A3B 自蒸馏实验中,仅用 reverse KL “奖励”,OPD 将平均采样长度从 18.6K 降至约 6K token,同时将留出集 DAPO 性能从 84.6% 提升至 89.5%。这表明 OPD 能在几乎不影响 benchmark 性能的前提下迁移行为。

Zero-KL Alignment

Miles supports Zero-KL Alignment, minimizing numerical differences between rollout and training engines by aligning attention, GEMM, operator precision, batching behavior, and other execution details, in addition to model weights. In supported configurations, the training–rollout log-probability difference can stay exactly zero.

译: Miles 支持 Zero-KL Alignment(零 KL 对齐),通过在模型权重之外对齐 attention、GEMM、算子精度、batch 行为及其他执行细节,最小化采样与训练引擎之间的数值差异。在受支持的配置下,训练-采样的 log-probability 差异可以精确保持为零。

Zero-KL Alignment is currently only available for the Qwen 3 model family, but we plan to support more model architectures, kernels, and parallelism configurations soon.

译: Zero-KL Alignment 目前仅面向 Qwen 3 模型家族可用,但我们计划尽快支持更多模型架构、kernel 和并行配置。

Code Quality Principle

By now, we have covered the entire RL training loop in Miles, and all those features are built around our code quality principle: Miles should be easy to read and extend. The training driver is intentionally written like pseudocode, while major components, like rollout functions, data sources, losses, and rewards, sit behind small, typed interfaces. The rollout stack is divided into agent, generation, and rollout layers, so an environment or agent framework can replace only the layer it needs while reusing everything else. This makes it straightforward to build a custom RL training loop without forking or rewriting Miles.

译: 至此我们已走查 Miles 的整个 RL 训练循环,所有这些特性都围绕我们的代码质量原则构建:Miles 应当易读、易扩展。训练驱动有意写得像伪代码,而主要组件(采样函数、数据源、损失、奖励)都藏在小型、带类型的接口之后。采样栈被划分为 agent、generation 和 rollout 三层,因此一个环境或 agent 框架可以只替换自己需要的那一层,其余部分照常复用。这让构建自定义 RL 训练循环变得直截了当——无需 fork 或重写 Miles。

Miles-Diffusion

Miles’ design philosophy extends beyond LLMs to diffusion models. In Miles-diffusion, sglang-diffusion serves as the high-performance rollout engine and returns the full denoising trajectory with per-step log-probs. An FSDP2 trainer consumes selected SDE steps and optimizes the RL objective under hybrid shard and SP. Inherited from Miles’ design, Flow-GRPO, DiffusionNFT, and SFT are all unified within a single trainer with pluggable loss, rollout, and reward components. Initial supported models include SD3.5, Qwen-Image, Wan2.2, LTX-2.3, Cosmos3, and Minimax-H3, with curve-verified recipes for each.

译: Miles 的设计哲学不止于 LLM,也延伸到扩散模型。在 Miles-diffusion 中,sglang-diffusion 作为高性能采样引擎,返回完整的去噪轨迹及逐步 log-prob。一个 FSDP2 训练器消费选定的 SDE 步,并在混合 shard 与 SP 下优化 RL 目标。继承自 Miles 的设计,Flow-GRPO、DiffusionNFT 和 SFT 都统一在单一训练器内,loss、rollout、reward 组件均可插拔。初始支持的模型包括 SD3.5、Qwen-Image、Wan2.2、LTX-2.3、Cosmos3 和 Minimax-H3,每个都有经曲线验证的配方。

On the rollout side, sglang-diffusion rollout organizes generations into microgroups, reusing encoder results and batching samples. A 5.87× speed-up is observed over plain serial generation on Qwen-Image at 512×512 with group size 16. Each microgroup is then deserialized and reward-scored as its own async stream to overlap with others. On the training side, optional deterministic mode enables bitwise reproducibility, which verifies recipe quality together with documented curves and end-to-end CI. To address training-inference mismatch and keep precision-sensitive DiT parameters, FSDP2 is patched to enable fine-grained per-parameter dtype control.

译: 在采样侧,sglang-diffusion 采样将生成组织为 microgroup,复用编码器结果并批处理样本。在 Qwen-Image 512×512、group size 16 的设置下,相对朴素串行生成观察到 5.87× 加速。每个 microgroup 随后被反序列化、作为独立异步流做奖励打分,与其他流重叠。在训练侧,可选的 deterministic 模式实现按位可复现,与已记录曲线和端到端 CI 一起验证配方质量。为解决训练-推理不匹配并保留精度敏感的 DiT 参数,FSDP2 被打补丁以启用精细的逐参数 dtype 控制。

Multi-Hardware Support

Miles runs the same training loop on NVIDIA and AMD GPUs. NVIDIA coverage spans A100 through GB300, the hardware behind the reference run and the Blackwell low-precision recipes in this post. AMD support is native ROCm through HIP and RCCL [4], [7]: Miles runs on MI300X through MI355X with the same SGLang rollout integration and dedicated Docker images, and CI exercises both vendors alike, running end-to-end training tests on NVIDIA and AMD runners.

译: Miles 在 NVIDIA 和 AMD GPU 上运行同一训练循环。NVIDIA 覆盖从 A100 到 GB300,即本文参考运行和 Blackwell 低精度配方所用的硬件。AMD 支持是通过 HIP 和 RCCL 的原生 ROCm [4][7]:Miles 在 MI300X 到 MI355X 上运行,具备相同的 SGLang 采样集成和专用 Docker 镜像,CI 对两家厂商同等对待,在 NVIDIA 和 AMD runner 上都运行端到端训练测试。

Example: Training GLM-5.2 on Terminal-Use Tasks with 64 NVIDIA GB300 GPUs

As an end-to-end example of agentic RL training, we demonstrate how we use Miles to train a GLM-5.2 744B-A40B model on terminal-use coding tasks using fully asynchronous RL across 64 NVIDIA GB300 GPUs, with 32 GPUs for rollout and 32 GPUs for training. For maximal performance, we set training parallelism to TP 2 / PP 4 / CP 4 / EP 8 and inference parallelism to TP 8 / EP 8, with multi-token prediction (MTP) enabled. Each multi-turn terminal agent runs in its own sandbox using the OpenEnv integration in Miles. In this reference run, we use a 65k max sequence length and a batch size of 64.

译: 作为 agentic RL 训练的端到端示例,我们演示如何用 Miles 跨 64 张 NVIDIA GB300 GPU(32 张采样、32 张训练)以全异步 RL 训练 GLM-5.2 744B-A40B 模型完成终端编程任务。为追求最大性能,我们将训练并行设为 TP 2 / PP 4 / CP 4 / EP 8、推理并行设为 TP 8 / EP 8,并启用 multi-token prediction(MTP)。每个多轮终端 agent 都在用 Miles 的 OpenEnv 集成构建的专属沙箱中运行。在该参考运行中,我们使用 65k 最大序列长度和 64 的 batch size。

  • The reference run completes 100 terminal-bench-like coding task rollout steps stably, sustaining roughly 4.5 minute training steps, with the rollout weights lagging on average 1.7 steps behind the trainer.
  • Rollout and training are almost fully overlapped via sample-level asynchronous scheduling, DP-aware and load-balanced routing, and a balanced SGLang server config. Rollout reaches a 96% prefix-cache hit rate with stable concurrency.
  • Thanks to the substantial memory optimization enabled by Miles, we can fit asynchronous training of a 744B model into 64 GPUs, hosting the training engine on only 32 GB300 GPUs.

译:

  • 该参考运行稳定完成 100 步类 terminal-bench 编程任务采样,维持约 4.5 分钟/训练步,采样权重平均滞后训练器 1.7 步。
  • 采样与训练几乎完全重叠,靠的是样本级异步调度、DP 感知且负载均衡的路由,以及均衡的 SGLang server 配置。采样达到 96% 的前缀 cache 命中率,并发稳定。
  • 得益于 Miles 带来的大幅内存优化,我们能将 744B 模型的异步训练塞进 64 张 GPU,仅用 32 张 GB300 GPU 承载训练引擎。

The full launch script for this run can be found here.

Metrics in the GLM-5.2 agentic RL training example.
Metrics in the GLM-5.2 agentic RL training example.

译: 该运行的完整启动脚本见此处。

Acknowledgement

We would like to thank all community contributors of Miles and SGLang for their invaluable contributions and continued support ❤️

译: 我们感谢 Miles 与 SGLang 的所有社区贡献者,感谢他们无可估量的贡献与持续支持 ❤️

References

The Miles blog series:

译: Miles 博客系列:

  1. Introducing Miles — RL Framework To Fire Up Large-Scale MoE Training
  2. Unified FP8: Moving Beyond Mixed Precision for Stable and Accelerated MoE RL
  3. Squeezing 1TB Model Rollout into a Single H200: INT4 QAT RL End-to-End Practice
  4. ROCm Support for Miles: Large-Scale RL Post-Training on AMD Instinct™ GPUs
  5. Updating 1T parameters in seconds — P2P weight transfer in Large Scale Distributed RL
  6. No Token Left Behind: Demystifying Token-In-Token-Out in Miles
  7. Bringing DeepSeek-V4 Flash RL Training to AMD Instinct MI355X GPUs with Miles
  8. OPD Support in Miles
  9. Towards Blackwell-Native 8-bit and 4-bit RL: End-to-End MXFP8 and NVFP4 RL in Miles

Day-0 model support with Miles RL:

译: Miles RL 的 Day-0 模型支持:

  1. DeepSeek-V4 on Day 0: From Fast Inference to Verified RL with SGLang and Miles
  2. SGLang and Miles Add Day-0 Support for NVIDIA Nemotron 3 Ultra for Long-Running Autonomous Agents
  3. SGLang and Miles Add Day-0 Support for Inkling, a Frontier Multimodal Model
  4. SGLang and Miles Add Day-0 Support for Kimi K3
  5. SGLang and Miles Add Day-0 Support for Qwen3.8

相关阅读