Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We also provide examples for some use cases not covered in the quick start guide
Arguments in Vime are divided into three categories:

1. **Megatron arguments**: Vime reads all arguments in Megatron. You can configure Megatron by passing arguments like `--tensor-model-parallel-size 2`.
2. **vLLM arguments**: vLLM server and engine options are exposed with a `--vllm-` prefix (for example, `--vllm-gpu-memory-utilization`). Router-related options use the `--router-` prefix. See [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py) for the full surface.
2. **vLLM arguments**: vLLM server and engine options are exposed with a `--vllm-` prefix (for example, `--vllm-gpu-memory-utilization`). Router options live under two prefixes: vllm-router's native options are passed with `--router-` (for example, `--router-policy round_robin`), while Vime-side orchestration knobs that tell Vime *where* the router lives use `--vllm-router-` (`--vllm-router-ip`, `--vllm-router-port`, `--vllm-router-request-timeout-secs`). See [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py) for the full surface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The router configuration flags are --router-ip, --router-port, and --router-request-timeout-secs (without the --vllm- prefix), as defined in slime/backends/vllm_utils/arguments.py. Please update the documentation to reflect the correct flags.

Suggested change
2. **vLLM arguments**: vLLM server and engine options are exposed with a `--vllm-` prefix (for example, `--vllm-gpu-memory-utilization`). Router options live under two prefixes: vllm-router's native options are passed with `--router-` (for example, `--router-policy round_robin`), while Vime-side orchestration knobs that tell Vime *where* the router lives use `--vllm-router-` (`--vllm-router-ip`, `--vllm-router-port`, `--vllm-router-request-timeout-secs`). See [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py) for the full surface.
2. **vLLM arguments**: vLLM server and engine options are exposed with a `--vllm-` prefix (for example, `--vllm-gpu-memory-utilization`). Router options live under the `--router-` prefix: vllm-router's native options are passed with `--router-` (for example, `--router-policy round_robin`), and Vime-side orchestration knobs that tell Vime *where* the router lives also use `--router-` (`--router-ip`, `--router-port`, `--router-request-timeout-secs`). See [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py) for the full surface.

3. **Framework-specific arguments**: Shared slime/Vime orchestration flags (rollout GPUs, data paths, RL algorithms, etc.). Please refer to [slime/utils/arguments.py](slime/utils/arguments.py).

`--rollout-num-gpus-per-engine` sets the tensor parallel size of each vLLM engine. The default rollout entry is `slime.rollout.vllm_rollout.generate_rollout`.
Expand Down Expand Up @@ -78,7 +78,6 @@ Vime is derived from slime. The following upstream resources and in-repo guides
- Upstream repository: [THUDM/slime](https://github.com/THUDM/slime)
- English docs in this repo: [docs/en/](docs/en/)
- Chinese docs in this repo: [docs/zh/](docs/zh/)
- vLLM backend design notes (Chinese): [docs/zh/advanced/slime_vllm_backend_design_v1.md](docs/zh/advanced/slime_vllm_backend_design_v1.md)

## FAQ & Acknowledgements

Expand Down
3 changes: 1 addition & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Vime 继承 slime 的广泛模型支持,包括:
Vime 的参数分为三类:

1. **Megatron 参数**:Vime 会读取 Megatron 中的全部参数,可通过传入如 `--tensor-model-parallel-size 2` 的方式配置 Megatron;
2. **vLLM 参数**:vLLM server 与 engine 相关选项以 `--vllm-` 为前缀(例如 `--vllm-gpu-memory-utilization`);路由相关选项使用 `--router-` 前缀。完整参数见 [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py)。
2. **vLLM 参数**:vLLM server 与 engine 相关选项以 `--vllm-` 为前缀(例如 `--vllm-gpu-memory-utilization`)。路由相关选项分两类前缀:vllm-router 自身的选项以 `--router-` 传入(例如 `--router-policy round_robin`),Vime 侧用于告诉 Vime *router 在哪里* 的编排参数则以 `--vllm-router-` 为前缀(`--vllm-router-ip`、`--vllm-router-port`、`--vllm-router-request-timeout-secs`)。完整参数见 [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py)。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The router configuration flags are --router-ip, --router-port, and --router-request-timeout-secs (without the --vllm- prefix), as defined in slime/backends/vllm_utils/arguments.py. Please update the documentation to reflect the correct flags.

Suggested change
2. **vLLM 参数**:vLLM server 与 engine 相关选项以 `--vllm-` 为前缀(例如 `--vllm-gpu-memory-utilization`)。路由相关选项分两类前缀:vllm-router 自身的选项以 `--router-` 传入(例如 `--router-policy round_robin`),Vime 侧用于告诉 Vime *router 在哪里* 的编排参数则以 `--vllm-router-` 为前缀(`--vllm-router-ip``--vllm-router-port``--vllm-router-request-timeout-secs`)。完整参数见 [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py)
2. **vLLM 参数**:vLLM server 与 engine 相关选项以 `--vllm-` 为前缀(例如 `--vllm-gpu-memory-utilization`)。路由相关选项统一使用 `--router-` 前缀:vllm-router 自身的选项以 `--router-` 传入(例如 `--router-policy round_robin`),Vime 侧用于告诉 Vime *router 在哪里* 的编排参数也以 `--router-` 为前缀(`--router-ip``--router-port``--router-request-timeout-secs`)。完整参数见 [slime/backends/vllm_utils/arguments.py](slime/backends/vllm_utils/arguments.py)

3. **框架参数**:与 slime/Vime 编排相关的开关(rollout GPU、数据路径、RL 算法等),见 [slime/utils/arguments.py](slime/utils/arguments.py)。

`--rollout-num-gpus-per-engine` 对应每个 vLLM engine 的 tensor parallel size。默认 rollout 入口为 `slime.rollout.vllm_rollout.generate_rollout`。
Expand Down Expand Up @@ -78,7 +78,6 @@ Vime 由 slime 衍生而来。以下上游资源与本仓库文档仍沿用 slim
- 上游仓库:[THUDM/slime](https://github.com/THUDM/slime)
- 本仓库英文文档:[docs/en/](docs/en/)
- 本仓库中文文档:[docs/zh/](docs/zh/)
- vLLM 后端设计说明:[docs/zh/advanced/slime_vllm_backend_design_v1.md](docs/zh/advanced/slime_vllm_backend_design_v1.md)

## 常见 Q&A 与致谢

Expand Down
Binary file removed docs/_static/image/arch.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/_static/image/sglang_config.png
Binary file not shown.
Binary file added docs/_static/image/vllm_config.png

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in the drawn image.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/en/advanced/fault-tolerance.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To enable the fault tolerance function in slime, please set `--use-fault-toleran

## Rollout Fault Tolerance

During the rollout process, slime periodically sends heartbeat requests (`/health_generate`) to all SGLang servers. If a heartbeat times out, that SGLang server will be stopped. After the current rollout round is complete, the server will be restarted and its parameters will be correctly updated.
During the rollout process, slime periodically sends heartbeat requests (`/health`) to all vLLM engines. If a heartbeat times out, that vLLM engine will be stopped. After the current rollout round is complete, the engine will be restarted and its parameters will be correctly updated.

- `--rollout-health-check-first-wait`: Since some large MoE models require compilation on their first run, slime will wait for `rollout_health_check_first_wait` seconds before the first rollout to start sending heartbeats. Defaults to 300s.
- `--rollout-health-check-interval`: The interval between heartbeat checks. Defaults to 10s.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/advanced/low-precision.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Here's a quick explanation of how FP8 training is currently implemented in slime

2. Training: During training, weights and activations are quantized online to nvfp8 format, and cuBLAS FP8 GEMM is called for various GEMM computations in forward and backward passes.

3. Weight updates: During RL weight updates, Megatron first dequantizes FP8 weights to bf16 format, then slime quantizes these bf16 weights to fp8 format and sends them to sglang. (This additional dequantization and quantization is not elegant, but we haven't modified the interface yet for framework compatibility.)
3. Weight updates: During RL weight updates, Megatron first dequantizes FP8 weights to bf16 format, then slime quantizes these bf16 weights to fp8 format and sends them to vLLM. (This additional dequantization and quantization is not elegant, but we haven't modified the interface yet for framework compatibility.)

4. Save checkpoint: Similar to weight updates, if checkpoints need to be saved from the training engine, they will also be dequantized back to bf16 and saved to `torch_dist` format checkpoints.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/advanced/megatron-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`--megatron-config-path` is a YAML-based configuration system for applying role-specific overrides on top of the shared Megatron CLI arguments. Today it is mainly intended for PPO actor / critic configuration.

Unlike `--sglang-config`, `--megatron-config-path` does not manage deployment, routing, or GPU orchestration. Its only job is to decide which training arguments each role should finally use.
Unlike `--vllm-config`, `--megatron-config-path` does not manage deployment, routing, or GPU orchestration. Its only job is to decide which training arguments each role should finally use.

---

Expand Down
16 changes: 8 additions & 8 deletions docs/en/advanced/on-policy-distillation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ On-policy distillation (OPD) enables a student model to learn from a larger teac
| Argument | Description |
|----------|-------------|
| `--use-opd` | Enable on-policy distillation. Required flag to use OPD. |
| `--opd-type` | Type of OPD: `sglang` or `megatron`. Required when `--use-opd` is set. |
| `--opd-type` | Type of OPD: `vllm` or `megatron`. Required when `--use-opd` is set. |
| `--opd-kl-coef` | OPD KL penalty coefficient (default: 1.0). Controls the weight of the distillation signal relative to the RL advantage. |
| `--opd-teacher-load` | Path to teacher Megatron checkpoint. **Required** when `--opd-type=megatron`, **must not be set** when `--opd-type=sglang`. |
| `--opd-teacher-load` | Path to teacher Megatron checkpoint. **Required** when `--opd-type=megatron`, **must not be set** when `--opd-type=vllm`. |
| `--opd-teacher-ckpt-step` | Optional checkpoint step for teacher model. |

## How It Works
Expand All @@ -26,26 +26,26 @@ This means OPD can be combined with any advantage estimator, including GRPO, PPO

## Two Teacher Modes

### SGLang Mode (`--opd-type sglang`)
### vLLM Mode (`--opd-type vllm`)

The teacher runs on an external SGLang server. Teacher log-probs are obtained during the rollout phase.
The teacher runs on an external vLLM server. Teacher log-probs are obtained during the rollout phase.

**When to use**: The teacher has a different architecture from the student, or the teacher is too large to load alongside the training model.

**How it works**:
1. An external SGLang server runs the teacher model.
1. An external vLLM server runs the teacher model.
2. During rollout, the custom reward function (`slime.rollout.on_policy_distillation.reward_func`) sends each sample to the teacher server to obtain token-level log-probs.
3. The custom post-processing function (`slime.rollout.on_policy_distillation.post_process_rewards`) trims the teacher log-probs to the response span and stores them in `sample.teacher_log_probs`.
4. During training, the KL penalty is computed from the stored teacher log-probs and applied to advantages.

**Configuration**:
```bash
--use-opd
--opd-type sglang
--opd-type vllm
--opd-kl-coef 1.0
--custom-rm-path slime.rollout.on_policy_distillation.reward_func
--custom-reward-post-process-path slime.rollout.on_policy_distillation.post_process_rewards
--rm-url http://<TEACHER_IP>:<TEACHER_PORT>/generate
--rm-url http://<TEACHER_IP>:<TEACHER_PORT>/inference/v1/generate
```

### Megatron Mode (`--opd-type megatron`)
Expand Down Expand Up @@ -73,7 +73,7 @@ The teacher model is loaded directly into Megatron via `--opd-teacher-load`. Tea

Complete example scripts are provided in `examples/on_policy_distillation/`:

### SGLang Teacher
### vLLM Teacher

```bash
# 1. Download models and data
Expand Down
21 changes: 10 additions & 11 deletions docs/en/advanced/reproducibility.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# Reproducibility

Reproducibility is a bedrock of scientific progress. 通过结合 SGLang 提供的 [确定性推理](https://lmsys.org/blog/2025-09-22-sglang-deterministic/) 和 Megatron-LM 的确定性模式,slime 可以提供完全确定性(bitwise)的实验复现能力。

为了开启确定性训练,你需要通过 `pip uninstall flash_attn_3 -y` 卸载 flash attention 3,并设置:
Reproducibility is a bedrock of scientific progress. By combining vLLM's [batch-invariant deterministic inference](https://vllm.ai/blog/2025-11-10-bitwise-consistent-train-inference) with Megatron-LM's deterministic mode, slime supports bitwise experiment reproduction.

To enable deterministic training, you need to first uninstall the flash attention 3 in the docker with `pip uninstall flash_attn_3 -y` and set:
```bash
# sglang config
--sglang-enable-deterministic-inference
--sglang-attention-backend flashinfer
# vLLM config
--vllm-enable-deterministic-inference
--vllm-attention-backend flashinfer

# megatron config
--deterministic-mode
```

以及设置如下环境变量:
And set the following environment variables:

```bash
"env_vars": {
Expand All @@ -24,9 +23,9 @@ Reproducibility is a bedrock of scientific progress. 通过结合 SGLang 提供
}
```

我们提供了一个完全确定性的,用 Qwen2.5 0.5B 训练 GSM8K 的脚本。
Here we provide the script to do RL training on Qwen2.5 0.5B model and GSM8K dataset with full deterministic.

可以用如下脚本初始化训练数据和 ckpt:
For data and checkpoint preparation, please run:

```bash
# download
Expand All @@ -43,10 +42,10 @@ PYTHONPATH=/root/Megatron-LM/ python \
--save /root/Qwen2.5-0.5B-Instruct_torch_dist/
```

可以使用如下脚本进行训练:
And to run training,

```bash
bash script/run-qwen2.5-0.5B-reproducibility.sh
```

这个 PR 中记录了 wandb 的截图 [pull#370](https://github.com/THUDM/slime/pull/370).
For screen shots of the wandb, please refer to [pull#370](https://github.com/THUDM/slime/pull/370).
25 changes: 17 additions & 8 deletions docs/en/advanced/speculative-decoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ Speculative decoding is a key optimization for speeding up rollouts. Instead of

## Accelerating Inference with Speculative Decoding

For models with MTP layers (e.g., GLM-4.7, DeepSeek-V3/R1), simply add:
vLLM exposes speculative decoding as a single JSON config (`SpeculativeConfig`),
which slime forwards via `--vllm-speculative-config`. For models with MTP layers
(e.g., GLM-4.7, DeepSeek-V3/R1), pass:

```bash
--sglang-speculative-algorithm EAGLE
--sglang-speculative-num-steps 3
--sglang-speculative-eagle-topk 1
--sglang-speculative-num-draft-tokens 4
--vllm-speculative-config '{"method":"eagle","num_speculative_tokens":3}'
```

If you want to use a separately trained draft model (e.g., one trained with [SpecForge](https://docs.sglang.ai/SpecForge/)), also set:
To use a separately trained draft model, set `model` (and optionally `draft_tensor_parallel_size`)
in the same JSON:

```bash
--sglang-speculative-draft-model-path /your/draft/model/path
--vllm-speculative-config '{"method":"eagle","num_speculative_tokens":3,"model":"/your/draft/model/path"}'
```

For detailed parameter meanings and configuration, see SGLang’s speculative decoding [documentation](https://docs.sglang.ai/advanced_features/speculative_decoding.html).
To train a draft model from scratch, see [TorchSpec](https://github.com/lightseekorg/TorchSpec)
and [vllm-project/speculators](https://github.com/vllm-project/speculators).
TorchSpec provides torch-native, disaggregated draft training.
Speculators supports EAGLE-3, DFlash, and MTP-style drafts, ships pre-trained
checkpoints on Hugging Face (see the `RedHatAI/*-speculator.*` collection), and
saves drafts in a format that `vllm serve <speculator_model>` can deploy directly.

For the full list of `SpeculativeConfig` fields (including `disable_by_batch_size`,
`acceptance_method`, draft TP, etc.), see vLLM's speculative-decoding
[documentation](https://docs.vllm.ai/en/latest/features/speculative_decoding/).

## Online SFT for the Draft Model

Expand Down
Loading
Loading