Long-Horizon Agent RL on 100 GPUs: A Five-Day Recipe for Efficient Training
This article explains how a 100-GPU-class cluster can train long-horizon agents with reinforcement learning in about five days while cutting per-task cost by more than an order of magnitude. It covers the three reusable pillars behind the result: online difficulty filtering to keep only informative tasks, an algorithm recipe for long, stale, low-precision rollouts, and a shared harness for training, inference, and evaluation. It also breaks down practical cost controls across inference, sampling, storage, and scheduling, and lists common pitfalls to avoid.
1. Why Long-Horizon Agents Are Expensive
Long-horizon agents are moving beyond short interactions such as fixing a single bug toward continuous terminal operations and software engineering tasks that run for hours. As tasks get longer, cost does not grow linearly; it amplifies combinatorially. A single training sample can be a full attempt lasting three hours with over a hundred tool calls, and any failure along the way wastes hours of cluster time.
Traditionally, only frontier labs with thousands of accelerators dared to scale this kind of reinforcement learning at large scale. For most teams, the bottleneck is not access to GPUs but the compute efficiency per effective sample. That is why a clear direction in the industry is to approach the frontier performance–cost Pareto frontier with a 100-GPU-class cluster. The Pareto frontier is the set of configurations with the lowest cost at a given task success rate, or the highest success rate at a given cost. It is commonly measured with Pass@1 (single-attempt pass rate) and average cost per task, usually on a log scale.
2. Three Reusable Pillars
A publicly shared recipe from one research team starts from a sparse model with about 321B total parameters and roughly 17.4B activated per token, runs full-parameter reinforcement learning over all ~320B language parameters (including the multi-token prediction layers), freezes the vision encoder and the sparse attention indexer, and ends up matching the strongest closed-source solutions on terminal and coding benchmarks while keeping per-task cost more than an order of magnitude lower. Abstracted from this result, only three things are reusable.
2.1 Environment Filtering: Make Every Task Worth Learning From
The biggest waste in long-horizon RL comes from uninformative samples: easy tasks carry no gradient signal, and extremely hard tasks almost always fail, so they provide no discrimination either. In practice, you should build difficulty stratification and signal reliability checks: sample a task multiple times with the current policy, look at the distribution of pass rates, and prioritize tasks whose pass rate falls in a middle band (for example, 0.2–0.8). Remove tasks whose environment is unstable, depends on external networks, or produces non-reproducible results.
Illustrative filtering logic:
# Pseudocode: online difficulty stratification based on pass ratedef keep_task(task, policy, n=8, lo=0.2, hi=0.8):passes = sum(run_episode(task, policy) for _ in range(n))rate = passes / nreturn lo <= rate <= hi and task.is_reproducible()
The payoff is a significant increase in effective gradients per GPU hour, so long-tail failures no longer eat compute.
2.2 An Algorithm Recipe for Long, Stale, Low-Precision Rollouts
Long-horizon rollouts have three natural characteristics: long trajectories (hundreds of tool calls), stale data (a time gap between sampling and updates), and low numerical precision (low-precision inference and storage for throughput). Applying short-horizon RL naively becomes unstable. Engineering practice usually mitigates this in four ways:
- Use clipped importance sampling ratios to control the shift from stale data, and cap the number of update steps;
- Normalize advantages at the trajectory level to avoid variance accumulation across long sequences;
- Apply loss masking to tool calls and reasoning segments, computing gradients only on the decision tokens the model itself generates;
- Use a “partial rollout + resume” mechanism that slices and saves overly long trajectories to avoid recomputing whole segments.
Illustration:
# Pseudocode: stale data + clipping + maskingratio = exp(logp_new - logp_old) # apply numerical stabilization first under low precisionratio = clamp(ratio, 1 - eps, 1 + eps)loss = -min(ratio * adv, clamp(ratio, 1-eps, 1+eps) * adv)loss = (loss * decision_mask).sum() / decision_mask.sum()
2.3 One Shared Harness for Training, Inference, and Evaluation
The “environment” of a long-horizon agent is essentially a file system, a terminal, and test commands. If training uses one framework and evaluation uses another, metrics are not comparable and transfer ability gets overestimated. A shared harness means the same sandbox image, the same timeout and retry policy, and the same log collection format, which keeps the training signal aligned with the evaluation criteria and makes failures attributable. Supporting engineering elements include containerized sandbox isolation, unified logging with monitoring and alerting, and replayable trajectory archives.
3. Cost Control: Treat Cost per Task as a First-Class Metric
In long-horizon settings, cost ≈ average trajectory length × per-step inference cost × number of samples. Actionable ways to cut cost:
- Inference side: self-host models and convert cost using public price references for easier comparison; use paging or prefix reuse for long contexts to reduce repeated computation.
- Sampling side: adapt the number of samples, sampling less on easy tasks and more on hard ones; early-stop trajectories that are clearly failing.
- Storage side: tier rollouts and logs to object storage, keeping hot data local and archiving cold data.
- Scheduling side: use elastic scaling on the container platform, slice long tasks into small preemptible units, and use a message queue for task distribution and failure re-delivery.
4. Practical Advice and Common Pitfalls
- Validate on a small cluster first whether difficulty stratification actually improves the effective sample rate, then scale up;
- Before full-parameter training, confirm which modules are frozen (the vision tower and sparse indexer can usually be frozen to save memory and compute);
- Always average over multiple evaluation runs, since a single run is extremely noisy;
- Watch out for inflated metrics caused by mismatched training and evaluation frameworks;
- If you use cloud resources, build a closed loop with a container platform, object storage, logging, and monitoring/alerting so engineering time is not lost to environment drift.
5. Conclusion
A 100-GPU-class cluster is not limited to running scaled-down experiments. When environment filtering, the algorithm recipe, and a unified harness are all in place, long-horizon agent RL can approach the performance–cost Pareto frontier: transferable ability across multiple software engineering benchmarks, with a very short training cycle and very low per-task cost. For most teams, the value of this methodology outweighs any single model, because it determines whether your compute is wasted or compounded.
