Skip to content

Commit 5001471

Browse files
authored
docs(slime): update docs for slime + sglang 0.5.13, remove useless sglang patches (#79)
* docs(slime): update docs for slime + sglang 0.5.13, remove useless sglang patches * docs(slime): remove the LinearCrossEntropyModule bug that no longer exists in the tested slime version
1 parent a86d31e commit 5001471

10 files changed

Lines changed: 260 additions & 1505 deletions

File tree

docs/site/scripts/gen_api.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
reward.md
2121
backends/
2222
slime/
23-
rollout.md
24-
traces.md
25-
rewards.md
26-
gateway.md
27-
sglang_token_ids.md
28-
verify_sglang_token_ids.md
23+
runner.md
2924
"""
3025
from __future__ import annotations
3126

@@ -98,32 +93,17 @@ class ModuleSpec:
9893
include=("RewardFunction",),
9994
),
10095
# --- Backends › slime --- #
101-
# Only the public user surface: the SlimeRunner entry point and the
102-
# two SGLang patch scripts. integration/rollout.py and
103-
# integration/rewards.py are load-bearing plugin paths but users
104-
# don't import them — SlimeRunner wires them into the job.
96+
# Only the public user surface: the SlimeRunner entry point.
97+
# integration/rollout.py and integration/rewards.py are load-bearing
98+
# plugin paths but users don't import them — SlimeRunner wires them
99+
# into the job.
105100
ModuleSpec(
106101
dotted_paths=("agentcore_rl_toolkit.backends.slime.runner",),
107102
out_path="backends/slime/runner.md",
108103
title="SlimeRunner",
109104
description="One Python entry point for slime-backed training.",
110105
include=("SlimeRunner",),
111106
),
112-
# Both patches consolidated onto one page.
113-
# sglang_token_ids exposes apply_patch (the public patch entry point).
114-
# verify_sglang_token_ids exposes main (the CLI contract, invoked via
115-
# `python -m ...verify_sglang_token_ids`). Everything else is
116-
# low-level monkey-patch machinery / internal check helpers.
117-
ModuleSpec(
118-
dotted_paths=(
119-
"agentcore_rl_toolkit.backends.slime.patches.sglang_token_ids",
120-
"agentcore_rl_toolkit.backends.slime.patches.verify_sglang_token_ids",
121-
),
122-
out_path="backends/slime/patches.md",
123-
title="SGLang patches",
124-
description="Apply + verify the SGLang token-IDs patch used by the slime backend.",
125-
include=("apply_patch", "main"),
126-
),
127107
]
128108

129109

docs/site/src/content/docs/api/backends/slime/patches.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

docs/site/src/content/docs/api/backends/slime/runner.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@ SlimeRunner(
4141
slime_dir: str = '/root/slime',
4242
megatron_dir: str = '/root/Megatron-LM',
4343

44+
# --- Optional: CUDA toolchain pinning ---
45+
cuda_home: str | None = None,
46+
4447
# --- Optional: ACR / toolkit (forwarded to slime via custom-config yaml) ---
4548
model_id: str = 'default',
4649
acr_timeout: int = 900,
4750
acr_tps_limit: int = 25,
4851
max_concurrent: int = 100,
52+
max_pool_connections: int = 100,
4953
gateway_port: int = 9090,
5054
reward_postprocessing: str = 'grpo',
55+
sglang_tool_call_parser: str = 'qwen',
56+
sglang_reasoning_parser: str | None = None,
57+
cumulative_token_mode: bool = False,
58+
renderer_family: str = 'auto',
59+
gateway_log_level: str = 'warning',
5160

5261
# --- Optional: training hyperparameters ---
5362
rollout_batch_size: int = 32,
@@ -60,6 +69,7 @@ SlimeRunner(
6069
weight_decay: float = 0.1,
6170
adam_beta2: float = 0.98,
6271
sglang_mem_fraction_static: float = 0.7,
72+
sglang_context_length: int | None = None,
6373
max_tokens_per_gpu: int = 9216,
6474

6575
# --- Wandb (opt-in; no defaults injected if unset) ---
@@ -95,6 +105,10 @@ via ``ray job submit``. Streams stdout/stderr to the parent process.
95105

96106
- `agent_runtime_arn` *(str)*
97107

108+
- `cuda_home` *(str | None)*
109+
110+
- `cumulative_token_mode` *(bool)*
111+
98112
- `data_path` *(str)*
99113

100114
- `eps_clip` *(float)*
@@ -105,12 +119,16 @@ via ``ray job submit``. Streams stdout/stderr to the parent process.
105119

106120
- `extra_flags` *(list[str])*
107121

122+
- `gateway_log_level` *(str)*
123+
108124
- `gateway_port` *(int)*
109125

110126
- `lr` *(float)*
111127

112128
- `max_concurrent` *(int)*
113129

130+
- `max_pool_connections` *(int)*
131+
114132
- `max_tokens_per_gpu` *(int)*
115133

116134
- `megatron_dir` *(str)*
@@ -125,6 +143,8 @@ via ``ray job submit``. Streams stdout/stderr to the parent process.
125143

126144
- `num_gpus` *(int)*
127145

146+
- `renderer_family` *(str)*
147+
128148
- `reward_postprocessing` *(str)*
129149

130150
- `rollout_batch_size` *(int)*
@@ -137,8 +157,14 @@ via ``ray job submit``. Streams stdout/stderr to the parent process.
137157

138158
- `s3_bucket` *(str)*
139159

160+
- `sglang_context_length` *(int | None)*
161+
140162
- `sglang_mem_fraction_static` *(float)*
141163

164+
- `sglang_reasoning_parser` *(str | None)*
165+
166+
- `sglang_tool_call_parser` *(str)*
167+
142168
- `slime_dir` *(str)*
143169

144170
- `tp_size` *(int)*

docs/site/src/content/docs/guides/slime-backend-setup.md

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,18 @@ description: Train an AgentCore Runtime-deployed agent with the SLIME training b
55

66
This doc describes how to train an AgentCore Runtime-deployed agent with the
77
[slime](https://github.com/THUDM/slime) training backend. The public
8-
user surface is exactly two things: the
8+
user surface is the
99
[`SlimeRunner`](/agentcore-rl-toolkit/api/backends/slime/runner/)
10-
class (for launching training) and the two SGLang
11-
[patch scripts](/agentcore-rl-toolkit/api/backends/slime/patches/)
12-
(applied once to the SGLang install).
10+
class for launching training.
1311

14-
For known issues (Megatron-LM regression on 32B, norm-epsilon
15-
mismatch, etc.) see
12+
For known issues (e.g. the norm-epsilon mismatch on
13+
Qwen2.5-32B-Instruct) see
1614
[slime troubleshooting](/agentcore-rl-toolkit/troubleshooting/slime/).
1715

1816
## Prerequisites
1917

20-
- Hardware and CUDA requirements: see
21-
[slime's README](https://github.com/THUDM/slime#installation) and the
22-
[slime docker README](https://github.com/THUDM/slime/blob/main/docker/README.md)
23-
for tested GPU configurations per model size.
24-
- Python 3.10+ and [`uv`](https://docs.astral.sh/uv/).
18+
- A GPU cluster with **CUDA>=12.9** installed.
19+
- Python 3.12+ and [`uv`](https://docs.astral.sh/uv/).
2520
- AWS credentials with permission to invoke an AgentCore Runtime and
2621
read/write an S3 bucket.
2722
- An AgentCore Runtime deployment of your agent — follow the
@@ -31,44 +26,52 @@ mismatch, etc.) see
3126
- An S3 bucket for rollout result delivery — required as the
3227
`s3_bucket` argument on `SlimeRunner` below.
3328

34-
## slime environment
29+
## Installation
3530

36-
Follow
37-
[slime's own installation docs](https://github.com/THUDM/slime#installation)
38-
— either the container path (`slimerl/slime:latest`) or a bare-metal
39-
install. Everything below runs inside this environment.
31+
Choose **one** of the two paths below to install slime, then install
32+
the toolkit into the same environment.
4033

41-
Inside the `slimerl/slime:latest` container, slime and Megatron-LM
42-
ship pre-installed at `/root/slime` and `/root/Megatron-LM` — use
43-
those paths for `slime_dir` / `megatron_dir` on `SlimeRunner`. For a
44-
bare-metal install, point at wherever you cloned slime + Megatron-LM.
34+
### Option A: Official slime docker
4535

46-
## Install the toolkit + apply patches
36+
Follow
37+
[slime's own installation docs](https://github.com/THUDM/slime#installation)
38+
and use the container image (`slimerl/slime:latest`). Inside the
39+
container, slime and Megatron-LM ship pre-installed at `/root/slime`
40+
and `/root/Megatron-LM` — use those paths for `slime_dir` /
41+
`megatron_dir` on `SlimeRunner`.
4742

48-
Inside the slime environment:
43+
Install the toolkit with the slime-backend extras inside the container:
4944

5045
```bash
51-
# From a clone of this repo
52-
cd /path/to/agentcore-rl-toolkit
53-
54-
# Install the toolkit plus the slime-backend extras
5546
uv pip install -e ".[slime]"
5647
```
5748

58-
Then apply the SGLang `token_ids` patch — it adds
59-
`prompt_token_ids` / `token_ids` fields to chat completion responses
60-
so the gateway can capture RL training trace data. The patch is idempotent:
49+
:::note
50+
We have only tested against official slime at commit
51+
[`fa3c990`](https://github.com/THUDM/slime/commit/fa3c990af6f18efd3fd9922698bf4bf4048d1263).
52+
:::
6153

62-
```bash
63-
python -m agentcore_rl_toolkit.backends.slime.patches.sglang_token_ids
54+
### Option B: Bare-metal install script
6455

65-
# Verify the patch round-trips under greedy decoding (any HF checkpoint
66-
# works; Qwen2.5-0.5B-Instruct is the fastest to download + load)
67-
python -m agentcore_rl_toolkit.backends.slime.patches.verify_sglang_token_ids \
68-
--model-path /path/to/Qwen2.5-0.5B-Instruct
69-
# Expect: "OK: 4/4 checks passed"
56+
Install slime and its heavyweight dependency stack (Megatron-LM,
57+
Transformer Engine, Apex, flash-attn, sglang, torch_memory_saver)
58+
with the provided script, which clones slime + Megatron-LM into the
59+
current directory and applies slime's official patches. Run it inside
60+
your activated python environment.
61+
62+
:::note
63+
Both CUDA 12.9 and CUDA 13 are supported. The following commands assume CUDA 13.0 is installed at `/usr/local/cuda-13.0`; adjust `CUDA_HOME` and `cu13` if yours differs.
64+
:::
65+
66+
```bash
67+
uv pip install -e ".[slime]"
68+
export CUDA_HOME=/usr/local/cuda-13.0
69+
bash src/agentcore_rl_toolkit/backends/slime/scripts/install_slime.sh cu13
7070
```
7171

72+
Point `slime_dir` / `megatron_dir` on `SlimeRunner` at the `slime` and
73+
`Megatron-LM` directories the script cloned.
74+
7275
## Prepare data
7376

7477
The training dataset is a JSONL file where each line is one rollout

docs/site/src/content/docs/troubleshooting/slime.md

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,11 @@ was validated against:
1414
| Component | Version / SHA |
1515
|---|---|
1616
| Instance type | 8 × NVIDIA H100 80GB HBM3 |
17-
| CUDA | `12.9` |
18-
| PyTorch | `2.9.1+cu129` |
19-
| Docker image | `slimerl/slime@sha256:0100c933f1f63e7c4acdb9ec575e769839d59de4a648551e09e3fe0e7885631b` (built 2026-04-28) |
20-
| slime | commit `f3e7bd7f3091d3be05c20977eefb31a785d6221d` (2026-04-28) |
21-
| SGLang | `v0.5.9` |
22-
| Megatron-LM | commit `3714d81d418c9f1bca4594fc35f9e8289f652862` ⚠ see note |
23-
24-
:::caution[Megatron-LM pin]
25-
The image bundles Megatron-LM at `1dcf0dafa` (~500 commits ahead of
26-
slime's stable pin), which breaks 32B training — see the
27-
[LinearCrossEntropyModule issue](#linearcrossentropymodule-parallelism-error-on-32b-or-any-model-with-untied-embeddings) below.
28-
We downgrade to `3714d81d` (slime's documented stable sha) via
29-
`git checkout` inside `/root/Megatron-LM`. The table above reflects
30-
the downgraded sha, not the one baked into the image.
31-
:::
32-
33-
## `LinearCrossEntropyModule` parallelism error on 32B (or any model with untied embeddings)
34-
35-
**Symptom:** During 32B training, the Megatron actor crashes with:
36-
37-
```
38-
ValueError: Cannot determine parallelism type for module 'LinearCrossEntropyModule'
39-
at weight 'output_layer.weight'.
40-
```
41-
42-
**Cause:** The Megatron-LM bundled in `slimerl/slime:latest` is
43-
several hundred commits ahead of the sha pinned in slime's docker
44-
README (`3714d81d`). Specifically, Megatron PR **#3226 "Reapply fix
45-
Linear CE Fusion"** (2026-02-04) replaced `ColumnParallelLinear`
46-
with a new `LinearCrossEntropyModule` that megatron-bridge's
47-
`AutoMapping` doesn't recognize. Models with tied embeddings (0.5B,
48-
3B, 7B) skip this code path; models with
49-
`--untie-embeddings-and-output-weights` (32B and up) hit it.
50-
51-
**Fix:** Inside the container, pin `/root/Megatron-LM` to the stable
52-
sha:
53-
54-
```bash
55-
cd /root/Megatron-LM
56-
# Stash any image-local patches first (can be restored later with `git stash pop`)
57-
git stash -u -m "slime local patches"
58-
git checkout 3714d81d418c9f1bca4594fc35f9e8289f652862
59-
# Clear pyc caches that reference the old code
60-
find . -name __pycache__ -type d -exec rm -rf {} + 2>/dev/null
61-
```
17+
| CUDA | `13.0` |
18+
| PyTorch | `2.11.0+cu130` |
19+
| slime | commit `fa3c990af6f18efd3fd9922698bf4bf4048d1263` |
20+
| SGLang | `0.5.13` |
21+
| Megatron-LM | commit `1dcf0dafa884ad52ffb243625717a3471643e087` |
6222

6323
## `--norm-epsilon` mismatch on Qwen2.5-32B-Instruct
6424

@@ -68,5 +28,5 @@ find . -name __pycache__ -type d -exec rm -rf {} + 2>/dev/null
6828

6929
**Fix:** Edit the slime model script to `--norm-epsilon 1e-6`, or
7030
pass an override through `SlimeRunner(extra_flags=["--norm-epsilon", "1e-6"])`.
71-
0.5B/3B/7B Instruct variants match their base-model norm epsilons,
72-
so this only affects 32B.
31+
Qwen2.5-0.5B / 1.5B / 3B / 7B Instruct variants match their base-model
32+
norm epsilons, so this only affects Qwen2.5-32B.

0 commit comments

Comments
 (0)