AI Engineer21 min
Training Your Own Agent Models With RL Is Now Practical - Jason Mancuso, Modal
Conference Presentation
- Strategic Shift in AI Engineering: Relying solely on swapping static, off-the-shelf models is a losing strategy for competition; success requires optimizing for both agent economics and user experience through vertical integration.
- Drivers for Fine-Tuning Adoption:
- Reliability SLOs: Enterprises require consistent Service Level Objectives that out-of-the-box open-source models often fail to meet without degradation.
- Proprietary Data: Agents must reason over proprietary datasets absent from pre-training corpora, forcing fine-tuning of open-source models as the only viable path.
- Competitive Differentiation: Industries are increasingly vertically integrating across the stack to compete on "task intelligence per dollar," a trend expanding beyond coding into broader sectors.
- Reinforcement Learning (RL) vs. Supervised Fine-Tuning (SFT):
- SFT is brittle for agents because it trains on static production traces, failing to account for the branching, multi-turn decision trees agents face in production.
- RL dominates the fine-tuning paradigm because the model can explore all potential execution branches during training, leading to better generalization.
- Production as an RL Environment: Organizations can leverage existing production harnesses and A/B tests or evals to synthesize high-quality training tasks, specifically mining failure cases from live user traces to direct fine-tuning improvements.
- Asynchronous RL Architecture:
- Traditional sequential RL (rollout then train) wastes significant GPU compute; parallel asynchronous execution increases utilization but introduces "staleness" where rollouts are generated by older model versions.
- System-level mismatches (e.g., kernel differences between trainer and samplers) create distribution shifts that destabilize training if uncorrected.
- The Stable RL Recipe: A newly refined training methodology achieves stability despite high staleness and hardware heterogeneity through four key mechanisms:
- Masked and Packed Sampling: Corrects for token-wise mismatches caused by staleness and system-level differences.
- Score Centering: Removes cumulative weight drift over time that persists even after token-wise corrections.
- Top-P Sampling with Mass Replay: Prevents catastrophic failures when trainers sample rare tokens that samplers exclude via Top-P constraints; this technique allows Score Centering to be exact rather than approximate.
- Empirical Validation: Ablation studies on Qwen 3.6 35B MoE (trained on MIMO code, evaluated on SWE-bench Pro) demonstrate significantly higher stability when combining all recipe components compared to individual techniques.
- Modal's Infrastructure Challenges & Solutions:
- Fragmentation: Modal's multi-provider fleet (15-20 providers including hyperscalers and neoclouds) makes scheduling large, contiguous clusters difficult.
- Inference/Training Ratio: RL typically requires a 2:1 ratio of inference GPUs to training GPUs, meaning large clusters are often underutilized for the actual trainer.
- Sparse Delta Compression: Model weight updates are 100x-1,000x sparser than full weights; compressing these deltas reduces communication bandwidth by a factor of 1,000, enabling inference GPUs to run outside the main training cluster.
- Heterogeneous Hardware Execution:
- The RL recipe successfully handles extreme hardware mismatch, running trainers on H200s while rollouts occur across B200s, H100s, and A100s simultaneously.
- Training remains stable even when rollouts utilize up to 4-5x more hardware mismatch than in homogeneous setups, with no degradation in reward or gradient norms.
- Cost Optimization Results:
- Running rollouts on cheaper, fragmented GPU pools resulted in a 15% reduction in total run costs compared to homogeneous high-end GPU clusters.
- The system effectively learns from mixed-precision rollouts (e.g., BF16 vs. FP8) on the same hardware, with correction mechanisms absorbing quantization-induced mismatches.
- Open Source & Availability:
- The underlying implementation is built on Milvus and SGLang, with source code scheduled for release via an accompanying blog post.
- The speaker asserts that owning the full agent stack, including custom RL infrastructure, is now feasible and critical for maintaining a competitive edge in the industry.