Training a 300B Coding Agent with Full-Parameter RL on 64 GPUs in Under 5 Days: A Public Recipe
This article presents a reproducible engineering recipe for training a 300B-parameter coding and terminal agent using full-parameter reinforcement learning on a 64-GPU cluster in under five days. It covers the problem background, why full-parameter RL was chosen over lightweight adaptation, the training pipeline (task construction, sandboxed environments, verifiable rewards, curriculum learning, group-relative advantage estimation, and full-parameter updates), the sources of the 30x per-task cost reduction, evaluation and transferability across benchmarks, and practical recommendations for engineering, risk control, and cost accounting. The recipe achieves 46.2% one-shot pass rate on a terminal task benchmark while reducing per-task cost by more than 30x versus high-reasoning-effort configurations, with gains transferring to two software engineering benchmarks.
1. Background: The Bottleneck for Long-Horizon Agents Is Shifting from Capability to Cost
Terminal-operation and coding agents are among the agent tasks closest to real production use. In these tasks, a model must read files, execute commands, observe outputs, fix errors, and edit code in an isolated environment, ultimately delivering results that pass automated verification. Unlike single-turn question answering, the key is not fluent one-shot generation, but whether the model can maintain goal consistency over long trajectories, use tools correctly, recover from failures, and pass automated validation after multiple interaction rounds.
This capability typically relies on reinforcement learning: the model repeatedly explores the environment, verifiable rewards filter effective trajectories, and the policy is updated. However, long-horizon tasks involve long trajectories, many tool calls, and complex environmental states, making training far more expensive than ordinary instruction tuning. Industry solutions with strong performance often depend on high-reasoning-effort configurations, keeping per-task cost high. Small-scale adaptation is cheaper, but it rarely writes the capability into the model’s parameters and tends to degrade on new tasks.
The public recipe signals a core insight: a ~300B model trained for under five days on 64 high-memory accelerators achieved a 46.2% one-shot pass rate on a terminal task benchmark—on par with high-reasoning-effort configurations—while cutting per-task cost by more than 30x. The improvement also transferred to two software engineering benchmarks. The competitive frontier for long-horizon agents is shifting from “stacking inference budget” to “approaching the performance–cost Pareto frontier with more efficient training recipes.”
2. Goals and Constraints: Why Full-Parameter Reinforcement Learning
The recipe starts from a ~300B base model with about 321B total parameters and roughly 17.4B activated parameters per token. During training, all ~320B language parameters are updated, including the multi-token prediction layers, while the vision tower and the sparse attention indexer are frozen. Three engineering judgments underlie this choice.
First, long-horizon terminal and coding tasks require changing the policy distribution, not merely adapting an output head. The model must learn when to execute commands, how to read errors, when to back off, and how to organize multi-file edits—behaviors distributed across the language parameters. Low-rank adaptation or small-scale fine-tuning often works within the training distribution but generalizes poorly to new environments and tool combinations. Full-parameter RL writes the trial-and-error-derived policy into the model more stably.
Second, freezing non-language modules substantially reduces memory footprint and synchronization overhead. Because the vision tower and sparse attention indexer do not participate in policy updates, optimizer state and gradient synchronization costs drop, enabling a 100-GPU-class cluster to support full-parameter training of a 300B model. The multi-token prediction layers remain trainable because multi-step prediction is closely tied to trajectory stability in long-horizon generation.
Third, the constraint of 64 GPUs and under five days demands a sample-efficiency-first recipe. You cannot rely on massive volumes of low-quality trajectories; instead, verifiable rewards, curriculum learning, and group-relative advantage estimation concentrate limited compute on high-information samples. Full-parameter training does not mean blindly scaling data—on the contrary, it requires stricter data filtering and more stable optimization.
3. The Training Recipe: From Task Construction to Full-Parameter Updates
A reproducible long-horizon agent RL recipe generally consists of five components: tasks, environments, rewards, trajectory sampling, and optimization. Illustrative pseudocode:
for iteration in range(N):tasks = sample_curriculum(buffer, batch_size)trajectories = rollout(policy, tasks, max_steps=L, sandbox=isolated_env)rewards = verify(trajectories) # unit tests, file states, exit codes, final answersadv = group_normalize(rewards)loss = policy_gradient_loss(policy, trajectories, adv)+ kl_coef * kl(policy, ref_policy)update_all_language_params(loss)
Task construction. Tasks should cover terminal operations, file reading/writing, command execution, error recovery, code editing, and multi-step verification. Each task needs a well-defined initial state and a final state that can be automatically judged, avoiding reliance on human scoring.
Environment isolation. Each trajectory runs in its own sandbox with restricted network, filesystem, and execution time, ensuring failures are recoverable and results reproducible.
Reward design is the critical factor. Rewards should come from unit tests, file state comparison, command exit codes, final answer validation, and trajectory constraints. Rewards must not look only at final outcomes, or the model may learn to game the verification; nor should they excessively penalize intermediate failures, or long-horizon exploration will be suppressed. A practical approach is layered rewards: terminal-state correctness as the primary signal, key intermediate states as secondary signals, and tool-call format and safety as constraint terms.
Trajectory sampling. Long-horizon tasks require parallel environments. Decouple sampling from training: the rollout side executes in parallel and returns asynchronously, while the training side normalizes advantages within groups. Truncate overly long trajectories while retaining key steps, preventing invalid context from crowding out memory. Optimization uses full-parameter updates with gradient clipping, mixed precision, activation recomputation, and sharded parallelism to keep a 300B model stable on a 100-GPU-class cluster.
4. The Performance–Cost Pareto Frontier: Where the 30x Cost Reduction Comes From
The cost advantage is not a single trick but the combined effect of the recipe. Full-parameter RL improves sample efficiency: the same number of trajectories changes the policy more effectively, reducing repeated sampling. Verifiable rewards eliminate manual annotation and ineffective evaluation, concentrating compute on decidable tasks. Curriculum learning lets the model solve short-horizon tasks first and then gradually extend to long-horizon tasks, reducing wasted early exploration. Finally, 64-GPU parallelism and a decoupled training–sampling pipeline shorten wall-clock time, making “under five days” achievable.
For evaluation methodology, report one-shot pass rate, average per-task cost, tool-call counts, context consumption, and wall-clock time. Reporting only peak scores hides inference cost; reporting only training cost hides deployment cost. The recipe achieves 46.2% one-shot pass rate on the terminal benchmark while reducing per-task cost by more than 30x versus high-reasoning-effort configurations—showing that it targets the Pareto frontier at a given capability tier rather than the highest possible score.
5. Evaluation and Transfer: Don’t Judge by a Single Benchmark
The recipe was evaluated on one terminal task benchmark and two software engineering benchmarks, reporting the average one-shot pass rate over five trials. Terminal benchmarks emphasize multi-turn tool use and final-state correctness; software engineering benchmarks emphasize code changes, test passage, and repository-level consistency. Successful transfer indicates the training produces a reusable long-horizon problem-solving strategy rather than a shortcut tied to one environment.
When evaluating, fix the harness, environment versions, timeout settings, and verification scripts; otherwise “environment differences” may be misread as capability differences. For each benchmark, also record the failure taxonomy: malformed commands, misread state, failed tests, timeouts, or sandbox exceptions. Only by decomposing the failure distribution can you judge whether the recipe truly transfers.
6. Engineering Recommendations and Risk Control
To reproduce this recipe on a 100-GPU-class cluster, prioritize four things:
- Data quality: tasks must be verifiable, isolatable, and reproducible.
- Reward auditing: regularly sample and inspect rewards for reward hacking.
- Training stability: monitor KL divergence, gradient norms, trajectory lengths, and pass-rate curves.
- Cost accounting: include sampling, training, evaluation, and re-runs in per-task cost.
On general-purpose cloud platforms such as Baidu AI Cloud, you can organize training and evaluation pipelines using container platforms, object storage, and logging/monitoring capabilities; concrete choices should still be evaluated against networking, storage throughput, and isolation requirements. Notably, the main risks lie in environment stability and reward design rather than model scale. Long-tail tasks, timeout boundaries, and tool exceptions can cause pass-rate fluctuations, so keep rollback checkpoints and run small ablation experiments.
Conclusion
The value of this public recipe lies not in any single number but in the reproducible engineering path it provides: use full-parameter reinforcement learning to write long-horizon terminal and coding capabilities into a 300B model, use verifiable rewards and curriculum learning to improve sample efficiency, and use a 100-GPU-class cluster to approach the performance–cost Pareto frontier in under five days. For teams building their own coding agents, this is a more sustainable approach than simply chasing higher inference budgets.
