Reinforcement learning (RL) has emerged as a critical phase in the post-training pipeline of large language models (LLMs). As the frontier of LLM capabilities shifts from static reasoning to agentic tasks--characterized by external tool invocation, multi-turn interactions, and long-horizon decision-making--existing mainstream RL frameworks have grown increasingly unwieldy, raising the overhead of adoption, usage, and debugging. To address these challenges, we present LoongSage, an agent-native, fully asynchronous RL framework with a lightweight core of roughly 14K lines of code. Built upon Megatron for distributed training and SGLang for high-throughput inference, LoongSage centralizes orchestration within a single controller process and encapsulates all GPU-resident components as Ray actors. It introduces AgentFlow, a unified execution paradigm that orchestrates both white-box and black-box agents. For asynchronous execution, it integrates sliding-window strategies that bound trajectory staleness, and employs TransferMesh, a topology-aware synchronization mechanism that routes weights after each step over the fastest transport available to each receiver. Beyond agentic RL, LoongSage incorporates a memory-efficient Teacher Manager that decouples the scaling of teacher models from GPU memory constraints, natively supporting Multi-Teacher On-Policy Distillation. Extensive evaluations across four complete training runs, spanning complex reinforcement learning and multi-teacher distillation, demonstrate that task rewards improve steadily while the train-inference gap is kept under continuous control, and the fully asynchronous pipeline removes synchronous idle bubbles, sustaining hardware utilization.
Figures & tables
Figure 1: Positioning of LoongSage relative to closely related systems. Each entry is compiled from the publicly available documentation of the corresponding project at the time of writing. A dash indicates a capability that is not documented, rather than one that cannot be realized within the system.
Figure 2: Overall system architecture of LoongSage.
Figure 3: The two orthogonal configuration axes behind LoongSage’s operational modes, their trade-offs, and the combination that the framework does not support.
Figure 4: The AgentFlow request path. The Router intercepts each Chat Completions request, tokenizes the turn, dispatches it to SGLang’s /generate , and records the returned tokens per turn in the TrajectoryStore .
Figure 5: Data representation under TITO: a single flattened token array with its position-aligned response-space arrays, referenced by Segment and Triplet indices rather than copied.
Figure 6: AgentFlow stores a black-box trajectory as a tree of segments: trainable mainline segments ( origin=root or compact ) own the flat token arrays, while a collab_spawn request forks a non-trainable subagent placeholder ( origin=subagent ).
Figure 7: The protocol adapter normalizes each agent’s wire format into one internal request: OpenCode over Chat Completions, Codex over OpenAI Responses, and Claude Code over Anthropic Messages. A single parser, tokenizer, and SGLang path then serve all of them.
Figure 8: The fully asynchronous pipeline’s control points reduce to two gates—a dispatch gate and a collection gate. Table 1 lists the mathematical bounds each registered policy places on them.
Bound at the control point
Resulting guarantee
Strategy
Dispatch
Collection
Staleness
Training order
no-window
F+Q≤W
unconstrained
unbounded
unconstrained
window-gated
s≤smin+W
unconstrained
≤S steps
unconstrained
windowed-fifo
F+Q≤W
s−smin<B
indirect
FIFO within B
Table 1: The bounds imposed by each sliding-window strategy at the two control points of the asynchronous runtime, and the guarantees they provide. window-gated inherits the capacity bound of no-window in addition to the sequence-number bound listed here.
Figure 9: The three registered sliding-window policies (a) no-window , (b) window-gated , and (c) windowed-fifo on a shared timeline of dispatched groups (bounds in Table 1 , consequences discussed above).
Figure 10: TransferMesh packs the named tensor stream into one contiguous memory bucket described by a single metadata frame, then dynamically selects a transport protocol per receiver based on device topology: utilizing a zero-copy CUDA IPC handle for colocated engines and an NCCL broadcast for remote receivers.
Figure 11: The Teacher Manager schedules teacher groups that share a GPU-memory slot, offloading inactive teacher weights to host memory and swapping them back on demand.
Figure 12: Full-vocabulary distillation via micro-batch logit reconstruction: within each micro-batch the teacher logits are rebuilt from hidden states, consumed by the loss, and released before the next micro-batch begins.
Figure 13: Train–inference consistency is handled in three groups: source alignment guarantees the trained sequence mathematically matches the sampled sequence, long-context and precision settings anchor numerical stability, and residual corrections continuously bound the remaining gap.
Registry
Configuration field
Scope
agent
data_source.agent.name
Agent loop
reward
data_source.reward.name
Reward computation
sandbox
data_source.sandbox.type
Execution environment
advantage
algorithm.advantage_estimator
Advantage estimation
policy_loss
algorithm.policy_loss
Policy loss
kl_policy
opd.{pg,gkd}_kl_method
KL constraint and estimator
Table 2: The core registries exposed by LoongSage. Each is invoked via a @register_<name> decorator at the definition site and bound to the corresponding configuration field. Fields lacking a top-level section ( agent , reward , dataset.* ) are resolved relative to the specific data_source . The kl_policy row abbreviates opd.pg_kl_method and opd.gkd_kl_method .
Setting
Model
Hardware
Focus
Training runs, one complete run each
SWE
DeepSeek-V4-Flash
8 H20 nodes
Long-horizon software tasks
DAPO
DeepSeek-V4-Flash
6 H20 nodes
Verifiable mathematical reasoning
OpenCode
Qwen3-Coder-30B-A3B
4 H20 nodes
Black-box coding agent
MOPD
Qwen3-30B-A3B
1 H20 node
Multi-teacher distillation
Controlled comparisons between configurations
Table 3: The runs reported in this paper.
Figure 14: Training curves for DeepSeek-V4-Flash on SWE tasks.
Figure 15: Training curves for DeepSeek-V4-Flash on DAPO mathematical reasoning.
Figure 16: Training curves for full-vocabulary multi-teacher MOPD on Qwen3-30B-A3B.
Figure 17: Training curves for Qwen3-Coder-30B-A3B with the OpenCode black-box agent.
all 100 steps
excluding step 0
Configuration
Split
avg (s)
speedup
avg (s)
speedup
Colocated
16
580.79
1.00 ×
578.63
1.00 ×
Colocated + partial rollout
16
489.63
1.19 ×
486.34
1.19 ×
Async, no-window , S=1.0
8:8
454.50
1.28 ×
451.74
1.28 ×
Async, windowed-fifo , S=1.0
8:8
434.76
1.34 ×
424.30
1.36 ×
Async, windowed-fifo , S=2.0
8:8
428.76
1.35 ×
414.58
1.40 ×
Table 4: Average step time under colocated and fully asynchronous execution. Speedups are relative to the colocated baseline in the same column.
Reinforcement learning (RL) is becoming increasingly important for post-training large language models (LLMs). Previous RL pipelines for LLMs were mostly synchronous and batch-interleaved, which is inefficient for long-horizon agentic tasks. Recently, asynchronous RL has emerged as a more efficient alternative by updating the model as rollouts arrive. However, existing asynchronous RL systems often emphasize throughput, while leaving training stability and task effectiveness largely underexplored. For example, a key challenge is that group-wise sampling in the widely-used GRPO framework does not naturally fit asynchronous agentic training. In this paper, we present Single-rollout Asynchronous Optimization (SAO) to address the stability and off-policy challenges in asynchronous RL. To reduce off-policy effects and improve generalization, we replace group-wise sampling with single-rollout sampling, that is, using one rollout per prompt. We further improve this single-rollout strategy with practical value-model training designs. To improve optimization stability, we introduce a strict double-side token-level clipping strategy. SAO is able to train stably for one thousand steps and consistently outperform GRPO and its variants on agentic coding and reasoning benchmarks, such as SWE-Bench Verified, BeyondAIME, and IMOAnswerBench. We also demonstrate that single-rollout RL is particularly effective in a simulated online learning setting, where the model must adapt to changing evolving environments. To this end, SAO is successfully deployed in the agentic RL pipeline for training the open GLM-5.2 model (750B-A40B).
Zhenyu Hou, Yujiang Li, Jie Tang +1
Tsinghua University · Work done while ZH and YL interned at Z.AI.
Reinforcement learning (RL) has become a pivotal technology in the post-training phase of large language models (LLMs). Traditional task-collocated RL frameworks suffer from significant scalability bottlenecks, while task-separated RL frameworks face challenges in managing complex dataflows and resolving resource idling. Furthermore, most existing frameworks are tightly coupled with LLM training or inference engines, making them difficult to support custom-designed engines. To address these challenges, we propose AsyncFlow, an asynchronous streaming RL framework tailored for efficient post-training. Specifically, we introduce a distributed data storage and transfer module that provides panoramic data management and fine-grained scheduling capabilities in a fully streamed manner. This architecture inherently enables automated pipeline overlapping among RL tasks and dynamic load-balancing. Moreover, we propose an asynchronous producer-consumer workflow, which is engineered to minimize computational idleness by strategically deferring the parameter update process within staleness thresholds. Finally, the core capabilities of AsyncFlow are architecturally decoupled from underlying training and inference engines and encapsulated by service-oriented user interfaces, offering a modular and customizable user experience. Extensive experiments demonstrate an average throughput of 1.59x compared to the state-of-the-art baseline. The architecture presented in this work provides actionable insights for designing next-generation RL training systems.
Reinforcement learning (RL) has been a critical paradigm for improving large language model (LLM) reasoning and agentic capabilities, but its efficiency remains a major bottleneck. Existing RL systems commonly rely on asynchronous execution to overlap rollout generation with policy optimization for enhanced efficiency. However, this approach faces inherent limitations: mild policy staleness offers only limited training efficiency gains, whereas aggressive asynchrony can degrade model quality and yields diminishing efficiency gains. The dynamic nature of LLM RL and multi-turn agentic workloads further challenges RL system design, as resource demands shift over time, making static resource allocation and generation strategy inefficient. This paper presents ReFlow, a system-algorithm co-designed RL framework for efficient LLM post-training. Its key insight is that, unlike existing RL frameworks which consume each trajectory only once, experience replay of recent trajectories enables effective sample reuse, thereby amortizing the high cost of rollout generation without incurring excessive policy staleness. To fully exploit this opportunity, ReFlow adopts a decoupled and adaptive architecture with three key designs: a dual replay data cycle supports efficient experience reuse while balancing training throughput and optimization stability; an elastic resource pool enables dynamic resource placement to accommodate evolving RL workloads; an adaptive scheduler coordinates generation strategies and resource allocation to improve resource utilization and boost generation throughput. Experiments across representative single-turn reasoning and multi-turn agentic RL tasks show that ReFlow improves training throughput by up to 2.06× over state-of-the-art synchronous and asynchronous RL systems, while maintaining comparable or better model performance.
Yukun Tian, Junwei Su, Haofeng Xu +6
The University of Hong Kong · Alibaba Group · University of Science and Technology of China +1