yzlnew/infra-skills/slime-user-2
Claude Code and agent skill by yzlnew/infra-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide 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 troubleshooting SLIME workflows. Covers GRPO, GSPO, PPO, Reinforce++, multi-agent RL, VLM training, FSDP/Megatron backends, SGLang integration, dynamic sampling, and custom generation functions.
Install
npx vskill@latest install yzlnew/infra-skills/slime-user-2SKILL.md
SLIME User Guide
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.
Quick Start Workflow
For First-Time Users
- Environment Setup
- Use Docker:
docker pull slimerl/slime:latest - Or build from source: See
docs/en/get_started/quick_start.md - Hardware: Supports H100/H200, B200 series
- Download Model and Data
``bash hf download Qwen/Qwen3-4B --local-dir /root/Qwen3-4B hf download --repo-type dataset zhuzilin/dapo-math-17k --local-dir /root/dapo-math-17k ``
- Convert Weights (Megatron backend only)
``bash source scripts/models/qwen3-4B.sh PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \ ${MODEL_ARGS[@]} \ --hf-checkpoint /root/Qwen3-4B \ --save /root/Qwen3-4B_torch_dist ``
- Run Training
``bash bash scripts/run-qwen3-4B.sh ``
For Experienced Users
When user needs specific functionality:
- Multi-turn/tool calling: Read references/examples_reference.md Search-R1 section
- Custom reward models: See custom RM pattern in examples reference
- FSDP instead of Megatron: Use
--train-backend fsdp, skip weight conversion - Large-scale training: See multi-node examples (GLM-4.5, DeepSeek-R1)
- Source code exploration: Check references/source_code_reference.md
Documentation Navigation
SLIME has extensive documentation. Use this guide to find what you need quickly.
Essential Documentation (Read These First)
- Quick Start Guide:
docs/en/get_started/quick_start.md- Setup and first training run - Usage Guide:
docs/en/get_started/usage.md- Comprehensive parameter reference - Example Docs:
docs/en/examples/qwen3-4B.mdordocs/en/examples/glm4-9B.md
For detailed navigation of all documentation, see references/doc_navigation.md.
Common Tasks → Documentation Mapping
| Task | Documentation | |
|---|---|---|
| First-time setup | docs/en/get_started/quick_start.md | |
| Understanding parameters | docs/en/get_started/usage.md | |
| Basic training (8 GPUs) | docs/en/examples/qwen3-4B.md | |
| Multi-turn tool use | examples/search-r1/ | |
| Custom generation logic | docs/en/get_started/customization.md | |
| Multi-node training | docs/en/examples/glm4.5-355B-A32B.md | |
| FSDP backend | docs/en/get_started/usage.md (FSDP section) | |
| VLM training | examples/geo3k_vlm/ | |
| Troubleshooting | docs/en/get_started/qa.md |
Core Concepts
Training Loop
SLIME uses a "Rollout → Train" loop:
- Rollout: Generate responses using SGLang inference
- Reward: Compute rewards using reward model
- Train: Update model weights using Megatron/FSDP
- Repeat for
--num-rolloutiterations
Key Constraint
Resource Allocation Modes
Colocated (training and inference share GPUs):
Disaggregated (separate GPUs for training/inference):
Parameter Quick Reference
Essential Parameters
Model Loading:
--hf-checkpoint: HuggingFace model path (for SGLang and FSDP)--ref-load: Megatron reference model checkpoint--load: Megatron actor checkpoint (resume training)--save: Save path for checkpoints
Data:
--prompt-data: JSONL dataset path--input-key: Field name for prompts (default: "prompt")--label-key: Field name for labels (default: "label")--metadata-key: Field name for metadata (default: "metadata")--apply-chat-template: Apply tokenizer chat template
Rollout:
--rollout-batch-size: Prompts per rollout--n-samples-per-prompt: Responses per prompt--rollout-max-response-len: Max response length--rollout-temperature: Sampling temperature
Training:
--num-rollout: Total training iterations--num-steps-per-rollout: Optimizer steps per rollout (default: 1)--global-batch-size: Samples per optimizer step--advantage-estimator: RL algorithm (grpo, gspo, ppo, reinforce_plus_plus)
Reward Model:
--rm-type: Built-in RM type (e.g., "deepscaler")--custom-rm-path: Custom RM function path
Backends:
--train-backend: Training backend (megatron or fsdp)--rollout-num-gpus-per-engine: GPUs per SGLang engine (like tp_size)
For complete parameter reference, see docs/en/get_started/usage.md.
Common Workflows
1. Standard Single-Turn Training
Use example scripts as templates:
scripts/run-qwen3-4B.sh: Basic 8xH100 setupscripts/run-glm4-9B.sh: With dynamic sampling
Key sections in script:
2. Multi-Turn Tool Calling
For multi-turn scenarios (like Search-R1):
- Prepare Data with metadata:
``json { "question": "User query", "final_answer": "Expected answer", "metadata": "{\"session_id\": \"123\", \"tool_code\": \"...\"}" } ``
- Implement Custom Generation Function:
```python async def generate(args, sample: Sample, sampling_params) -> Sample: for turn in range(max_turns): # Generate action model_output = await call_sglang(...) sample.loss_mask += [1] * len(model_tokens) # Train on actions
# Execute tool tool_output = await execute_tool(...) sample.loss_mask += [0] * len(tool_tokens) # Mask tool outputs
if action == "answer": break
sample.tokens = prompt_tokens + response_tokens sample.response_length = len(response_tokens) return sample ```
- Configure Custom Functions:
``bash --custom-generate-function-path my_module.generate \ --custom-rm-path my_module.reward_func \ --metadata-key metadata ``
See examples/search-r1/ for complete example.
3. Dynamic Sampling (DAPO-style)
Filter low-quality samples during generation:
How it works:
- Samples 64 prompts (over-sampling)
- Filters groups based on reward diversity
- Keeps only 32 prompts × 8 samples that pass filter
- Automatically resamples if too many filtered out
4. FSDP Backend (No Weight Conversion)
Benefits:
- No HF → Megatron weight conversion needed
- Directly load HuggingFace checkpoints
- Simpler setup for supported models
See examples/geo3k_vlm/ and docs/en/get_started/usage.md FSDP section.
5. Multi-Node Training
- Start Ray cluster:
```bash # Head node ray start --head --node-ip-address ${MASTER_ADDR} --num-gpus 8
# Worker nodes ray start --address=${MASTER_ADDR}:6379 --num-gpus 8 ```
- Submit job:
``bash ray job submit --address="http://127.0.0.1:8265" \ --runtime-env-json='{"env_vars": {"PYTHONPATH": "/root/Megatron-LM/"}}' \ -- python3 train.py \ --actor-num-nodes 8 \ --actor-num-gpus-per-node 8 \ ... ``
See docs/en/examples/glm4.5-355B-A32B.md for large-scale example.
Customization Guide
Custom Reward Model
Implement async function:
Use with: --custom-rm-path module.path:my_reward_func
Custom Generation Function
Implement async function:
Use with: --custom-generate-function-path module.path:my_generate
Custom Dynamic Filter
Implement filter function:
Use with: --dynamic-sampling-filter-path module.path:my_filter
Examples Reference
For detailed examples and patterns, see references/examples_reference.md.
Quick finder:
- Basic math training:
scripts/run-qwen3-4B.sh - Multi-turn tool use:
examples/search-r1/ - Vision-language RL:
examples/geo3k_vlm/ - Large-scale MOE:
docs/en/examples/glm4.5-355B-A32B.md - Custom generation:
examples/search-r1/search_r1_logic.py - FSDP backend:
examples/geo3k_vlm/
Source Code Reference
For source code exploration, see references/source_code_reference.md.
Key files:
- Arguments:
slime/utils/arguments.py - Rollout:
slime/rollout/sglang_rollout.py - Sample type:
slime/utils/types.py - Reward models:
slime/rollout/rm_hub/ - Conversion tools:
tools/convert_hf_to_torch_dist.py
Troubleshooting
Common Issues
OOM during colocated training:
- Reduce
--sglang-mem-fraction-static(try 0.7 or 0.6) - Reduce
--max-tokens-per-gpu - Enable gradient checkpointing:
--recompute-granularity full
Mismatched batch sizes:
- Ensure:
rollout-batch-size × n-samples-per-prompt = global-batch-size × num-steps-per-rollout
Weight conversion errors:
- Check model config matches exactly (e.g.,
--rotary-base) - Use FSDP backend to skip conversion:
--train-backend fsdp
Multi-node communication issues:
- Set environment variables:
GLOO_SOCKET_IFNAME,NCCL_SOCKET_IFNAME - See
docs/en/get_started/quick_start.mdmulti-node section
SGLang concurrency issues:
- Limit concurrency:
--sglang-server-concurrency 160 - Increase CUDA graphs:
--sglang-cuda-graph-bs 1 2 4 8 $(seq 16 8 256)
For more troubleshooting, see docs/en/get_started/qa.md.
Additional Resources
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingslime-user/SKILL.md
Popularity
- Repository stars
- 100
- Repository forks
- 6
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 3 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/yzlnew/infra-skills/slime-user-2)