Long-Horizon AI Agent Reinforcement Learning on a 100-GPU Cluster: Practices and Cost Optimization

    This article examines how to make long-horizon AI agent reinforcement learning cost-efficient on a 100-GPU-scale cluster, where the real bottleneck is the cost per unit of effective learning signal rather than model size. It breaks down a public recipe into five key areas: difficulty stratification and reliability filtering of training tasks, algorithm adaptations for long, stale, low-precision rollouts, scoping full-parameter training, sharing one harness between training and evaluation, and reading the Pareto frontier through both quality and cost. It also provides a reusable implementation checklist and a general cloud architecture for reproducing the setup, showing how systematic design across environment, algorithm, framework, and cost accounting can approach the performance-cost frontier without a massive cluster.

    1. Background: Why Long-Horizon Agents Are Expensive to Train

    Long-horizon agents are pushing task boundaries from “fix a single bug” toward continuous terminal operations and software engineering work that can last for hours. These tasks share a common trait: each attempt produces an extremely long trajectory with dense tool-call rounds, and any deviation in the middle accumulates downstream, ultimately surfacing as a single complete failure. Viewed through a reinforcement learning framework, one training sample often corresponds to a full rollout that spans hours and involves hundreds of tool calls. When the environment is unstable or the reward is unreliable, what gets wasted is not a single forward pass but hours of cluster time.

    The core tension in long-horizon agent RL is therefore not “whether the model is big enough” but the cost per unit of effective signal. Frontier labs can scale across thousands of accelerators, while most teams operate at around a hundred GPUs and must trade process design for compute stacking to gain efficiency. Public industry practice offers an answer: starting from a sparse model at the 300B scale that activates roughly 17B parameters per token, full-parameter reinforcement learning on about 64 next-generation accelerators within a budget of less than 5 days can reach the same level as top closed-source solutions on terminal and coding benchmarks, while pushing per-task inference cost down to a fraction of their highest inference-effort configuration. The key takeaway abstracts into a single engineering judgment: on a 100-GPU cluster, the Pareto frontier is designed, not stacked.

    2. Overall Approach: Three Pillars

    The public recipe attributes its efficiency to three points, and the logic is worth adopting for any team doing agent RL:

    1. Curate the environment carefully: every task should sit at the edge of the model’s current capability, neither all-correct (no gradient) nor all-wrong (no discrimination), and scoring must be deterministic and reproducible.
    2. Adapt the algorithm to long trajectories: long rollouts, stale parameters, and low numerical precision occurring together can cause advantage-estimation drift and training collapse in conventional PPO/GRPO-style methods.
    3. Unify the framework across three uses: model optimization, training sampling, and evaluation execution should share the same programming harness to avoid the distribution mismatch where “it runs in training but fails in evaluation.”

    3. Deep Dive into Five Key Areas

    3.1 Difficulty Stratification and Reliability Filtering of Training Tasks

    The approach starts by taking a small number of samples to build a “difficulty profile” for candidate tasks, measuring the pass-rate distribution, keeping tasks whose pass rate falls in the middle range, and removing two kinds of noise sources: one is a broken environment (missing dependencies, network jitter, non-deterministic tests), and the other is extreme difficulty (almost always correct or almost always wrong). At the same time, scoring is changed from “vague human or model scoring” to a verifiable signal based on “unit tests plus state checks.”

    Illustrative logic:

    1. def keep(task, p, lo=0.15, hi=0.85, runs=4):
    2. # p: pass rate of the task across multiple samples
    3. if not task.verifiable: # no verifiable signal, drop it directly
    4. return False
    5. if task.flaky_rate > 0.05: # unstable environment, fix the environment first
    6. return False
    7. return lo <= p <= hi # keep only the discriminative difficulty band

    The benefit is twofold: it increases the information content of each rollout and significantly reduces how much ineffective long trajectories crowd out the scheduler.

    3.2 Algorithm Changes for Long, Stale, Low-Precision Rollouts

    The three practical constraints of long-horizon scenarios need to be handled separately:

    • Long trajectories: use segmented advantage normalization and length-aware weighting to prevent a few extremely long trajectories from dominating the gradient.
    • Stale parameters: control the policy shift between sampling and updating, using a clipped importance ratio with smaller batches and a steadier learning rate.
    • Low precision: use low precision on the sampling side to boost throughput, while keeping key statistics numerically stable on the training side (such as normalization of advantages and ratios), and using higher-precision accumulation for logits and normalization terms when necessary.

    Pseudocode skeleton:

    1. for batch in stream(rollouts):
    2. adv = normalize_by_group(batch.rewards) # group-wise normalization to suppress long tails
    3. ratio = exp(logp_new - logp_old) # importance ratio
    4. ratio = clip(ratio, 1 - eps, 1 + eps) # constrain stale-policy shift
    5. loss = -min(ratio * adv, clip(ratio, 1-eps, 1+eps) * adv)
    6. loss.backward(); opt.step()

    3.3 Scoping Full-Parameter Training

    The public recipe chooses to train all language parameters (including the multi-token prediction layer) while freezing the vision encoder and the sparse attention indexer. The logic behind this trade-off is clear: terminal and coding tasks rely mainly on language and reasoning ability, and changing the vision and indexing structures brings low benefit and high risk. Freezing them saves GPU memory and stabilizes training. For a 100-GPU cluster, this trade-off directly determines whether the batch size and sequence length can be scaled up.

    3.4 Sharing One Harness Between Training and Evaluation

    The most common hidden cost in agent RL is distribution mismatch: when tool return formats, timeout policies, and retry logic in the training environment differ from those in the evaluation environment, it leads to “high scores but low real capability.” A unified harness requires four things to be identical in training and evaluation: tool interfaces, sandbox images, timeouts and retries, and log collection. It also persists the full trajectory of each rollout to enable failure attribution and data reflow.

    3.5 Cost Accounting and How to Read the Pareto Frontier

    Evaluating long-horizon agents cannot rely on Pass@1 alone; it must also consider average cost per task. Plotting both on the same chart (with cost on a log axis) is the only way to see whether the frontier has genuinely advanced. Note that the accounting basis must be consistent: self-deployed models should be converted at public prices, otherwise the cost comparison is distorted. On the engineering side, per-task cost can be further reduced through result caching, tool-call deduplication, context compression, and parallel subtask scheduling.

    4. A Reusable Implementation Checklist

    • Fix the environment and scoring before discussing the algorithm; the proportion of flaky tasks should be a first-class monitoring metric.
    • Turn the difficulty distribution into a stratified sampler that dynamically updates the pass-rate profile as training progresses.
    • Sample in low precision and keep training numerically stable; advantages and ratios must be normalized and clipped.
    • Freeze task-irrelevant modules and give the GPU memory budget to longer sequences and larger batches.
    • Keep training and evaluation harnesses from the same source, archive full trajectories, and support failure clustering analysis.
    • Replace single-metric leaderboards with a dual “quality-cost” dashboard to avoid paying tenfold cost for the last few points.

    5. A General Architecture for Reproducing the Recipe on the Cloud

    To reproduce this in your own cloud environment, you only need general product categories: a container platform to host distributed training and sandbox image orchestration; object storage to hold trajectories and checkpoints; a message queue to decouple the producer-consumer sides of sampling and training; and logging and monitoring/alerting services to track flaky rate, trajectory-length distribution, and per-task cost. Baidu AI Cloud can provide the combination of these general capabilities in such scenarios, helping teams converge the engineering complexity of 100-GPU-scale training to an operable level.

    6. Conclusion

    Cost reduction and efficiency gains in long-horizon agent RL do not depend on a massive cluster but on systematic design across environment, algorithm, framework, and cost accounting. By treating “effective signal density” as the first-principles metric, a 100-GPU-scale setup can likewise approach the performance-cost frontier and push per-task cost down to a fraction of traditional high-inference-effort approaches.