็™ป้Œฒใ—ใฆๆ‹›ๅพ…ใƒชใƒณใ‚ฏใ‚’ๅ…ฑๆœ‰ใ™ใ‚‹ใจใ€ๅ‹•็”ปๅ†็”Ÿๅ ฑ้…ฌใจ็ดนไป‹ๅ ฑ้…ฌใ‚’็ฒๅพ—ใงใใพใ™ใ€‚

Zhihu Frontier
@ZhihuFrontier
๐Ÿš€Bringing China's AI & tech trends, voices and perspectives to the global stage. โšก๏ธPowered by ็ŸฅไนŽ/ China's leading knowledge community.
ๅ‚ๅŠ  June 2025
167 ใƒ•ใ‚ฉใƒญใƒผไธญ    11K ใƒ•ใ‚กใƒณ
๐Ÿงต Slime: The Most Elegant & Comfortable RL Training Framework Ever A deep dive into why Slime redefines LLM RL training with clean architecture & production-grade engineering โœจ Insights from Zhihu contributor Xavier ๐Ÿ“Œ What Is Slime In One Sentence? Slime is a streamlined RL training framework built on SGLang (Inference) + Megatron (Training) + Ray (Orchestration).Itโ€™s not just a simple stackโ€”it stitches top-tier open-source projects together with perfectly polished interfaces.Core design philosophy: Fully decouple training & inference, connected via streamlined data flow. Compared to veRL / OpenRLHF: โœ… Native SGLang backend โ†’ high concurrency, continuous batching, prefix caching (no messy vLLM wrapper) โœ… Native Megatron backend โ†’ full TP/PP/EP/CP parallelism, seamless MoE training โœ… Lightweight Ray scheduling โ†’ Placement Group + Remote Actor (no bloated Ray Train) ๐Ÿ—๏ธ Global Architecture: 3 Modules, One Pipeline ๐Ÿ–ฅ๏ธ Ray Cluster Core Workflow:Data Buffer (Prompt Manager โ†’ Buffer & Filter)โ†”๏ธ Rollout (SGLang โ†’ Sampling + RM Scoring + Filtering)โ†”๏ธ Training (Megatron โ†’ Actor/Critic + PPO/GRPO) ๐Ÿ” Simplified Core Training Loop 1.Allocate GPU resources via Placement Group 2.Launch SGLang rollout engine 3.Initialize Megatron Actor/Critic models 4.Sync initial weights to SGLang 5.Repeat 3-beat cycle: Generate (SGLang) โ†’ Train (Megatron) โ†’ Sync Weights ๐ŸŽฏElegance = ultra-simple top-level logic, all complexity encapsulated inside modules ๐ŸŽ›๏ธ 4 Core Design Flexibilities โš™๏ธ Resource Scheduling: Colocate (shared GPU) / Disaggregate (separate GPU pools) ๐Ÿ”„ Training Mode: Synchronous / Asynchronous training ๐Ÿงช Sampling Logic: Standard sampling / Over-sampling / Multi-turn tool calling ๐Ÿค– Model Type: Dense / MoE, full tensor/pipeline/context parallel support ๐Ÿ”ง Plug & Play Customization (All Extensible) Slime lets you customize every component via CLI paramsโ€”no need to fork the repo ๐Ÿ› ๏ธ Key Customization Points โœ… Custom Reward Model: Write an async func to define your own reward logic (easiest entry) โœ… Custom Generate Func: Control multi-turn dialogue, tool calling & external API integration โœ… Custom Rollout Func: Fully take over sampling concurrency & filtering logic โœ… Custom DataSource: Fetch prompts from API / local files / dynamic data streams โœ… Dynamic Filter: Discard low-value sample groups (e.g., zero-variance GRPO samples) โœ… Custom Loss Function: Rewrite PPO/GRPO loss calculation freely All custom code loads dynamically via --custom-xxx-path config ๐Ÿ“ ๐Ÿš€ Ray GPU Scheduling Magic Two deployment modes for all cluster scales: ๐Ÿ”น Colocate Mode: Train & inference share GPUs โ†’ high utilization, ideal for small 8-card servers ๐Ÿ”น Disaggregate Mode: Independent GPU pools โ†’ train-infer overlap, perfect for multi-node clusters Slime stabilizes Ray Placement Group GPU mapping via IP/GPU ID sorting to guarantee reproducibility ๐Ÿ”’ โšก SGLang Rollout Engine Internals 3-layer abstraction:RolloutManager โ†’ RolloutServer โ†’ ServerGroup โ†’ SGLangEngine Standout design highlights: ๐Ÿ”ธ Over-sampling + Dynamic Filter: Pre-sample extra data, filter invalid groups on the fly ๐Ÿ”ธ Async Concurrent Sampling: Process completed groups immediately with FIRST_COMPLETED ๐Ÿ”ธ Abort Mechanism: Stop redundant sampling once target data size is met, save compute ๐Ÿ”ธ Singleton GenerateState: One-time tokenizer & connection initialization ๐Ÿง  Megatron Training Backend Native support for mainstream RL algorithms: โœ… GRPO: No Critic needed, group-wise reward normalization (most popular) โœ… PPO: Classic Actor-Critic with GAE advantage estimation โœ… REINFORCE++: Token-level baseline optimization Seamless support for Dense & large MoE models with full parallelism ๐Ÿ“Š ๐Ÿ”„ Weight Sync: The Hard Engineering Solved Two high-performance sync paths: ๐Ÿ”น Colocate: IPC + Gloo โ†’ intra-node low-latency weight transfer ๐Ÿ”น Disaggregate: NCCL Broadcast โ†’ cross-node distributed sync MoE OOM prevention: Chunked Bucket Weight Update โ†’ sync parameters in small batches, release memory instantly ๐Ÿงฉ ๐Ÿ’ก Core Takeaways โœจ Slimeโ€™s elegance lies in integrating mature top-tier stacks with clean decoupled design โœจ Minimal top-level logic, maximal internal engineering depth โœจ Fully pluggable customization for all RL scenarios (Math / Code / Agent / MoE) โœจ Optimized for both small single-node & large multi-node clusters ๐Ÿ”—Full article๏ผš #LLM# #RLTraining# #SGLang# #AIInfrastructure# #MoE# #MachineLearning#
ใ‚‚ใฃใจ่ฆ‹ใ‚‹