Long-Horizon Agent RL on a 100-GPU Cluster: A Practical Training Recipe

    Long-horizon agent reinforcement learning makes rollouts expensive, asynchronous data stale, and rewards sparse. This article examines a recent recipe showing how a roughly 100-GPU-scale cluster can approach the performance-cost frontier through full-parameter MoE RL, environment filtering, stability measures for long and low-precision rollouts, and a shared training and evaluation harness. It also outlines reproducibility requirements, cost-reporting caveats, and key operational risks.

    1. Why Long-Horizon Agents Push RL Into a New Cost Regime

    The capability boundary of long-horizon agents is moving quickly. Early evaluations focused on minute-scale tasks such as fixing a single bug. Today, agents can spend hours in a terminal reading logs, modifying code, running tests, rolling back changes, and retrying.

    As tasks become longer, a training example is no longer just one forward pass and one backward pass. It becomes a complete trajectory that may last three hours and include hundreds of tool calls.

    This creates three major pressures for reinforcement learning:

    • Expensive samples: A single rollout can take hours of wall-clock time. Sampling throughput becomes the bottleneck, and GPUs spend substantial time waiting for environments to execute.
    • High failure cost: A failure at any point in a trajectory—such as a tool timeout, contaminated state, or a leftover process—wastes an entire multi-hour run rather than a single batch.
    • Sparse and stale signals: Rewards may appear only at the end of a trajectory. By the time the policy is updated, samples can be dozens of steps behind the current policy, causing severe distortion in importance ratios.

    Frontier labs can scale RL across thousands of accelerators and use brute-force parallelism to absorb these losses. Most teams do not have that budget. The more useful question is therefore not whether long-horizon agent RL can be trained at all, but whether a cluster with roughly one hundred GPUs can approach the performance-cost Pareto frontier.

    2. Core Finding: Smaller Clusters Can Still Reach the Frontier

    A recently published long-horizon agent RL recipe suggests that the answer is yes.

    The starting point is an MoE base model with approximately 321B total parameters and about 17.4B active parameters per token. After full-parameter reinforcement learning, it reached a Pass@1 score of 46.2% on a mainstream terminal-task benchmark. That result was comparable to leading closed-source systems running at their highest inference effort, while the cost per task was more than 30 times lower. The same gains transferred to two software engineering benchmarks.

    The complete training run used 64 high-end accelerators for fewer than five days.

    This is not simply a case of using a smaller model to reduce cost. It is a redesign of training efficiency at a similar capability level. The main ingredients are:

    1. Environment filtering that keeps tasks within a difficulty range that produces reliable learning signals.
    2. An RL recipe designed specifically for long, stale, and low-precision rollouts.
    3. A shared programming harness for optimization, training, and evaluation.

    3. Training Starting Point: Full-Parameter RL and Selective Freezing

    The recipe does not use parameter-efficient fine-tuning methods such as training adapters only. Instead, it updates all roughly 320B language parameters, including multi-token prediction (MTP) layers, while freezing the vision tower and sparse-attention indexing modules.

    The rationale is important.

    1. Long-horizon capabilities are distributed across the backbone. Terminal and programming tasks require instruction following across many turns, stable tool-call formatting, and state tracking over long contexts. These behaviors reside in backbone parameters. Low-rank adapters may not have enough capacity and can lead to formatting failures late in long trajectories.

    2. The frozen components are less relevant to the task. Vision encoding and sparse indexing are perception and efficiency infrastructure. They are less directly related to planning the next command. Freezing them reduces memory use and helps avoid catastrophic forgetting.

    3. Full-parameter training does not necessarily mean full dense-model cost. MoE activation sparsity means per-token computation is much lower than for a dense model with the same total parameter count. This makes the marginal cost of full-parameter RL manageable and is a key reason the approach can fit within a roughly 100-GPU budget.

    In practice, this requires a combined memory and parallelism strategy. Parameters, optimizer states, and gradients need to be sharded. Rollout and training resources need either time-sharing or separate deployment. Auxiliary heads such as MTP also require separately managed loss weights so that they do not dominate the gradient direction.

    4. Pillar One: Environment Filtering and Difficulty Stratification

    RL effectiveness depends heavily on signal quality.

    If a task is too difficult, nearly all samples fail. Group-level advantages become zero, and the task contributes no useful gradient. If a task is too easy, nearly all samples succeed, which also produces no gradient. Both cases consume compute without generating learning signal.

    A practical filtering process includes the following steps:

    • Executability validation: Every task must initialize, run, and be graded reproducibly inside a container. Tasks should not depend on external networks, unstable timestamps, or random ports.
    • Difficulty calibration: Sample each task multiple times using the base model and measure its pass rate. Retain tasks in a middle success-rate range, such as 0.1 to 0.7, to form a curriculum.
    • Grader hardening: Unit tests and state assertions must verify whether the problem was actually solved. This helps prevent reward hacking, such as modifying tests, skipping cases, or hard-coding return values.
    • Environment isolation and cleanup: Use one container per task. Force-kill timed-out jobs and fully clean working directories and process groups to prevent state contamination from affecting later samples.
    • Dynamic difficulty: Re-sample the task pool during training. Remove tasks that have become saturated and introduce tasks that have become appropriately challenging.

    A simplified filtering and sampling workflow looks like this:

    1. # Pseudocode: difficulty calibration and curriculum sampling
    2. def calibrate(tasks, policy, n=8):
    3. keep = []
    4. for t in tasks:
    5. results = [run_in_container(t, policy) for _ in range(n)]
    6. p = mean(results)
    7. if 0.1 <= p <= 0.7: # Only intermediate difficulty provides gradients
    8. keep.append((t, p))
    9. return keep
    10. def sample_batch(pool, policy, group_size=8):
    11. batch = []
    12. for t, _ in weighted_resample(pool):
    13. group = [run_in_container(t, policy) for _ in range(group_size)]
    14. if len(set(group)) == 1: # Drop all-correct or all-failed groups
    15. continue
    16. batch.append((t, group))
    17. return batch

    5. Pillar Two: An RL Recipe for Long, Stale, and Low-Precision Rollouts

    This is the most technically demanding part of the recipe. Three unfavorable properties need separate treatment.

    5.1 Long Trajectories: Credit Assignment and Length Normalization

    Hour-scale trajectories may provide only a sparse terminal reward. Rewards need to be propagated back across tool-call boundaries with appropriate discounting. The loss should also be normalized by trajectory length so that long trajectories do not dominate gradients simply because they contain more tokens.

    Truncated trajectories should be marked separately. A rollout terminated by a timeout should not automatically be treated as a policy failure.

    5.2 Stale Data: Controlling the Degree of Off-Policy Training

    Asynchronous sampling inevitably produces stale trajectories. Common engineering measures include:

    • Small-batch proximal policy optimization clipping.
    • Importance-ratio truncation.
    • A maximum allowed policy lag for each batch.
    • Dropping samples that exceed the lag limit instead of forcing them into training.

    The key trade-off is between staleness tolerance and throughput. More tolerance improves utilization, but too much stale data can destabilize training.

    5.3 Low Precision: Numerical Stability

    Importance-ratio terms can have very high variance in long-horizon RL. Low precision, including bf16 or lower-precision communication and computation, can cause extreme importance ratios.

    A common approach is to compute importance ratios and log probabilities in higher precision, retain a higher-precision master copy for model updates and optimizer states, and use gradient clipping plus skipped steps for abnormal gradients.

    A simplified update loop is shown below:

    1. # Pseudocode: policy updates with stale and low-precision rollouts
    2. for batch in async_rollout_stream(max_lag=32):
    3. adv = group_normalized_advantage(batch.rewards) # Normalize advantages within each group
    4. for _ in range(PPO_EPOCHS):
    5. logp = policy.log_prob(batch.tokens, dtype="float32") # Compute ratios in higher precision
    6. ratio = (logp - batch.old_logp).exp().clamp(max=CLIP)
    7. loss = -min(ratio * adv,
    8. ratio.clamp(1 - CLIP, 1 + CLIP) * adv)
    9. loss = loss / batch.num_tokens # Normalize by trajectory length
    10. if not grads_finite(loss):
    11. skip_step(); continue # Skip abnormal updates
    12. opt.step()

    6. Pillar Three: Use One Shared Harness for Training and Evaluation

    Many teams use one framework for training and another for evaluation. This often causes behaviors learned during training to fail during evaluation because tool descriptions, timeout settings, or context-truncation strategies differ. The resulting metrics are not directly comparable.

    A shared harness reduces this distribution shift:

    • The same tool interfaces and prompt templates: Training and evaluation differ only in model weights and concurrency.
    • The same graders: This reduces the mismatch where training reward improves but benchmark performance does not.
    • Unified observability: Log every tool call, execution duration, and failure reason. Monitoring and alerting can then distinguish environment failures from policy regressions.
    • Centralized artifact storage: Store trajectories, checkpoints, and evaluation reports together for debugging, replay, and reproducibility.

    In a cloud deployment, these requirements map to general infrastructure categories: a container platform for environment orchestration and elastic scaling, object storage for trajectories and checkpoints, and logging and monitoring services for observability. For example, Baidu AI Cloud provides container, storage, and monitoring capabilities that can support these requirements, although the specific architecture should be evaluated against a team’s existing stack.

    7. Two Common Traps in Result and Cost Interpretation

    Trap One: The Chart Axis

    Performance-cost charts should use logarithmic axes. Otherwise, low-cost improvements can be visually compressed until they are difficult to see.

    A standard presentation is to show the Pareto frontier as a dashed line and use arrows to indicate the direction of improvement.

    Trap Two: The Cost Accounting Method

    A self-hosted model does not have a market price, so the recipe estimates cost based on the published price of the base model. This introduces two important caveats:

    1. The actual unit cost of self-hosting depends on utilization. If GPUs spend significant time idle, the real cost will be higher than the estimated cost.
    2. The “more than 30 times lower” figure is relative to a competitor operating at its highest inference-effort setting. The gap would narrow substantially if the competing system used a lower inference-effort setting.

    Evaluation methodology also matters. Pass@1 may be averaged across repeated trials and measured with a custom harness, which can differ from official benchmark reporting. Cross-report comparisons should therefore be treated carefully.

    8. Reproduction Checklist

    • Base model: An MoE model with more than 300B total parameters and roughly 5% active parameters; full-parameter RL; vision and indexing modules frozen.
    • Compute: 64 high-end accelerators for fewer than five days.
    • Data: A terminal and programming task pool filtered for executability and calibrated difficulty, with a dynamic curriculum.
    • Algorithm: Group-normalized advantages, proximal clipping, a maximum policy-lag limit, higher-precision importance ratios, length normalization, and skipped-step protection.
    • Engineering: A shared training and evaluation harness, one container per task, and end-to-end logs and metrics.
    • Validation: At least three benchmarks, including two terminal-oriented benchmarks and software engineering benchmarks; report both Pass@1 and per-task cost curves.

    9. Limitations and Risks

    The conclusions of this recipe depend on a specific base model and task distribution. When transferring the approach to another model, the difficulty range, stale-data tolerance, and clipping coefficients must be recalibrated.

    Full-parameter RL also places high demands on memory capacity and parallelism implementation. For smaller teams, a more practical path is to first establish a shared harness and reliable environment filtering, then gradually expand the set of trainable parameters.

    Reward hacking becomes more likely as long-horizon tasks become more complex. Grader hardening should be treated as a continuous investment rather than a one-time setup task.

    The broader lesson is that the main bottleneck in long-horizon agent RL is no longer simply having enough accelerators. It is the quality of training signals and the consistency of the engineering system. Clean environments, stable handling of stale and low-precision rollouts, and aligned training and evaluation can allow a roughly 100-GPU budget to deliver frontier-level cost efficiency.