$npx -y skills add yzlnew/infra-skills --skill slime-userGuide for using SLIME (LLM post-training framework for RL Scaling). Use when working with SLIME for reinforcement learning training of language models, including setup, configuration, training execution, multi-turn interactions, custom reward models, tool calling scenarios, or tr
| 1 | # SLIME User Guide |
| 2 | |
| 3 | SLIME is an LLM post-training framework for RL Scaling developed by THUDM. It supports various RL algorithms (GRPO, GSPO, PPO, Reinforce++), multiple training backends (Megatron, FSDP), and advanced features like multi-turn interactions, tool calling, and dynamic sampling. |
| 4 | |
| 5 | ## Quick Start Workflow |
| 6 | |
| 7 | ### For First-Time Users |
| 8 | |
| 9 | 1. **Environment Setup** |
| 10 | - Use Docker: `docker pull slimerl/slime:latest` |
| 11 | - Or build from source: See `docs/en/get_started/quick_start.md` |
| 12 | - Hardware: Supports H100/H200, B200 series |
| 13 | |
| 14 | 2. **Download Model and Data** |
| 15 | ```bash |
| 16 | hf download Qwen/Qwen3-4B --local-dir /root/Qwen3-4B |
| 17 | hf download --repo-type dataset zhuzilin/dapo-math-17k --local-dir /root/dapo-math-17k |
| 18 | ``` |
| 19 | |
| 20 | 3. **Convert Weights** (Megatron backend only) |
| 21 | ```bash |
| 22 | source scripts/models/qwen3-4B.sh |
| 23 | PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \ |
| 24 | ${MODEL_ARGS[@]} \ |
| 25 | --hf-checkpoint /root/Qwen3-4B \ |
| 26 | --save /root/Qwen3-4B_torch_dist |
| 27 | ``` |
| 28 | |
| 29 | 4. **Run Training** |
| 30 | ```bash |
| 31 | bash scripts/run-qwen3-4B.sh |
| 32 | ``` |
| 33 | |
| 34 | ### For Experienced Users |
| 35 | |
| 36 | When user needs specific functionality: |
| 37 | - **Multi-turn/tool calling**: Read [references/examples_reference.md](references/examples_reference.md) Search-R1 section |
| 38 | - **Custom reward models**: See custom RM pattern in examples reference |
| 39 | - **FSDP instead of Megatron**: Use `--train-backend fsdp`, skip weight conversion |
| 40 | - **Large-scale training**: See multi-node examples (GLM-4.5, DeepSeek-R1) |
| 41 | - **Source code exploration**: Check [references/source_code_reference.md](references/source_code_reference.md) |
| 42 | |
| 43 | ## Documentation Navigation |
| 44 | |
| 45 | SLIME has extensive documentation. Use this guide to find what you need quickly. |
| 46 | |
| 47 | ### Essential Documentation (Read These First) |
| 48 | 1. **Quick Start Guide**: `docs/en/get_started/quick_start.md` - Setup and first training run |
| 49 | 2. **Usage Guide**: `docs/en/get_started/usage.md` - Comprehensive parameter reference |
| 50 | 3. **Example Docs**: `docs/en/examples/qwen3-4B.md` or `docs/en/examples/glm4-9B.md` |
| 51 | |
| 52 | For detailed navigation of all documentation, see [references/doc_navigation.md](references/doc_navigation.md). |
| 53 | |
| 54 | ### Common Tasks → Documentation Mapping |
| 55 | |
| 56 | | Task | Documentation | |
| 57 | |------|---------------| |
| 58 | | First-time setup | `docs/en/get_started/quick_start.md` | |
| 59 | | Understanding parameters | `docs/en/get_started/usage.md` | |
| 60 | | Basic training (8 GPUs) | `docs/en/examples/qwen3-4B.md` | |
| 61 | | Multi-turn tool use | `examples/search-r1/` | |
| 62 | | Custom generation logic | `docs/en/get_started/customization.md` | |
| 63 | | Multi-node training | `docs/en/examples/glm4.5-355B-A32B.md` | |
| 64 | | FSDP backend | `docs/en/get_started/usage.md` (FSDP section) | |
| 65 | | VLM training | `examples/geo3k_vlm/` | |
| 66 | | Troubleshooting | `docs/en/get_started/qa.md` | |
| 67 | |
| 68 | ## Core Concepts |
| 69 | |
| 70 | ### Training Loop |
| 71 | SLIME uses a "Rollout → Train" loop: |
| 72 | 1. **Rollout**: Generate responses using SGLang inference |
| 73 | 2. **Reward**: Compute rewards using reward model |
| 74 | 3. **Train**: Update model weights using Megatron/FSDP |
| 75 | 4. Repeat for `--num-rollout` iterations |
| 76 | |
| 77 | ### Key Constraint |
| 78 | ``` |
| 79 | rollout-batch-size × n-samples-per-prompt = global-batch-size × num-steps-per-rollout |
| 80 | ``` |
| 81 | |
| 82 | ### Resource Allocation Modes |
| 83 | |
| 84 | **Colocated** (training and inference share GPUs): |
| 85 | ```bash |
| 86 | --actor-num-nodes 1 \ |
| 87 | --actor-num-gpus-per-node 8 \ |
| 88 | --colocate \ |
| 89 | --sglang-mem-fraction-static 0.7 |
| 90 | ``` |
| 91 | |
| 92 | **Disaggregated** (separate GPUs for training/inference): |
| 93 | ```bash |
| 94 | --actor-num-nodes 1 \ |
| 95 | --actor-num-gpus-per-node 4 \ |
| 96 | --rollout-num-gpus 4 |
| 97 | ``` |
| 98 | |
| 99 | ## Parameter Quick Reference |
| 100 | |
| 101 | ### Essential Parameters |
| 102 | |
| 103 | **Model Loading**: |
| 104 | - `--hf-checkpoint`: HuggingFace model path (for SGLang and FSDP) |
| 105 | - `--ref-load`: Megatron reference model checkpoint |
| 106 | - `--load`: Megatron actor checkpoint (resume training) |
| 107 | - `--save`: Save path for checkpoints |
| 108 | |
| 109 | **Data**: |
| 110 | - `--prompt-data`: JSONL dataset path |
| 111 | - `--input-key`: Field name for prompts (default: "prompt") |
| 112 | - `--label-key`: Field name for labels (default: "label") |
| 113 | - `--metadata-key`: Field name for metadata (default: "metadata") |
| 114 | - `--apply-chat-template`: Apply tokenizer chat template |
| 115 | |
| 116 | **Rollout**: |
| 117 | - `--rollout-batch-size`: Prompts per rollout |
| 118 | - `--n-samples-per-prompt`: Responses per prompt |
| 119 | - `--rollout-max-response-len`: Max response length |
| 120 | - `--rollout-temperature`: Sampling temperature |
| 121 | |
| 122 | **Training**: |
| 123 | - `--num-rollout`: Total training iterations |
| 124 | - `--num-steps-per-rollout`: Optimizer steps per rollout (default: 1) |
| 125 | - `--global-batch-size`: Samples per optimizer step |
| 126 | - `--advantage-e |