Slime GitHub Explained: Restructuring RL Pipelines for GPU Throughput

slime pairs SGLang rollouts with Megatron training under Ray. Its biggest throughput gains come from placement, overlap and balance, not kernel tuning.

Slime GitHub Explained: Restructuring RL Pipelines for GPU Throughput
Written by TechnoLynx Published on 11 Jul 2026

slime is a framework for scaling reinforcement learning (RL) post-training of large language models. It is published as the slime GitHub repository THUDM/slime, and it pairs SGLang for rollout generation with Megatron-LM for training, with Ray placing and scheduling both. In AReaL, Laminar and StreamRL, the reported speedups come from decoupling, overlapping and balancing generation and training.

In RL post-training, GPUs spend much of each step waiting on other GPUs, and no kernel optimisation inside one stage removes a wait between stages.

How Does Slime RL Work, and What Does It Mean in Practice?

slime keeps its own scope narrow. It provides a customisable rollout interface, uses Ray for GPU management and asynchronous execution, integrates SGLang for inference and Megatron for training, and handles weight updates between the two. Its authors describe this as pushing complexity out of the framework and into user-defined pipelines and the core libraries, which keeps the slime codebase small.

One RL step follows the standard pipeline. The current policy generates responses (rollout), each response gets a reward score, and the training stage updates the weights from those rewards. In slime, every SGLang server sits behind sgl-router, so your data-generation code sends HTTP requests to a single endpoint, and agent environments can call it through an OpenAI-compatible API without being modified. The updated weights then flow back from Megatron to the SGLang servers before the next round of generation.

This is not a research toy. slime has powered RL post-training across Z.ai’s GLM model generations. For GLM-5 it served as the unified post-training infrastructure, with no new system components added.

In practice, two structural choices are configuration rather than rewrites. Colocated (same GPUs) versus decoupled (separate GPUs) placement is one flag, --colocate, and switching between synchronous and asynchronous behaviour comes down to where the ray.get call sits.

What Should You Know Before Running Slime from the Slime GitHub Repository?

The usage guide in the repository puts the parameters into four groups: the GPU split between training and inference, loading Megatron for training, loading SGLang for inference, and the RL hyperparameters. By default, Ray gives actor_num_nodes × actor_num_gpus_per_node GPUs to training and rollout_num_gpus GPUs to inference, so the two run on separate resources. That arithmetic is the first structural decision you make, and you make it before writing any custom code.

A few practical details matter early:

  • Megatron must be importable on PYTHONPATH, because slime reuses functions from megatron.training such as argument parsing and checkpoint save and load.
  • SGLang is initialised from a Hugging Face checkpoint passed with --hf-checkpoint, and every SGLang parameter passes through with a --sglang prefix.
  • A Megatron-only debug mode (--debug-train-only) and checkpoint conversion tools exist to tame Megatron’s complexity.
  • GRPO computes advantages from comparisons within a group and needs no critic, while PPO adds a critic that shares the actor’s training GPU group. PPO therefore adds load to the training side of the balance.

The fully asynchronous rollout path has its own end-to-end demo, and we cover what it does to cost in our piece on how slime’s async rollouts change GPU inference cost. If you came for reward design rather than throughput, a separate walkthrough of how the slime RL framework works in practice takes that angle.

What Are the Main Components of a Slime RL Training Pipeline, and How Do They Run on GPUs?

The pipeline has five moving parts:

  • Rollout engine: SGLang servers launched in server mode, with every SGLang optimisation available. sgl-router load-balances requests across them.
  • Training backend: Megatron-LM with tensor, pipeline, expert and context parallelism, and training MFU monitored. Hugging Face’s 2025 survey of async RL libraries notes that expert parallelism for MoE models is handled correctly only by Megatron-backed libraries (slime among them) and one FSDP2 path.
  • Orchestration: Ray actors. Eight of the sixteen libraries in that survey use Ray as their backbone.
  • Weight synchronisation: the survey records slime as using a bucketed NCCL process group, importance-sampling correction for staleness, and abort-and-recycle to the buffer for in-flight rollouts.
  • Data transport: the Ray object store by default, with NIXL tensor transport as an option, or the straw backend on a shared JuiceFS directory for distributed fully async rollout.

The two GPU-heavy stages want different things from the hardware. Decoding is memory-bandwidth-bound because each step computes one new token but reads all the parameters, while training is compute-bound because forward and backward passes cover every token in the batch. The StreamRL authors (2025) measured generation time plateauing as resources were added. Only tensor parallelism raises aggregate bandwidth, and its communication cost keeps it within a node, so extra generation GPUs mostly add data-parallel instances that do little for step time. The result is that the same GPU count buys a different amount of useful work in each stage. Our deeper look at how SGLang speeds up the RL rollout serving path covers the inference side of this split.

Why Is Throughput Balance Between Rollout and Training a Structural Problem, Not a Kernel-Tuning One?

Idle time in an RL step comes from stage dependencies and long-tail output lengths.

The RhymeRL authors (2025) report that rollout typically takes 84% to 91% of each RL step, and finished rollouts must wait for the longest one in the batch before reward and training can start. The Laminar authors (2025) found that in maths and coding tasks the 99th-percentile output length can exceed the median by an order of magnitude, which leaves only a few trajectories running and most of the cluster underused. The GLM-5 team (2026) puts it most bluntly: for RL rollouts the target is end-to-end latency, dominated by the slowest sample in each step, not aggregate throughput.

Decoding is memory-bound, so a rollout replica left with fewer than eight live sequences has nearly the same per-step latency as one decoding 64.

A Worked Example of Why the Slower Stage Sets the Pace

The AREAL-DTA authors (2026) model idealised asynchronous pipeline throughput as the minimum of the two stages: T_e2e = min(T_train × N_train / N, T_roll × N_roll / N), where N is the GPU count and T is each stage’s full-cluster throughput. Assume, purely for illustration, that training could process twice as many samples per step as rollout produces. Doubling training kernel speed then changes nothing end to end, because the minimum is still the rollout term. In this model, the moves that help are faster rollout or moving GPUs from the surplus stage to the scarce one.

The DynaResize authors (2026) frame the imbalance the same way: primarily a physical resource mismatch, not a flaw in the RL algorithm, to be fixed by reallocating GPUs between stages while keeping the algorithm’s semantics. Their runtime reallocation (for example, moving a train-to-rollout split from 6:2 to 4:4) improved end-to-end throughput by 66.5%.

The profile is not always generation-dominated. In agentic RL, RollArt’s authors (2025) measured an average iteration of 366 seconds in which generation took only 54%, training 23% and environment initialisation 15%. In the same study, reward workers on dedicated GPUs fell to as little as 7.4% utilisation.

A cluster-wide GPU-busy average blends a generation phase and a training phase with very different hardware appetites. Splitting that figure per stage is a monitoring job, and our ML monitoring framework piece covers how to instrument it. The financial side of those idle phases is covered under the hidden cost of GPU underutilisation.

When Does Restructuring the RL Pipeline Give a Bigger GPU Speedup than Optimising Individual Kernels?

FlexRLHF and StreamRL targeted pipelines where one stage dominated the step or waited on the other. The measured gains from changing placement and overlap run to multiples.

The evidence follows paper by paper; each paper measured against its own baselines, such as DeepSpeed-Chat for FlexRLHF and synchronous systems for AReaL.

  • The FlexRLHF authors (2023) found actor generation taking more than 85% of a DeepSpeed-Chat RLHF step. Their disaggregated placement outperformed DeepSpeed-Chat’s co-located strategy by 4× to 11× in PPO RLHF on 33B and 65B models.
  • The StreamRL authors (2025) broke down their gains on a 72B model: skewness-aware scheduling added 8%, disaggregated streaming another 15%, and asynchronous training a further 25%.
  • AReaL (2025), which also pairs SGLang with Megatron-Core, cut end-to-end training time by 2.77× compared with synchronous systems. It allocated three-quarters of the devices to inference after a 75/25 split beat 50/50, while noting that the optimum varies by setting.
  • Laminar’s trajectory-level asynchrony averaged 1.41× across baselines at 64 GPUs or fewer and 3.34× at the largest scales, with up to 5.48× on a 1024-GPU cluster.
  • RhymeRL’s history-based scheduling alone (HistoPipe) gave 1.43× throughput on a 14B maths model.

Choosing Colocated, Disaggregated or Hybrid Placement

Situation you measure Placement to try Why
Small cluster where the model needs most GPUs for parallelism Whichever placement the parallelism allows At small scale parallelism limits the allocation choices, and placements across systems end up similar; colocation also removes the separate NCCL weight-sync group.
Generation dominates and stops scaling with more GPUs Disaggregated Colocation forces identical resource counts and hardware on a bandwidth-bound and a compute-bound stage.
Disaggregated, but each stage idles while the other runs Disaggregated plus async overlap Naive disaggregation leaves training GPUs idle during generation and the reverse.
A CPU simulator or environment is the bottleneck Colocated or shallow hybrid In RLinf-VLA’s tests on LIBERO, a CPU-bound simulator and a 1:15 generation-to-execution ratio erased the benefit of pipelining.
GPU-parallel simulator with rollout scaling by environments Hybrid pipelining On GPU-parallel ManiSkill, RLinf-VLA measured up to 1.88× over a disaggregated baseline on 8 GPUs.
Large cluster with heavy long-tail skew Trajectory-level async with repacking Global weight-sync barriers make extra rollout GPUs yield marginal returns.
Mixed agentic workload on heterogeneous hardware Stage-to-hardware routing RollArt reports limited benefit on homogeneous clusters or strict on-policy RL.

The sources also disagree on one classification. RollArt groups slime with “monolithic” frameworks that co-locate all stages, while slime’s own usage guide separates training and inference GPUs by default and GLM-4.5 describes partitioning GPUs into dedicated rollout and training engines. RollArt’s stated objection is that these frameworks ignore hardware heterogeneity across stages.

Async Rollout Batching and the Staleness Bill

Asynchrony buys throughput by training on samples from older policy versions, and that has a cost. The Laminar authors describe the trade-off directly: a larger staleness bound hides more generation latency but widens the gap between the policy that generated the data and the policy being trained, which can harm convergence. The ICLR 2025 asynchronous RLHF study found that performance generally degrades with more off-policyness, yet one-step off-policy training matched synchronous results and ran 38% faster on an 8B chatbot.

Frameworks handle this in different ways. AReaL caps staleness with a hyperparameter η (η = 0 is synchronous RL) and uses a decoupled PPO objective with importance sampling. RollArt aborts any trajectory started more than α versions ago. Hugging Face’s survey notes a production trend towards combining depth bounds with optional importance-sampling correction, and lists slime’s async mode under the double-buffer pattern, which overlaps one generation with one training step at most one step of lag.

slime’s fully async example keeps a fixed pool of in-flight generations across rollout boundaries, so the next training step does not wait for the slowest sample. Admission pauses around weight synchronisation and in-flight work is preserved. --flush-cache-interval decides whether KV cache is flushed or kept across weight updates. Keeping it is not free, because the Laminar authors warn that updating weights mid-generation creates mixed-version trajectories and ties throughput to training stability. Asynchrony also only removes idle time when the two stages take similar time; mismatched speeds still leave GPUs waiting.

Algorithmic Changes Move the Balance Point

Changing what a stage computes also moves the optimal GPU split. AREAL-DTA reuses shared prefixes across rollouts during training. That raised training throughput by up to 8.31× for a single worker but end-to-end RL throughput by up to 2.28×, and the best rollout/training GPU split moved to 5/3 from AReaL’s 2/6. The gap between those two multiples is the minimum-of-stages effect: once training got faster, rollout became the limit, and only reallocating GPUs captured more of the gain.

On the rollout side, GLM-5 used slime’s multi-token prediction because it helps most on small-batch stragglers in the long tail; the mechanism itself is explained in how DeepSeek MTP works. GLM-5 also ran prefill and decode on separate resources so that heavy multi-turn prefills stopped disrupting ongoing decodes.

How Do I Tell That My RL Training Stack Has Hit a Kernel-Tuning Ceiling?

You have hit the ceiling when profiling shows the step is bounded by waiting rather than computing, so kernel work on the waiting stage no longer moves step time. GPU performance is governed by whichever resource saturates first, and the right intervention depends on which one it is. That makes phase-level timing the first measurement, before any kernel profile.

A diagnostic checklist for an RL stack:

  1. Split each step’s wall time into rollout, reward, weight sync and training. If one phase sits idle while another runs, faster kernels on the idle phase return nothing.
  2. Track live sequences per rollout replica over the step. A long tail of tiny decode batches is the memory-bound regime where a small batch size costs about as much as a large one.
  3. Check whether the trainer blocks on batch collection. In RollArt’s production trace, the blocking get_batch call accounted for up to 62% of iteration time as GPU idleness.
  4. Add rollout GPUs and see whether step time moves. Marginal returns point to long-tail or synchronisation limits.
  5. Measure exposed weight-sync time. RollArt measured 38.6 to 157.0 seconds of blocking without overlap, against 1.4 to 9.6 seconds exposed with asynchronous transfer.
  6. Check utilisation of reward resources, which fell to 7.4% on dedicated GPUs in RollArt’s study.
  7. Check whether training MFU is already high while step time stays flat, using the training MFU slime monitors. If so, the training kernels are not your constraint.

Kernel tuning still pays when a compute-bound phase is the resource saturating first. The point is to prove that first.

What Metrics Show Whether Restructuring Improved End-to-End RL Training Throughput?

Judge a restructuring by end-to-end progress per unit of time at matched training quality. Per-stage utilisation on its own is not enough.

Metric What it tells you
End-to-end step time and time-to-score The headline result; RollArt reports both.
Samples processed per second, end to end FlexRLHF’s throughput measure.
Per-phase share of step time Where the time goes; rollout took 84–91% in RhymeRL’s reasoning runs but 54% in agentic RL.
Idle share per stage The stall that restructuring targets.
Rollout-to-training time gap In async training the slower stage sets iteration time, so this gap should shrink.
Exposed weight-sync time Sync cost that overlap failed to hide.
Staleness distribution of consumed samples Laminar kept inherent staleness typically under 3 versions.
KV-cache utilisation on rollout replicas A direct signal of rollout resource pressure.
Final quality against a synchronous run The async RLHF study matched a 57.2% win-rate while running 38% faster.

Measure over a long enough window. Generation time grows faster than training time as output lengths increase during a run, so a balance that holds at step 10 may not hold at step 500. Reconfiguration also has a startup cost: DynaResize found that reallocation paid for itself after roughly 11 sustained steps.

Where the Order of Work Comes From

Across AReaL, Laminar, StreamRL and AREAL-DTA, the gains came from decoupling, overlap, asynchrony and, in AREAL-DTA’s case, a change to what training computes. That matches how we approach GPU work generally: ask what the pipeline is waiting on before touching a kernel. For the general version of that comparison beyond RL, see choosing between algorithmic restructuring and kernel tuning.

One question remains open for any specific run: how much of these published speedups carries over to your model and cluster. The --colocate flag and the rollout GPU count are where you find out.

FAQ

Does Slime Support SFT?

Yes. slime’s flexible training setups include an SFT cold start as well as RL, in colocated or decoupled and synchronous or asynchronous configurations.