Implementing Mixed-Precision RL with Diverse Accelerators for Enhanced Efficiency
- Gate
- Machine Learning
- Departs
- Crew
- Nan Jiang
- Passengers
- 749
Research explores the use of mixed-precision, mixed-accelerator samplers in reinforcement learning, aiming for improved performance and cost-efficiency.

In large-model reinforcement learning (RL), samplers typically operate on the same accelerators and usually maintain a consistent precision as the trainer. This alignment helps stabilize training due to numerical proximity. However, outside of RL environments, systems are more flexible, often optimizing for speed and cost by utilizing low-precision formats such as FP8, MXFP4, and NVFP4. These formats can be paired with specialized kernels and accelerators specifically designed for long-context prefill tasks.
Sampling currently accounts for approximately 80%–85% of the GPU usage in extensive RL operations, indicating substantial optimization opportunities. The focus of this research is to determine if we can implement mixed-precision, mixed-accelerator samplers that employ different kernels while ensuring training remains stable and effective.
Identifying Challenges
Two significant challenges are evident in this approach:
The first challenge is related to learning. The integration of various optimizations can lead to mismatches between training and inference, resulting in samples that deviate from the optimal policy. This off-policy correction is a viable solution, as it allows a trainer to learn from data generated by different policies, like outdated samples in asynchronous training, without making assumptions about the discrepancies in the two policies.
The second challenge arises from the systems architecture. Traditional RL infrastructures often rely on homogeneous accelerator clusters, while mixed samplers necessitate a system of autoscaling accelerators capable of operating with their own precisions and kernels.
Through the combination of off-policy correction and our autoscaling, serverless GPUs, we demonstrate the feasibility of achieving stable, high-performance RL at a reduced cost using mixed-precision, mixed-accelerator samplers. Our experiments involve fully asynchronous training of an open-weight model in agentic coding tasks.
Experimental Setup
Our training focuses on the Qwen3.6-35B-A3B, engaging with agentic coding across a maximum of 256K tokens of context. We utilize the 2.7K repository tasks provided by Xiaomi released with the MiMo-V2.6, while ensuring the removal of the repository history to prevent data leakage. In every episode, the model constructs and submits a patch through a bash tool in a Modal Sandbox. The model earns a reward of 1 for submitting a passing patch and 0 for any failures. We evaluate the performance using SWE-bench Pro V2, which does not overlap with our training dataset, and a difficult subset termed HARD-51. Each checkpoint's performance is assessed in BF16 format.
For our RL framework, we employ Miles along with SGLang samplers and a Megatron-LM trainer that updates the policy in BF16 on B200 GPUs. This training setup operates fully asynchronously without any restrictions on staleness, utilizing 128 prompts with 8 trajectories per update. Each sampler operates with its own accelerator, precision, and kernels, while the trainer refrains from using their MoE routing decisions.
The samplers function within two configurations:
- The mixed samplers encompass six types of accelerators: B200 and B300 utilizing NVFP4 weights, H100 and H200 using FP8 and BF16 weights, and A100 and RTX PRO 6000 serving BF16 weights. Each sampler employs its accelerator's specific kernels and maintains its Key-Value (KV) cache in FP8. A routing mechanism allocates each agent session to one of these groups based on their serving capacities, ensuring a balanced share of requests throughout training.
- In contrast, the homogeneous samplers are confined to B200 with BF16 weights and a BF16 KV cache. They align with the trainer's accelerator and precision to ensure that only differences in kernels and staleness distinguish them.
Hosted on Modal, each sampler group scales dynamically as required, ensuring they can serve the trainer's most recent weights in their respective precision formats.
Ensuring Stability in Mixed Sampler RL
Our starting approach utilizes the GRPO framework without corrections for inconsistencies. We implement three pivotal strategies:
- Masked importance sampling (MIS) adjusts weights based on importance ratios. This involves multiplying each token's term by its importance ratio and masking tokens whose ratio lies outside a predetermined range, ensuring that the remaining tokens maintain expected updates in line with the training policy. If unmasked, rare tokens can significantly skew results.
- Score centering (SC) mitigates drift. At every token position, it deducts the expected gradient of the log-probability under the sampling policy, maintaining that only differences in advantage influence the policy adjustments. While MIS addresses weighting discrepancies, it may inadvertently introduce drift.
- Top-p sampling with mask replay (top-p) prevents the inclusion of rare tokens and standardizes support across both policies. The samplers draw from a finite top-p candidate set, ensuring rare tokens don’t feature in the sampled data. The trainer then renormalizes probabilities over this same candidate selection. Runs lacking this feature typically sample from the entire vocabulary.
Every token generated influences its associated update by adding its advantage multiplied by the gradient of its log-probability. By integrating MIS, SC, and top-p together, we achieve a system that reweights based on importance, centers the gradient, and uniformly restricts candidate sets across policies.
Experiments indicate that without these corrections, the training collapses across both setups—GRPO quickly fails in the mixed sampler configuration, while the homogeneous approach sustains longer before eventual failure. Notably, combinations of SC and MIS, whether or not coupled with top-p, manage to maintain stability, resulting in pass@4 scores on HARD-51 that peak at approximately 65% to 75%, whereas the entire dataset rises from 89% to around 94%.
Collapsed episodes typically exhibit distinctive behaviors: training rewards decline, sampler–trainer KL diverges significantly, and episodes frequently conclude with repetitive format errors. No consistent length patterns emerge for trajectories, though some runs finish early while others might continue long but with repetitive tasks. Notably, stable runs do not display these negative signs. The homogeneous samplers’ GRPO, despite starting at a lower KL divergence, remains subject to collapse, following similar trajectories as the mixed samplers.
In collapsed episodes, malformed commands are rarely produced. Instead, the model tends to stop calling its tool midway through tasks, leading to an episode end once there are three consecutive turns without a tool call. For instance, in the GRPO’s step-40 checkpoint using mixed samplers, around 62% of evaluation episodes end prematurely, averaging just 22 turns in contrast to the 57 turns for successful episodes, with 98% of the last replies being empty.
Cost Efficiency of Mixed Samplers
Utilizing the combination of SC, MIS, and top-p, the mixed samplers achieve SWE-bench Pro V2 scores that are comparable to those obtained by homogeneous samplers, with pass@4 rates remaining closely aligned throughout training. Additionally, metrics like training rewards and gradient norms reflect similar trajectories. Notably, this occurs despite a 4.7× greater average KL divergence compared to homogeneous setups. Until approximately step 160, entropic behaviors remain consistent, after which they diverge, with entropy increasing in homogeneous setups while remaining stable in mixed samplers.
Decoupling samplers from the trainer has allowed for significant cost reductions during the training phase. Throughout the majority of the training process, mixed samplers demonstrated an approximately 15% reduction in cost per update compared to their homogeneous counterparts. It's essential to recognize that while our experimental setup primarily targeted showcasing the potential of mixed-precision, mixed-accelerator samplers, ample opportunities for cost savings exist; for example, each sampler can be optimized individually, with the possibility of shifting the mix to prioritize lower-cost options.
Understanding Training-Inference Mismatch
Mismatched token probabilities during sampling can lead to discrepancies between the outcomes from the sampler and those from the trainer. These discrepancies stem from multiple potential sources within the RL system:
| Source | Examples | Effect |
|---|---|---|
| Kernels | Differences in inference and training kernels; lack of batch invariance | Different outputs for identical inputs, even at the same precision |
| Precision | BF16; FP8; MXFP4; NVFP4 | Variations in precision (mantissa bits) and dynamic range (exponent bits, block scaling), leading to divergent rounding errors; mismatch can escalate as computations increasingly utilize quantization |
| Accelerator | Architecture-specific kernels and number formats: absence of FP8 tensor cores on A100 or FP4 tensor cores on Hopper | Variation in mismatch across different accelerators utilizing identical code |
| Policy Staleness | Asynchronous RL frameworks wherein samplers lag behind training steps; partial rollouts; in-flight weight updates | Escalating mismatch correlated with policy staleness |
| Routing | Top-k expert selection; inconsistencies with the sparse-attention indexer’s top-k selection | Router inconsistency: two systems might select different experts, or different key-value entries, for a single token |
| Top-p / top-k Sampling | Tokens are selected exclusively from top-p or top-k candidates | Discrepancies in action spaces that can destabilize training |
| Multi-turn Context | Detokenizing and retokenizing processes; chat templates that reformat previous turns or obscure reasoning | Training scores may evaluate tokens in contexts that the model has not seen |
| Source | How it is matched | Cost |
|---|---|---|
| Kernels | Use batch-invariant, deterministic kernels across both platforms | Resulting in slower sampling, or the need for model-specific kernel development |
| Precision | Maintain identical formats on both ends | The trainer must be constrained to the samplers’ format, with no single low-precision compute format universally applicable across all accelerators, such as the absence of FP8 tensor cores on A100 or FP4 on Hopper |
| Accelerator | Sampling and training conducted on the same generation of accelerator | Limits the use of all other accelerators |
| Policy Staleness | Synchronous RL, with only one update per batch | Results in throughput trade-offs against asynchronous RL |
| Routing | Utilization of routing replay for rollouts | Would necessitate biased target policies, alongside memory and communication overheads; for the indexer, this incurs substantial overheads |
| Top-p / top-k sampling | Employing top-p / top-k mask replay | While this aligns the candidate sets, it does not synchronize probabilities; entails storage and transfer overheads for mask data |
| Multi-turn context | Implementation of token-in-token-out method | Requires longer contexts if the earlier reasoning is preserved; entails higher computational requirements if omitted |