AI Trends

MiniMax Releases Forge V2.0 to Support Cluster-Scale Agentic Reinforcement Learning for M4

MiniMax BlogUpdated Dec 4 19:10

AI summary

MiniMax has released Forge V2.0 to support agentic reinforcement learning for M4 at the scale of 3T parameters, a 1M-token context window, and 10,000 accelerators. Its predictive rollout scheduling increases effective throughput by 51% compared with a fixed P/D configuration, while Fast MegaEngine reduces tail trajectory inference time by approximately 60% in production long-horizon agentic tasks. The system also improves training-inference coordination, expert switching, multimodal training, and fault recovery through Tree-MSA, Rollout-Driven EPLB, a shared Vision Encoder, Checkpoint Service, and AFlow.

Why read this

SelectedAI score 67

The article breaks down the scheduling, training-inference coordination, and fault-tolerance solutions used for agentic reinforcement learning at the 10,000-accelerator scale, offering transferable insights for designing large-scale training systems.

Topics

Tags

Body · AI translation

We recently released MiniMax M4, setting a new state of the art among open-weight models across coding, long-horizon agentic tasks, and multimodal reasoning. Behind these gains, large-scale reinforcement learning (RL) served as the core engine turning post-training compute into frontier model capability.

When we released M2.5, we published a blog post introducing Forge, our first-generation native Agent RL framework. In Forge V1.0, we first got end-to-end RL working across arbitrary black-box and white-box agents—answering the question of whether we could train them at all—alongside an initial round of performance optimizations. With Forge V2.0, we went a step further and tackled RL scaling at 3T parameters, a 1M context window, and 10,000-accelerator cluster scale, pushing the stability, throughput, and flexibility of large-scale RL to a new frontier. In this post, we'll walk through our end-to-end approach across RL infrastructure, training and inference systems, and RL training recipes.

Overview

What Problems Are We Solving?

Every day during M4 development, dozens of Domain-Expert RL and Multi-Teacher On-Policy Distillation (MOPD) runs executed in parallel across a 10,000-accelerator cluster. Operating at that scale forced us to confront three core problems:

Training stability

RL correctness—across both training recipes and underlying systems

Cluster efficiency, i.e., per-rank rollout and training throughput

Together, these three factors dictate how many RL runs we can complete, how much data we can push through them, how much of what comes out is statistically trustworthy, how many research ideas we can validate, and ultimately how much capability gain lands in the final model. Everything in Forge V2.0 was built around these three pillars.

Overall Architecture

Figure 1 shows the overall architecture of Forge V2.0. At a high level, we retain our colocated rollout-and-training paradigm with Partial Rollout. On the rollout side, scheduling centers on a Predictive Scheduler paired with Encode–Prefill–Decode (EPD) disaggregation: instances hot-switch roles proactively ahead of load shifts, while predicted long-tail trajectories are routed in real time to our ultra-low-latency Fast MegaEngine. Meanwhile, the Vision Encoder is broken out into a dedicated node pool shared between inference and training. Where Forge V1.0 only isolated agent logic at the code level, V2.0 spins out agent-harness integration, wire protocols, and upper-layer task orchestration into an independent framework called AFlow—onboarding diverse agent harnesses and sandboxes non-invasively through a standard gateway. Finally, to keep runs resilient and data moving at memory speed, we added a unified Checkpoint Service and a cluster-wide standby node pool.

For MOPD, where dozens of teacher experts need to score trajectories concurrently without tying up dedicated hardware, we introduced on-demand expert hot-switching. On the algorithmic side, we designed our Expert RL and MOPD recipes from first principles around stability and numerical correctness—spanning training objectives, low-precision FP4 training recipes, and optimizer dynamics.

Figure 1. Overall architecture of Forge V2.0.

Prediction-Centric Rollout Scheduling

Predictive Rollout Scheduling

Across and within iterations of Agent RL, inference load swings dramatically. At the start of every iteration, updated policy weights invalidate the previous round's KV caches, forcing every active trajectory through a wave of full-context reprefills. Mid-iteration, the optimal Prefill-to-Decode (P/D) ratio continues to shift as multi-turn sessions progress. And toward the end of an iteration—even with a Windowed-FIFO controller in place—straggling trajectories inevitably leave serving concurrency sparse.

Reacting passively to current traffic—say, flipping P/D roles after queues have already piled up—is really an online-serving mindset, where you have no control over when external requests arrive, how many show up, or how they are spaced. RL rollout, by contrast, is a closed, globally controlled system. Total concurrency is set by us. The system knows when every session enters and exits, which turn each active session is on, what tool it is currently running, and how much context it has accumulated. Once a tool call finishes, the session either moves straight into its next inference turn or exits for good; even simulated user turns fire instantaneously, free from unpredictable human think time. In short, upcoming inference demand over the next horizon can be computed and forecast ahead of time—letting us reshape serving capacity before traffic shifts.

Building on this observation, we designed our RL scheduling stack around predictive rollout scheduling. Inside AFlow, we maintain a Global Session Table tracking the live state of every session across external agent harnesses and sandboxes. From those live states, a model-based predictor estimates remaining tool-call duration and tool-output token length, reporting its forecasts to Forge at a fixed cadence (every 5 seconds in production). On the Forge side, the global RL Scheduler runs a cluster-wide cost model over continuously updated prefill and decode profile tables, weighing projected throughput gains against the cost of P/D switching itself. Whenever a candidate P/D split clears a net-benefit threshold over the lookahead window, the scheduler triggers the switch proactively.

For lookahead scheduling to pay off end to end, two assumptions have to hold: reconfiguration overhead must be tiny, and workload predictions must be accurate. On M4, Forge performs in-place P/D hot-switching in 5–10 seconds—adding virtually zero overhead beyond the unavoidable weight communication and resharding across differing Prefill and Decode parallelism layouts. All runtime states, execution graphs, and metadata required by both roles are pre-captured at startup within reserved virtual address spaces, while physical accelerator memory is mapped on demand only to whichever role is currently active. Compared with a fixed P/D split and lagging reactive switching, predictive rollout scheduling boosts effective rollout throughput (completed trajectories per unit time) by 51% and 13%, respectively.

Figure 2. Coordinated predictive rollout scheduling between AFlow and the Forge RL Scheduler.

Predictive Rollout Scheduling handles P/D balance under normal load, but in long-horizon Agent RL, tool-call counts and generation lengths vary wildly across trajectories, leaving a stubborn long tail from a handful of slow sessions. Under strict on-policy RL, that tail leaves most accelerators sitting idle at the end of every iteration; under Partial Rollout (Windowed-FIFO), the slowest unfinished trajectory gets stuck at the head of the window and blocks completed groups behind it from entering training, while ultra-long trajectories that span multiple iterations accumulate severe off-policy staleness. To attack both problems, we pair Semi-Async execution with Fast MegaEngine (Figure 3)—cutting end-of-step idle bubbles in on-policy runs, and either raising throughput within the same FIFO window or tightening the window to reduce off-policy lag at matched throughput.

Conventional colocated setups have to pause every unfinished trajectory the moment training starts, whereas fully disaggregated async setups lock into a fixed compute split and struggle to bound global off-policy drift. Forge's Semi-Async mode keeps the vast majority of nodes colocated, carving out only a small slice of compute during the training window to run Fast MegaEngine so unfinished stragglers can keep executing tool calls and decoding. As shown in Figure 3, under OPD, student rollout nodes pause new trajectory generation once they switch to Trainer, while Expert Nodes—which need only part of their capacity to finish residual scoring—hot-switch their idle nodes directly into Fast MegaEngine to drain stragglers. In pure RL runs without teacher experts, a small subset of nodes in the colocated pool stays on Fast MegaEngine while the rest switch to Trainer, with updated weights synchronized across all nodes once the step finishes.

On the scheduling side, as soon as the opening prefill/reprefill wave clears, the RL Scheduler dynamically decides which active sessions to route to Fast MegaEngine. Routing priority blends AFlow's forecasts—remaining turns, output length, and tool runtime—with how severely a trajectory is blocking the training window: for instance, the last unfinished trajectory in a prompt group, or a straggler sitting at the head of the FIFO window holding up multiple completed groups behind it, gets promoted to the fast lane first within concurrency limits.

On the engine side, prior megakernel efforts have largely targeted single-request benchmarks and struggle with fluctuating multi-request concurrency in real workloads. In Fast MegaEngine, we built production-grade, multi-batch persistent megakernels and static execution graphs tailored for M4—fusing sparse attention, MoE, and DSpark speculative decoding while stripping out cross-process scheduling and synchronization overhead at small batch sizes. At a DSpark acceptance length of 5, Fast MegaEngine exceeds 835 tok/s for a single request and reaches 4,550 tok/s aggregate throughput at 32 concurrent requests. On production long-horizon agent workloads, this cuts long-tail trajectory inference time by roughly 60% and speeds up end-to-end rollout by 1.2×–1.3×.

Figure 3. Execution timeline across a single RL and OPD iteration.

Throughout an RL run—whether synchronizing weights from trainer to rollout, hot-switching prefill and decode instances, or time-multiplexing teacher checkpoints in MOPD—massive weights have to be converted and moved reliably at high speed. Standard storage services aren't built to span shared filesystems, host DRAM, and accelerator HBM, while existing tiered-memory stores don't handle the messy weight-layout conversions and resharding required across training and inference engines. We built Checkpoint Service to unify multi-tier high-speed storage with general-purpose weight transformation under a single plane, keeping weights flowing rapidly across every component in the RL loop.

Multi-expert scoring in MOPD is a prime example. A single M4 MOPD run may have 40+ domain-specialized expert models scoring student-generated trajectories at once. Because traffic across domains is heavily skewed, dedicating a separate serving instance to every expert leaves most instances sitting idle for the majority of the step. Time-multiplexing multiple experts onto a shared pool of instances is the only way to keep per-instance compute saturated.

Figure 4. Per-instance scoring throughput with expert hot-switching disabled (a) vs. enabled (b).

Sharing instances across experts only works if weight switching is fast enough—if every switch had to read from shared disk storage, a hundred-second load stall would wipe out any compute savings. Checkpoint Service pre-stages expert weights from disk into the distributed memory pool ahead of time; when the Expert Scheduler issues a switch command, the target instance pulls its required weight shards directly over RDMA.

In normal operation, the Expert Scheduler only triggers a switch when a candidate expert's queue depth substantially outweighs that of the currently resident expert, amortizing switch cost (Figure 5a). However, the moment the next training batch is held up solely by a few unscored trajectories, the scheduler flips into blocking mode and preemptively switches instances to drain whichever expert is stalling the head of the FIFO window (Figure 5b).

To push switch latency even lower, we introduced Delta-Based Expert Hot-Switching. Because our domain experts are all fine-tuned from a homologous base checkpoint, pairwise weight differences between them are sparse and small. We precompute and compress these weight deltas into the storage pool ahead of time; on a switch, instances pull only the compressed delta over RDMA and decompress it directly on the accelerator. In practice, compressed deltas take up just 1%–10% of a full checkpoint's footprint—letting us keep far more experts resident in the memory pool while cutting 3T-model expert switch latency to under 10 seconds.

Figure 5. Normal mode (a) and preemptive blocking mode (b) for MOPD expert hot-switching.

Rollout–Training Co-Optimization

What sets RL apart from standalone training is that the trainer consumes trajectories generated by its own rollout engine. That tight coupling cuts two ways. First, training and inference must behave identically down to the numerics so policy updates stand on solid ground (once that invariant is locked down, you stop burning cycles second-guessing phantom numerical bugs). Second, rollout naturally produces rich structural metadata—token distributions, multi-turn call trees, MoE routing traces—that can accelerate training, while updated states from training can feed right back into the next rollout round. We built a set of co-optimizations around both sides of this loop.

In Forge, we wanted forward passes in training and rollout to match exactly. Historically, the two sides drifted apart because of subtle implementation differences—different kernel fusions, reduction orders, and rounding points—compounded on the inference side by batch composition, token counts, prefill vs. decode paths, and prefix-cache hits. In V2.0, our goal was to make bitwise alignment between training and inference output distributions our everyday production configuration. Achieving this comes down to two steps:

Enforcing batch invariance: ensuring each engine produces identical outputs regardless of batch size, chunking, or parallelism split—for example, using split-k=1 GEMMs and fixed reduction trees for tensor-parallel all-reduces.

Aligning module by module: sharing identical quantizers and quantized byte layouts alongside identical (or mathematically bit-equivalent) kernels—for instance, matching router and indexer scoring and top-k block-selection logic across both stacks.

A naive implementation of bitwise alignment typically tanks throughput too severely to run in production, making performance preservation just as critical as numerical exactness. Our guiding rule was to protect rollout performance first—since rollout dominates RL wall-clock time—and otherwise align each operator toward whichever side faces tighter performance constraints. For performance-critical rollout modules like MoE, we keep the inference kernel and have the trainer call inference-side MegaMoE in place of its native MoE layer; for lightweight ops that barely register in inference wall time (such as RMSNorm), inference mirrors the training implementation instead, backed by custom fused kernels to amortize layout conversions and glue ops. Crucially, we preserve exact bitwise alignment even with complex optimizations like Fast MegaEngine and Tree-MSA turned on. The resulting efficiency ratios (aligned vs. unaligned, with further headroom remaining) are summarized below:

Stage Efficiency Ratio (Aligned / Unaligned)

In our Forge V1.0 blog post, we introduced prefix-tree merging to eliminate redundant prefix recomputation in long-horizon multi-turn agent interactions caused by retokenization or harness-side context rewrites. As M4 moved to a sparse attention architecture, we extended this idea into Tree-MSA.

We merge all branches of a trajectory into a single prefix tree and flatten it into a 1D sequence in heavy-path-first order (traversing the largest subtree first). This ordering clusters each branch's visible ancestor prefix into a small number of contiguous spans, preventing severe tree-mask fragmentation; at the same time, when an oversized tree exceeds packing capacity and has to be split across rows, heavy-path-first traversal keeps the main trunk intact in a single sequence and sharply reduces prefix duplication. Underneath, we co-adapted both context parallelism and our sparse attention kernels: context parallelism rebalances per-rank workloads by true visible attention area while hiding communication behind coalesced transfers and compute overlap, and the sparse attention kernels precompile tree masks into cross-layer reusable execution plans—delivering compute efficiency on par with standard causal sequences.

Figure 6 shows end-to-end training results on the multi-turn tool-use benchmark AutomationBench (against a baseline that already has V1 prefix merging enabled, where all branching comes from retokenization). With Tree-MSA enabled, the reward curve tracks the baseline throughout training (Figure 6, left); as training progresses and responses grow longer with more interaction turns and denser branching, late-stage per-step training speedup reaches 1.77× (Figure 6, right). On more complex long-horizon tasks with longer generations or frequent context rewrites, the end-to-end gains are larger still.

Figure 6. End-to-end training comparison with and without Tree-MSA: reward curve (left) and training time per step (right).

Rollout-Driven EPLB

On a 3T sparse MoE model, expert load imbalance hurts both training and inference throughput. In pre-training, Expert Parallelism Load Balancing (EPLB) has to extrapolate upcoming load from historical steps. In RL, however, every training step directly consumes trajectories just produced by rollout: the per-token routing trace recorded during rollout is already the exact load distribution of the upcoming training batch, and a strong leading indicator of hot experts in the next rollout round. We take advantage of this loop by having inference engines return per-token expert assignments directly, driving a joint Rollout-Driven EPLB scheme across training and inference (Figure 7):

Training side: Constrained by HBM capacity and inter-node bandwidth, the trainer cannot dynamically replicate experts wholesale across the cluster. Instead, before each training step begins, we run a cross-node Expert Shuffle based on mini-batch routing counts collected during rollout; then, as individual layers hit localized hotspots inside the step, we perform on-the-fly intra-node Expert Replication, streaming hot expert weights into a shared temporary buffer on peer accelerators within the node and immediately reusing that buffer for the next layer—adding zero permanent memory per replica.

Inference side: Piggybacking on per-step weight synchronization, inference instances rearrange cross-node expert placements and redundant replica slots using the previous round's routing statistics.

Working together, this cuts training step time for a ~15% training efficiency gain over a no-EPLB baseline, boosts Decode throughput by 18%, and delivers a 6% Prefill throughput gain in small-EP configurations.

Figure 7. Joint training-and-inference expert load balancing via Rollout-Driven EPLB.

M4 relies on a lightweight draft model, DSpark, for speculative decoding during rollout. Left frozen during RL, however, DSpark gradually falls out of sync as the target policy drifts, causing its expected acceptance length (EAL) to decay steadily (Figure 8, gray curve). Our first attempt was straightforward online co-training: computing the DSpark loss at every RL step, updating the draft weights, and syncing them alongside the main policy to inference engines. The result was underwhelming—the EAL curve under naive co-training overlapped almost completely with the frozen baseline (Figure 8, purple curve) and failed to arrest policy drift.

Digging into the data revealed a subtle distribution mismatch: during rollout, draft tokens are rejected far more often at high-entropy positions of the target policy, and every rejection immediately becomes the starting position (anchor) for the next speculative draft block. Real rollout anchors are therefore heavily skewed rather than uniform across a sequence. Uniformly sampling training anchors across the full sequence wastes most of the supervision budget on easy, low-entropy positions where acceptance is already high. To fix this, we built Rollout Anchor Replay (RAR): rollout logs the exact anchor positions where speculative drafting actually occurred, and training samples anchors exclusively from those recorded positions. On Coding RL, while a frozen draft sees its EAL slip from a 4.42 mean over the first 10 steps to 4.23 over the final 10 steps, adding RAR keeps EAL locked cleanly between 4.4 and 4.6 throughout training (Figure 8).

Figure 8. Expected acceptance length (EAL) on Coding RL across a frozen draft model, joint training without RAR, and joint training with RAR.

Shared Vision Encoder

In a naive multimodal RL stack, every image gets preprocessed and run through the ViT twice—once during rollout and again during training. Whenever the ViT is frozen during RL and preprocessing plus ViT execution are bitwise-aligned across both stacks, the trainer can simply reuse the exact ViT embeddings already computed during rollout. Under EPD disaggregation, turning the Vision Encoder into a shared pool between inference and training is a natural step: ViT embeddings computed during rollout are written once to the global storage pool and reused across both multi-turn Prefill requests and the Trainer. This eliminates all visual recomputation during training, clears raw images and ViT activations out of trainer HBM, and keeps heterogeneous ViT compute from disrupting pipeline-parallel balance—lifting end-to-end multimodal RL throughput by 5%–10%, depending on visual workload intensity.

Fault Tolerance and Stability

With dozens of jobs running side by side every day on a 10,000-accelerator cluster, handling hardware and software faults gracefully is a day-one requirement rather than an edge case. Fault tolerance in RL is trickier than in pre-training for two reasons: Trainer and Rollout engines have very different fault-tolerance profiles and shouldn't be treated the same way, and long-horizon agent trajectories have often been running inside sandboxes for a long time—making full rollout restarts painfully expensive.

Our fault-tolerance design follows one clear thread (Figure 9): minimize state lost when a fault hits, minimize the cost of the recovery action itself, and never leave failover capacity sitting idle. Concretely, this comes down to four mechanisms:

Figure 9. Fault-tolerant architecture of Forge.

Async per-iteration snapshots (at most one iteration of rollback): At the end of every iteration, the Trainer asynchronously persists model and optimizer states to a snapshot. Disk writes run in parallel with weight sync and rollout, staying completely off the critical path—capping lost training progress at a single iteration even on a trainer crash or full node failure. Once persistence completes, the host-memory copy of those states can be freed immediately; we dynamically mount that reclaimed host DRAM into rollout as an L3 KV cache pool, squeezing full utility out of host memory across role transitions.

HBM-resident weights (~7-second in-place rollout recovery): When an inference instance crashes, checkpoints on disk hold stale weights from an earlier step, and waiting around for the next weight sync would waste those accelerators for the rest of the iteration. Instead, after every weight sync, each inference engine hands physical HBM handles for its live weights to a lightweight local holder daemon. Because the holder keeps only references without copying data, the current step's weights stay intact in HBM even if the engine process dies. A restarted instance reclaims the handles from the holder and resumes serving in roughly 7 seconds (or pulls live shards from Checkpoint Service's memory plane when rebuilding on another node); end-to-end recovery, including crash detection, finishes in under a minute. Throughout failover, sandbox connections stay up and in-flight requests migrate seamlessly to healthy instances with their generated prefixes intact, so long-running trajectories are never dropped.

Tiered fault dispatch: When an interruption occurs, low-level telemetry from our internal hardware health monitor tells us whether we are dealing with a transient software crash or a machine-level hardware failure. Transient crashes (such as process exits) simply restart the affected Rollout or Trainer worker in place using the two fast-recovery paths above. Machine-level faults—such as uncorrectable ECC errors or NIC failures—isolate the bad host and dynamically swap in a healthy node from the standby pool so training continues without restarting the job.

Preemptible standby pool (zero idle capacity): The classic problem with dedicated hot spares is wasted compute while nothing is broken. In Forge, every standby node runs as a low-priority Rollout worker during normal operation while contributing its host DRAM and SSDs to the global storage pool. Standby nodes can be preempted at any moment either by high-priority cluster workloads (such as urgent training jobs) or to replace a failed node in any RL run. When preempted, the yielding RL job immediately reroutes in-flight requests to healthy instances and preserves completed trajectories; when replacing a faulty host, the standby node exits its low-priority role, pulls the latest weights and training states from Checkpoint Service, and joins the target job in seconds—keeping cluster utilization maxed out without sacrificing online resilience.

AFlow

In Forge V1.0, we isolated agent logic cleanly within the codebase and supported a handful of harnesses. As we onboarded more harnesses, iterated faster, and added support for richer data schemas and experimental workflows, that nominally separate layer began coupling back into Forge internals. By the time we started M4—where we needed to train black-box and white-box harnesses like Claude Code, Codex, OpenCode, and MiniMax Code simultaneously across cross-application desktop tasks, 3D modeling, cybersecurity ranges, and more—we extracted agent execution and environment management out of Forge entirely into an independent framework: AFlow.

Inference Gateway Integration

AFlow talks to Forge across a thin Inference Gateway compatible with standard OpenAI and Anthropic APIs. External harnesses require zero code changes: point the model URL at the gateway and start training, running the exact same task definition across training and evaluation. Once a black-box harness is running, it often fires off auxiliary calls—such as context compaction or sidecar summarization—alongside main dialogue turns. As requests pass through, the gateway injects sampling budgets and trajectory IDs while automatically separating policy-trainable turns from sidecar inference calls, ensuring trained behavior matches real-world deployment.

Three-Tier Architecture

To let dozens of domain tracks iterate independently without stepping on each other, AFlow is organized into three layers from top to bottom. At the top, the Task Representation layer specifies how a task runs purely as declarative configuration—covering queries, harness recipes, sandbox images, grading logic, and budgets—with native support for Harbor, Uni-Agent, and AFlow schemas so existing benchmarks plug in with virtually zero migration work. In the middle, the Abstraction layer splits execution into Agent and Service primitives: Agents wrap black-box harnesses or white-box policies, while Services expose CPU/Accelerator container sandboxes, virtual desktops, databases, and graders behind pluggable interfaces mounted on demand. At the bottom, the Runtime layer schedules and isolates massive numbers of stateful sessions across the cluster, including multi-worker shared sandbox topologies such as dual-agent collaboration or red-vs.-blue security environments. Throughout M4 development, AFlow routinely ran 40+ harness-by-task combinations and millions of sandboxes in daily production.

RL and MOPD

M4's post-training follows a two-stage Domain-Expert RL + Multi-Teacher On-Policy Distillation (MOPD) pipeline. Starting from a shared SFT checkpoint, individual tracks train domain specialists in parallel (combining domain RL with RFT or SFT in select verticals) before consolidating them into a single unified model via MOPD. While the 28 experts reported in the technical report represent the final shipping set, many more specialists were trained, iterated on, swapped out, and merged along the way. Beyond preventing tasks with very different sequence lengths, sandboxes, and reward scales from interfering with one another, the deeper value of splitting before merging is decoupling iteration cadences across domains to enable continuous multi-stage scaling: whenever a track produces a stronger specialist, it can drop right in to replace its predecessor; newly validated verticals can join the next consolidation wave without restarting from scratch; and each consolidated model becomes a stronger starting point for the next round of specialist training.

Expert RL

Single-domain Expert RL continues to build on our battle-tested in-house CISPO algorithm, optimizing the objective:JCISPO(θ)=Ex,  {yi}i=1G∼πroll[1∑i=1G∣yi∣∑i=1G∑t=1∣yi∣sg⁡ ⁣[min⁡(ri,t(θ), c)]Ai,tlog⁡πθ(yi,t∣x,yi,<t)]\mathcal{J}_{\mathrm{CISPO}}(\theta) = \mathbb{E}_{x,\;\{y_i\}_{i=1}^{G}\sim\pi_{\mathrm{roll}}}\left[\frac{1}{\sum_{i=1}^{G}|y_i|}\sum_{i=1}^{G}\sum_{t=1}^{|y_i|}\operatorname{sg}\!\left[\min\big(r_{i,t}(\theta),\,c\big)\right] A_{i,t}\log\pi_\theta(y_{i,t}\mid x,y_{i,<t})\right]JCISPO(θ)=Ex,{yi}i=1G∼πroll∑i=1G∣yi∣1i=1∑Gt=1∑∣yi∣sg[min(ri,t(θ),c)]Ai,tlogπθ(yi,t∣x,yi,<t)

where r_{i,t}(θ)=π_θ/π_{roll} denotes the importance sampling ratio. By normalizing over total tokens across the group and applying a stop-gradient (sg[·]) to the one-sided clipped importance weight—using it strictly to rescale the policy gradient—CISPO remains rock-solid at M4 scale under our Semi-Async training loop.

For multi-tier Reasoning Effort control, we found that penalizing thinking length alone invites reward hacking: the model simply chops single-turn thinking short and compensates by firing more tool-call turns, leaving trajectories fragmented. To close that loophole, we apply a joint penalty on thinking length and interaction turns relative to a low within-group quantile baseline, capping the maximum penalty below the positive–negative reward gap so sample rankings never flip. With this joint penalty, individual turns stay self-contained, total turn counts drop sharply, and pass rates on DeepSWE v1.1 improve across every effort tier using roughly 80% of the original output tokens.

MOPD Consolidation

MOPD consolidation reuses the exact same CISPO objective. The student rolls out trajectories on-policy in the environment while the corresponding frozen domain expert runs a single batched prefill pass to score log-probabilities on the student's sampled tokens—simply replacing A_{i,t} with the clipped expert–student log-probability gap:Ai,t(d)=clip⁡ ⁣(log⁡πEd(yi,t∣x,yi,<t)−log⁡πroll(yi,t∣x,yi,<t),  −cA−, cA+)A_{i,t}^{(d)} = \operatorname{clip}\!\Big(\log\pi_{E_d}(y_{i,t}\mid x,y_{i,<t}) - \log\pi_{\mathrm{roll}}(y_{i,t}\mid x,y_{i,<t}),\;-c_A^-,\,c_A^+\Big)Ai,t(d)=clip(logπEd(yi,t∣x,yi,<t)−logπroll(yi,t∣x,yi,<t),−cA−,cA+)

At 3T scale, computing and transmitting full-vocabulary logits is expensive—and unnecessary. With large batch sizes, a numerically stable rollout–training stack, and a strong base model, token-level supervision on sampled tokens alone reliably trains the student to specialist parity, while additional OPD techniques such as top-k logit matching or advantage normalization showed limited gains in our ablation studies. Moreover, because MOPD requires no task-level reward verification during rollout, every error-free trajectory goes directly into training—turning more than 97% of generated tokens into effective gradient updates.

To merge long-context specialists operating at 192K or even 512K tokens, we use Staged Horizon Expansion. Running full-length MOPD from step zero allows small early action differences to compound across turns, pushing the latter half of a trajectory outside the state distribution familiar to the expert (Context Drift); systematic bias in those drifted tails then contaminates the clean learning signal from earlier turns. Because OPD provides dense per-token supervision over the underlying high-dimensional conditional distribution, the student does not need full-length trajectories from the outset to absorb specialist capabilities. In practice, we begin training on short prefixes such as 32K—where the vast majority of experts, including several long-horizon ones, already converge—and then expand to 64K or 128K only where necessary to learn late-stage verification and wrap-up behaviors, while avoiding severe stalls in rollout tails. Across DeepSWE v1.1, ProgramBench, and AutomationBench, the prefix stage closes more than 80% of the gap to the expert using only 10%–15% of the accelerator-hours required for full-length training, and expanding the horizon matches or slightly exceeds the expert ceiling with less than 40% of the compute—far ahead of full-length training from scratch, which still trails after consuming more than 2.5× the compute, conservatively estimated.

FP4 Recipe

M4 introduces quantization-aware training (QAT) beginning at the 1M-context mid-training stage, keeping SFT and RL aligned with production serving precision throughout: block-scaled FP4 for routed MoE experts and MSA2 indexer Q/K, FP8 for attention projections, shared experts, and the MSA2 main branch, and dequantized BF16 GEMMs in the backward pass to preserve gradient fidelity. When we first switched RL to FP4, early-stage score improvements were noticeably sluggish. Layer-by-layer inspection revealed the cause: at small RL learning rates, single-step updates to FP32 master weights are smaller than half an NVFP4 quantization bin, so cold-starting from pre-quantized weights meant that the 4-bit codewords across all 384 routed experts barely changed when synchronized to rollout. Depending on the empirical gains for each track, we enable two fixes: initializing directly from high-precision SFT master weights to preserve sub-grid headroom, and enabling Stochastic Rounding during FP4 weight synchronization so that sub-grid updates propagate to rollout without bias in expectation.

For optimization, we pair Muon for 2D trunk weight matrices with AdamW for Embeddings, Norms, and the LM Head, introducing two targeted stability fixes. First, in on-policy policy gradients, only the single sampled token at each position receives direct supervision, while the remaining ~200,000 unsampled vocabulary rows carry tiny softmax residuals; retaining a tiny pre-training/SFT ε, such as 10^{-15}, normalizes those minute residuals by their own norms into full-sized steps, gradually causing vocabulary and Norm drift as well as repetition loops. Raising AdamW's ε into the range between background residual noise and the true gradient signal—for example, 1× 10^{-7}—allows the denominator to filter out residual noise cleanly and eliminates degradation. Second, because Muon fixes the norm of its orthogonalized update at every step, its default momentum β = 0.95 carries too much inertia under shifting Semi-Async MOPD distributions and amplifies subtle systematic bias—and once OPD overshoots into a degraded rollout regime, there is no offline restorative gradient to pull it back. Lowering momentum to β = 0.80, where Muon's built-in Nesterov lookahead already assigns 74% of variance energy to the current step's gradient, eliminates early overshoot and narrows the steady-state expert–student logprob gap from -0.060 to -0.048.

Source

MiniMax Blog