Get the app

QwenGyre: Inside Alibaba's Elastic RL Engine for Multi-Hour AI Agents

How Alibaba's dynamic GPU scheduler and prefix-deduplicating trajectory processor trained a 2.4T MoE across 700K-token rollouts, slashing end-to-end training time by 44% vs Async baselines.

Training autonomous software agents via online Reinforcement Learning (RL) hits a brutal wall when tasks transition from simple single-file bug fixes to extreme-long (xLong) horizons. When an agent spends several hours executing shell scripts, running tests, refactoring entire repositories, and processing 700,000 to 1,000,000 tokens per rollout across hundreds of tool invocations, conventional distributed RL architectures collapse.

Alibaba researchers have published QwenGyre (arXiv:2609.33848), an elastic online RL framework engineered specifically for xLong-horizon agent execution. Scaled to Alibaba's flagship Qwen 3.8 2.4T (activating 95B parameters per forward pass), QwenGyre achieved a 6.0% absolute accuracy jump on NL2RepoBench (climbing from 52.5% to 58.5%) in just 48 training steps, while achieving up to 1.85x speedup over colocate pipelines and 1.78x over asynchronous architectures.

Here is how QwenGyre re-engineers cluster scheduling and trajectory compilation to make million-token agent RL viable.


The Distributed Systems Trap of Long-Horizon RL

To understand why existing RL systems fail on long agent rollouts, consider how mainstream frameworks like veRL, Ray-based PPO, or AReaL handle policy updates:

  1. The Colocate Bottleneck (Long-Tail Stragglers): In colocate setups, the entire GPU cluster alternates synchronously between rollout inference and gradient updates. In xLong workloads (such as generating an entire multi-module codebase from a natural language specification), rollout duration has massive variance: fast tasks finish in 5 minutes, while complex tasks run for 3 hours. Because the cluster cannot checkpoint arbitrary external sandboxes mid-execution, training remains completely blocked until the slowest rollout terminates, leaving 80–90% of compute nodes idling.
  2. The Asynchronous Partition Trap: In static async deployments, GPUs are hard-split into dedicated rollout and training pools. However, when rollout queues clear or when the cluster waits on multi-hour tasks, training GPUs starve for fresh batches. When a massive batch suddenly resolves, rollout workers bottleneck while training clusters lag behind stale policies.
  3. Trajectory Non-Linearity: Real-world agent harnesses are complex black boxes. They do not follow neat, linear sequence loops: they prune saturated context histories, spawn nested sub-agents, execute recursive tool retries, and branch into sandbox rollbacks. Standard sequential token log-probability tracking cannot handle this without double-counting gradients or blowing up token memory.
Traditional Colocate: 
[ Rollout (Fast Tasks) ] ---> [ IDLE IDLE IDLE (Waiting for 3-Hour Straggler) ] ---> [ Train ]

QwenGyre Elastic Allocation:
[ Rollout Nodes ] === Dynamic Cell Migration ===> [ Continuous Training Plane ]
(Live multi-hour agent executions never interrupted or checkpoint-killed)

Core Innovation 1: The Non-Disruptive Elastic Scheduler

QwenGyre replaces static cluster partitioning with an Elastic Scheduler that migrates GPU nodes between rollout and policy training on the fly without interrupting running agent sandboxes.

  • Elastic GPU Cells: The compute cluster is divided into modular execution cells that match the tensor, pipeline, and data-parallel layout required for training.
  • Dynamic Role Migration: Rather than letting nodes sit idle as rollouts finish early, QwenGyre monitors a real-time rollout waterlevel (the aggregate queue of pending and active executions). As the active inference workload thins out, idle rollout cells are dynamically reassigned to the training engine to execute gradient accumulation and optimizer steps.
  • Zero Execution Interruption: Because multi-hour coding harnesses maintain external stateful environments (Docker containers, local file systems, compilers), killing rollouts to reclaim compute destroys agent trajectory validity. QwenGyre guarantees that once an environment session initializes, its persistent connection to inference endpoints remains active even as neighboring nodes pivot to training.

By smoothly adjusting the compute ratio based on live rollout volume, QwenGyre eliminates straggler bubbles, reducing total cluster training time by approximately 44% compared to traditional async baselines.


Core Innovation 2: Trajectory DAGs and Prefix-Masked Loss

When training on 700K+ tokens per rollout, treating the execution history as a naive concatenated sequence results in massive redundancy and severe gradient bias.

During a long multi-agent run, agents repeatedly read the same shared environment context, reuse parent prompts, and attempt alternate tool executions from identical prefix states. If trained directly, the shared prefix tokens receive multiple backpropagation passes per rollout, disproportionately amplifying early prompt tokens over critical downstream code generation.

QwenGyre's Trajectory Processor solves this with three tightly coupled mechanisms:

  • Graph Reconstruction: It parses raw telemetry logs from unmodified agent harnesses and reconstructs the execution into a prefix-shared Directed Acyclic Graph (DAG).
  • Shared-Prefix Target Masking: When computing policy gradient updates across branching paths, loss calculation masks duplicate tokens in parent nodes, ensuring that every token generated during the rollout contributes exactly once to the gradient update.
  • Partial Progress Credit Assignment: Under previous frameworks, an agent that ran for 40 steps, implemented 85% of a codebase, and hit a timeout received a flat zero reward indistinguishable from an agent that failed on step one. QwenGyre evaluates intermediate test suites and structural repository artifacts to assign calibrated partial reward signals, extracting high-value learning signal from partial executions.

Benchmark Performance and Scaling

The authors validated QwenGyre across the newly established NL2RepoBench (generating complete software repositories from natural language requirements):

  • Qwen 3.8 2.4T (A95B Active): Across rollouts averaging ~700,000 tokens, QwenGyre raised NL2RepoBench pass rates from 52.5% to 58.5% (+6.0% absolute) within 48 optimization steps.
  • Scaling Efficiency: When scaling from dozens to hundreds of GPU nodes on extreme-long horizon rollouts, QwenGyre sustained up to 1.85x overall speedup over colocate architectures by systematically recovering dead compute time.

Why Elastic Agentic RL Is the Next Training Frontier

As AI development moves from single-turn reasoning benchmarks (like MATH or GSM8K) toward autonomous engineering that spans days or weeks of compute, the training bottleneck is no longer just context window length—it is systems scheduling and credit assignment.

QwenGyre proves that frontier LLMs can be directly optimized on massive, black-box agent harnesses without requiring hand-crafted synthetic rollouts or brittle synchronous step limits. By treating cluster elasticity and trajectory topology as first-class architectural primitives, QwenGyre establishes the blueprint for scaling reinforcement learning into the multi-million-token agent era.

Sources

The day's AI news, in one Telegram post.

The stories that matter for people who build with AI, with the source for every claim. Free, no spam.

Join on Telegram
The daily AI brief, on your phone.

Feed, daily deep-dive and bytes — readable offline, with push alerts for the topics you follow.

Get it on Google Play