Skip to content

Commit 8255c9b

Browse files
authored
[doc] add example doc to the website (#267)
1 parent d2e14ad commit 8255c9b

File tree

16 files changed

+89
-23
lines changed

16 files changed

+89
-23
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,5 @@ local/
188188
.idea
189189
*.iml
190190

191-
glm/
191+
glm/
192+
_examples_synced/

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
## Quick Start
3939

4040
For a comprehensive quick start guide covering environment setup, data preparation, training startup, and key code analysis, please refer to:
41-
- [Quick Start Guide](./docs/en/quick_start.md)
41+
- [Quick Start Guide](./docs/en/get_started/quick_start.md)
4242

4343
We also provides examples for some usecases not covered in the quick start guide, please check [examples](examples/).
4444

@@ -50,7 +50,7 @@ Arguments in slime are divided into three categories:
5050
2. **SGLang arguments**: All arguments for the installed SGLang are supported. These arguments must be prefixed with `--sglang-`. For example, `--mem-fraction-static` should be passed as `--sglang-mem-fraction-static`.
5151
3. **slime-specific arguments**: Please refer to: [slime/utils/arguments.py](slime/utils/arguments.py)
5252

53-
For complete usage instructions, please refer to the [Usage Documentation](docs/en/usage.md).
53+
For complete usage instructions, please refer to the [Usage Documentation](docs/en/get_started/usage.md).
5454

5555
## Developer Guide
5656

@@ -63,9 +63,9 @@ For complete usage instructions, please refer to the [Usage Documentation](docs/
6363
pre-commit install
6464
```
6565

66-
- For debugging tips, please refer to the [Debugging Guide](docs/en/debug.md)
66+
- For debugging tips, please refer to the [Debugging Guide](docs/en/developer_guide/debug.md)
6767

6868
## FAQ & Acknowledgements
6969

70-
- For frequently asked questions, please see the [Q\&A](docs/en/qa.md)
70+
- For frequently asked questions, please see the [Q\&A](docs/en/get_started/qa.md)
7171
- Special thanks to the following projects & communities: SGLang, Megatron‑LM, mbridge, OpenRLHF, veRL, Pai-Megatron-Patch and others.

README_zh.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
有关环境配置、数据准备、训练启动和关键代码分析的完整快速开始指南,请参考:
3333

34-
- [快速开始指南](./docs/zh/quick_start.md)
34+
- [快速开始指南](./docs/zh/get_started/quick_start.md)
3535

3636
我还还额外提供了一些使用样例,请参考样例目录:[examples](examples/)
3737

@@ -43,7 +43,7 @@
4343
2. **sglang 参数**:支持环境中安装的 sglang 的所有参数,这些参数需要以 `--sglang` 起始,例如 `--mem-fraction-static` 需要通过 `--sglang-mem-fraction-static` 传入。
4444
3. **slime 自身的参数**:请见:[slime/utils/arguments.py](slime/utils/arguments.py)
4545

46-
完整使用说明请查阅 [使用文档](docs/zh/usage.md)
46+
完整使用说明请查阅 [使用文档](docs/zh/get_started/usage.md)
4747

4848
## 开发指南
4949

@@ -56,9 +56,9 @@
5656
pre-commit install
5757
```
5858

59-
- 调试技巧请参考 [debug 指南](docs/zh/debug.md)
59+
- 调试技巧请参考 [debug 指南](docs/zh/developer_guide/debug.md)
6060

6161
## 常见 Q&A 与致谢
6262

63-
- 常见问题请见 [Q&A](docs/zh/qa.md)
63+
- 常见问题请见 [Q&A](docs/zh/get_started/qa.md)
6464
- 特别感谢以下项目 & 社区:SGLang、Megatron‑LM、mbridge、OpenRLHF、veRL、Pai-Megatron-Patch 等。

docs/conf.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import sys
33
from datetime import datetime
4+
from pathlib import Path
5+
import shutil
46

57
sys.path.insert(0, os.path.abspath("../.."))
68

@@ -130,8 +132,67 @@
130132
html_css_files = ["css/custom_log.css"]
131133

132134

135+
def _sync_examples(app):
136+
"""Sync top-level examples into language-specific doc trees.
137+
138+
Policy:
139+
- README.md -> English docs/en/_examples_synced/<example>/README.md
140+
- README_zh.md -> Chinese docs/zh/_examples_synced/<example>/README_zh.md
141+
- If a language-specific README missing, that example is simply skipped for that language.
142+
"""
143+
docs_root = Path(__file__).resolve().parent
144+
src_dir = docs_root.parent / "examples"
145+
if not src_dir.exists():
146+
return
147+
148+
lang_cfgs = {
149+
"en": {
150+
"dir": docs_root / "en",
151+
"readme_name": "README.md",
152+
"title": "External Examples (Auto Synced)",
153+
"note": "This section is auto-generated from repository examples/ by copying README.md of each example.",
154+
},
155+
"zh": {
156+
"dir": docs_root / "zh",
157+
# primary preferred name; will fallback to README.md
158+
"readme_name": "README_zh.md",
159+
"title": "外部示例 (自动同步)",
160+
"note": "本节由构建时自动从仓库 examples/ 复制示例文档生成;优先使用 README_zh.md,若不存在则回退到 README.md。",
161+
},
162+
}
163+
164+
for lang, cfg in lang_cfgs.items():
165+
lang_dir = cfg["dir"]
166+
if not lang_dir.exists():
167+
continue
168+
out_dir = lang_dir / "_examples_synced"
169+
if out_dir.exists():
170+
shutil.rmtree(out_dir)
171+
out_dir.mkdir(parents=True, exist_ok=True)
172+
173+
entries = [] # (example_name, readme_rel_path)
174+
for d in sorted(src_dir.iterdir()):
175+
if not d.is_dir():
176+
continue
177+
# language-specific selection with fallback for zh
178+
if lang == "zh":
179+
primary = d / cfg["readme_name"] # README_zh.md
180+
fallback = d / "README.md"
181+
candidate = primary if primary.exists() else fallback
182+
else:
183+
candidate = d / cfg["readme_name"]
184+
if not candidate.exists():
185+
continue # skip entirely if nothing suitable
186+
target_dir = out_dir / d.name
187+
target_dir.mkdir(parents=True, exist_ok=True)
188+
shutil.copy2(candidate, target_dir / "README.md")
189+
entries.append((d.name, f"_examples_synced/{d.name}/README.md"))
190+
191+
133192
def setup(app):
134193
app.add_css_file("css/custom_log.css")
194+
# ensure examples are synced before reading source files
195+
app.connect("builder-inited", _sync_examples)
135196

136197

137198
myst_enable_extensions = [

docs/en/advanced/speculative-decoding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ For details on parameter meanings and configuration, see the [SGLang speculative
4242
2. Specify a broader range for `--sglang-cuda-graph-bs` to avoid batch sizes that trigger CUDA graph padding.
4343
3. Disable CUDA graph (not recommended due to significant performance loss).
4444
4. **Notice:** Disabling CUDA graph padding with `--sglang-disable-cuda-graph-padding` is currently ineffective for speculative decoding. See [SGLang `cuda_graph_runner.py`](tbd).
45-
* For debugging, enable Slime’s `--debug-rollout-only` flag to isolate rollout behavior from parameter updates or model offloading.
45+
* For debugging, enable slime’s `--debug-rollout-only` flag to isolate rollout behavior from parameter updates or model offloading.
4646

4747
```bash
4848
# If speculative decoding fails, this can help debug

docs/en/examples/qwen3-4b-base-openhermes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SFT Qwen3-4B-Base with OpenHermes-2.5
1+
# SFT Qwen3-4B-Base
22

33

44
## Environment Preparation

docs/en/get_started/quick_start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This document will guide you through setting up the environment and getting star
77

88
Since slime may contain temporary patches for sglang/megatron, to avoid potential environment configuration issues, we strongly recommend **users to use our latest Docker image**, which comes pre-configured with all dependencies.
99

10-
- For scenarios where Docker is not convenient, please refer to [build_conda.sh](./../../build_conda.sh);
11-
- For AMD support, please refer to [AMD Usage Tutorial](./amd_tutorial.md).
10+
- For scenarios where Docker is not convenient, please refer to [build_conda.sh](https://github.com/THUDM/slime/blob/main/build_conda.sh);
11+
- For AMD support, please refer to [AMD Usage Tutorial](../platform_support/amd_tutorial.md).
1212

1313
### Pull and Start Docker Container
1414

docs/en/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ slime is an LLM post-training framework for RL scaling, providing two core capab
3939
:caption: Other Usage
4040

4141
examples/qwen3-4b-base-openhermes.md
42-
42+
_examples_synced/search-r1/README.md
43+
_examples_synced/fully_async/README.md
44+
_examples_synced/retool/README.md
4345

4446
.. toctree::
4547
:maxdepth: 1

docs/en/platform_support/amd_tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
## Introduction
77

8-
If you are running Slime on AMD's Instinct, please refer to the following materials. This tutorial will explain how to set up the development environment (Docker), use the modified ROCm dependencies, and provide an example for running the experiments. The current rocm docker only support AMD's MI300 and MI325 GPUs.
8+
If you are running slime on AMD's Instinct, please refer to the following materials. This tutorial will explain how to set up the development environment (Docker), use the modified ROCm dependencies, and provide an example for running the experiments. The current rocm docker only support AMD's MI300 and MI325 GPUs.
99

1010

1111
<!-- First, you need to configure the slime runtime environment according to the [Readme](../../README.md) documentation and cd to the slime project directory. -->

docs/zh/auto_examples.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(构建时自动覆盖)
2+
===========================
3+
4+
.. note:: 初次构建前此文件为占位;实际内容会在 Sphinx 构建阶段自动生成。

0 commit comments

Comments
 (0)