重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
miles-rl-training by orchestra-research/ai-research-skills
npx skills add https://github.com/orchestra-research/ai-research-skills --skill miles-rl-trainingmiles 是一个高性能、企业就绪的强化学习框架,专为大规模模型后训练优化而构建。作为 slime 的生产分支版本,它解决了混合专家模型训练稳定性、低精度训练以及训练-推理对齐等关键挑战。
在以下场景中选择 miles:
在以下场景中考虑替代方案:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 推荐:使用 Docker
docker pull radixark/miles:latest
docker run --rm --gpus all --ipc=host --shm-size=16g \
-it radixark/miles:latest /bin/bash
# 从源码安装
git clone https://github.com/radixark/miles.git
cd miles
pip install -r requirements.txt
pip install -e .
miles 继承了 slime 的配置系统。基础训练如下:
python train.py \
--advantage-estimator grpo \
--model-name qwen3-30b-a3b \
--hf-checkpoint /path/to/qwen3-30b-a3b-hf \
--rollout-batch-size 512 \
--n-samples-per-prompt 8
此工作流适用于训练大型混合专家模型,如 DeepSeek V3 或 Qwen3-MoE。
# FP8 块缩放(推荐用于稳定性)
export NVTE_FP8_BLOCK_SCALING_FP32_SCALES=1
export CUDA_DEVICE_MAX_CONNECTIONS=1
python train.py \
--actor-num-gpus-per-node 8 \
--rollout-num-gpus 8 \
--hf-checkpoint /path/to/deepseek-v3 \
--advantage-estimator grpo \
--tensor-model-parallel-size 8 \
--expert-model-parallel-size 4 \
--prompt-data /path/to/data.jsonl \
--num-rollout 3000
此工作流适用于通过 EAGLE 推测式解码实现最大 rollout 吞吐量。
miles 通过 SGLang 支持 EAGLE 推测式解码:
python train.py \
--actor-num-gpus-per-node 8 \
--hf-checkpoint /path/to/target-model \
--sglang-speculative-algorithm EAGLE \
--sglang-speculative-num-steps 3 \
--sglang-speculative-eagle-topk 1 \
--sglang-speculative-num-draft-tokens 4 \
--sglang-speculative-draft-model-path /path/to/draft-model \
--advantage-estimator grpo \
--prompt-data /path/to/data.jsonl
用于在训练期间对草稿模型进行在线 SFT:
--mtp-num-layers 1 \
--enable-mtp-training \
--mtp-loss-scaling-factor 0.2
注意:在线 MTP 训练需要一个包含 MTP 权重的 torch dist 检查点。在从 HuggingFace 转换检查点时添加 --mtp-num-layers 1。
miles 继承了 slime 的所有参数。完整列表请参见 slime API 参考文档。
--actor-num-nodes 1
--actor-num-gpus-per-node 8
--rollout-num-gpus 8
--rollout-num-gpus-per-engine 2
--colocate
--tensor-model-parallel-size 8
--pipeline-model-parallel-size 2
--expert-model-parallel-size 4 # MoE 专家并行
--sglang-speculative-algorithm EAGLE
--sglang-speculative-num-steps 3
--sglang-speculative-eagle-topk 1
--sglang-speculative-num-draft-tokens 4
--sglang-enable-draft-weights-cpu-backup
--sglang-speculative-draft-model-path /your/draft/model/path
--mtp-num-layers 1
--enable-mtp-training
--mtp-loss-scaling-factor 0.2
以下特性已在 miles 中记录,但具体的 CLI 标志可能有所不同。请查阅 miles 仓库获取最新配置。
端到端的 FP8 采样和训练,消除了导致混合专家模型中强化学习崩溃的量化差异。
在 SGLang 推理期间记录专家路由决策,并在 Megatron 训练期间重放,以实现比特级专家对齐。
R3 工作原理:
sample.rollout_routed_experts 中支持在单机上部署 1TB 以上的模型(例如,在 H200 上)。
使用 INT4 的内存节省:
| 模型大小 | BF16 VRAM | INT4 VRAM | 减少倍数 |
|---|---|---|---|
| 70B | 140GB | 45GB | 3.1x |
| 235B | 470GB | 150GB | 3.1x |
| 671B | 1.3TB | 420GB | 3.1x |
miles 通过以下方式实现训练和推理之间“完全为零的 KL 散度”:
torch.compile 集成miles 使用与 slime 相同的 Sample 数据类,并包含用于混合专家路由重放的 rollout_routed_experts 字段:
@dataclass
class Sample:
prompt: str | list[dict]
tokens: list[int]
response: str
reward: float | dict
loss_mask: list[int]
status: Status
metadata: dict
rollout_log_probs: list[float]
rollout_routed_experts: list[list[int]] # 用于 R3 的 MoE 路由
完整的 Sample 定义请参见 slime API 参考文档。
症状:损失值爆炸,出现 NaN 值
解决方案:
export NVTE_FP8_BLOCK_SCALING_FP32_SCALES=1--lr 5e-7症状:随时间推移,接受率降低
解决方案:
--sglang-speculative-num-steps 2--sglang-enable-draft-weights-cpu-backup症状:策略发散,奖励崩溃
解决方案:
--use-tis --tis-threshold 0.9| 系列 | 模型 | 混合专家支持 |
|---|---|---|
| DeepSeek | R1, V3, V3.2 | 完全支持 |
| Qwen | 2, 2.5, 3 (包括 MoE) | 完全支持 |
| Llama | 3, 3.1, 3.3, 4 | 仅密集模型 |
| Gemma | 2, 3, 3N | 仅密集模型 |
| GLM | 4.5, 4.6, 4.7 | 仅密集模型 |
| MiniMax | M2, M2.1 | 完全支持 |
每周安装量
65
仓库
GitHub 星标数
5.5K
首次出现
2026年2月7日
安全审计
已安装于
opencode55
codex54
cursor54
gemini-cli53
claude-code53
github-copilot52
miles is a high-performance, enterprise-ready RL framework optimized for large-scale model post-training. Built as a production fork of slime, it addresses critical challenges in MoE training stability, low-precision training, and train-inference alignment.
Choose miles when you need:
Consider alternatives when:
# Recommended: Docker
docker pull radixark/miles:latest
docker run --rm --gpus all --ipc=host --shm-size=16g \
-it radixark/miles:latest /bin/bash
# From source
git clone https://github.com/radixark/miles.git
cd miles
pip install -r requirements.txt
pip install -e .
miles inherits slime's configuration system. Basic training:
python train.py \
--advantage-estimator grpo \
--model-name qwen3-30b-a3b \
--hf-checkpoint /path/to/qwen3-30b-a3b-hf \
--rollout-batch-size 512 \
--n-samples-per-prompt 8
Use this workflow for training large MoE models like DeepSeek V3 or Qwen3-MoE.
# FP8 block scaling (recommended for stability)
export NVTE_FP8_BLOCK_SCALING_FP32_SCALES=1
export CUDA_DEVICE_MAX_CONNECTIONS=1
python train.py \
--actor-num-gpus-per-node 8 \
--rollout-num-gpus 8 \
--hf-checkpoint /path/to/deepseek-v3 \
--advantage-estimator grpo \
--tensor-model-parallel-size 8 \
--expert-model-parallel-size 4 \
--prompt-data /path/to/data.jsonl \
--num-rollout 3000
Use this workflow for maximum rollout throughput with EAGLE speculative decoding.
miles supports EAGLE speculative decoding via SGLang:
python train.py \
--actor-num-gpus-per-node 8 \
--hf-checkpoint /path/to/target-model \
--sglang-speculative-algorithm EAGLE \
--sglang-speculative-num-steps 3 \
--sglang-speculative-eagle-topk 1 \
--sglang-speculative-num-draft-tokens 4 \
--sglang-speculative-draft-model-path /path/to/draft-model \
--advantage-estimator grpo \
--prompt-data /path/to/data.jsonl
For online SFT of draft model during training:
--mtp-num-layers 1 \
--enable-mtp-training \
--mtp-loss-scaling-factor 0.2
Note : Online MTP training requires a torch dist checkpoint with MTP weights. Add --mtp-num-layers 1 during checkpoint conversion from HuggingFace.
miles inherits all slime arguments. See slime API Reference for the complete list.
--actor-num-nodes 1
--actor-num-gpus-per-node 8
--rollout-num-gpus 8
--rollout-num-gpus-per-engine 2
--colocate
--tensor-model-parallel-size 8
--pipeline-model-parallel-size 2
--expert-model-parallel-size 4 # MoE expert parallelism
--sglang-speculative-algorithm EAGLE
--sglang-speculative-num-steps 3
--sglang-speculative-eagle-topk 1
--sglang-speculative-num-draft-tokens 4
--sglang-enable-draft-weights-cpu-backup
--sglang-speculative-draft-model-path /your/draft/model/path
--mtp-num-layers 1
--enable-mtp-training
--mtp-loss-scaling-factor 0.2
The following features are documented in miles but specific CLI flags may vary. Consult the miles repository for latest configuration.
End-to-end FP8 sampling and training that eliminates quantization-induced discrepancy causing RL collapse in MoE models.
Records expert routing decisions during SGLang inference and replays them during Megatron training for bit-wise expert alignment.
How R3 Works :
sample.rollout_routed_expertsEnables single-machine deployment of 1TB+ models (e.g., on H200).
Memory Savings with INT4 :
| Model Size | BF16 VRAM | INT4 VRAM | Reduction |
|---|---|---|---|
| 70B | 140GB | 45GB | 3.1x |
| 235B | 470GB | 150GB | 3.1x |
| 671B | 1.3TB | 420GB | 3.1x |
miles achieves "exactly 0 KL divergence" between training and inference through:
torch.compile integrationmiles uses the same Sample dataclass as slime with the rollout_routed_experts field for MoE routing replay:
@dataclass
class Sample:
prompt: str | list[dict]
tokens: list[int]
response: str
reward: float | dict
loss_mask: list[int]
status: Status
metadata: dict
rollout_log_probs: list[float]
rollout_routed_experts: list[list[int]] # MoE routing for R3
See slime API Reference for the complete Sample definition.
Symptoms : Loss explodes, NaN values
Solutions :
export NVTE_FP8_BLOCK_SCALING_FP32_SCALES=1--lr 5e-7Symptoms : Low acceptance rate over time
Solutions :
--sglang-speculative-num-steps 2--sglang-enable-draft-weights-cpu-backupSymptoms : Policy divergence, reward collapse
Solutions :
--use-tis --tis-threshold 0.9| Family | Models | MoE Support |
|---|---|---|
| DeepSeek | R1, V3, V3.2 | Full |
| Qwen | 2, 2.5, 3 (including MoE) | Full |
| Llama | 3, 3.1, 3.3, 4 | Dense only |
| Gemma | 2, 3, 3N | Dense only |
| GLM | 4.5, 4.6, 4.7 | Dense only |
| MiniMax | M2, M2.1 | Full |
Weekly Installs
65
Repository
GitHub Stars
5.5K
First Seen
Feb 7, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
opencode55
codex54
cursor54
gemini-cli53
claude-code53
github-copilot52
超能力技能使用指南:AI助手技能调用优先级与工作流程详解
53,700 周安装
小红书数据分析平台 Xinhong Data:账户增长、内容表现、达人合作、行业趋势深度洞察
62 周安装
KeyID Agent Kit MCP:为AI代理提供免费电子邮件地址和27种工具
570 周安装
Medusa 管理员用户创建指南:使用 new-user Skill 快速配置后台账户
562 周安装
数据分析验证工具 - 分享前审查分析准确性、方法论和潜在偏见
581 周安装
UI/UX设计师专家技能:精通设计系统、无障碍设计与现代工作流程
569 周安装
Grimmory 自托管图书馆管理器:支持 EPUB/PDF/MOBI/CBZ 的 Docker 部署方案
588 周安装