MiniMax shows how it trained its M4 model inside real coding agents
In a Hugging Face post of 4 December, MiniMax describes Forge V2.0, the reinforcement learning system behind M4, built for RL at 3T parameters, a 1M context window and 10,000-accelerator cluster scale. It covers predictive rollout scheduling, a fast engine for slow trajectories, a checkpoint service that hot-switches 40+ expert models, bitwise alignment between training and rollout, and AFlow, which trains agent harnesses such as Claude Code and Codex with zero code changes.
RL rollout is a closed system, MiniMax argues: the lab sets total concurrency and knows which turn each session is on, which tool it is running and how much context it holds, so demand can be forecast instead of met after queues pile up. A predictor in AFlow estimates remaining tool time and output length every 5 seconds, and the RL Scheduler switches instances between prefill and decode roles in place, in 5 to 10 seconds, when a switch clears a net-benefit threshold. Against a fixed split and reactive switching, that raised completed trajectories per unit time by 51% and 13%. For the long tail of slow sessions, a small slice of compute runs Fast MegaEngine, persistent megakernels that exceed 835 tok/s for a single request and reach 4,550 tok/s at 32 concurrent requests; on production agent workloads that cut long-tail inference time by roughly 60% and sped up end-to-end rollout by 1.2× to 1.3×.
A single M4 distillation run may have 40+ domain experts scoring student trajectories at once. Instead of giving each its own mostly idle instance, Checkpoint Service pre-stages their weights in a distributed memory pool and swaps them over RDMA; because the experts are fine-tuned from the same base, only compressed deltas of 1% to 10% of a full checkpoint move, keeping 3T-model switches under 10 seconds. Faults are routine on a 10,000-accelerator cluster. The trainer snapshots asynchronously every iteration, so at most one iteration is lost, and a crashed inference engine reclaims weights still held in accelerator memory and resumes in roughly 7 seconds, with sandbox connections kept up so long trajectories are not dropped. Standby nodes run low-priority rollouts until a job needs them.
Forward passes in training and rollout now match bitwise in production, through batch-invariant kernels and identical quantizers module by module, at 95.64% of the unaligned setup's end-to-end efficiency. AFlow sits outside Forge behind an Inference Gateway compatible with the OpenAI and Anthropic APIs: an external harness points its model URL at the gateway, which separates policy-trainable turns from side calls such as context compaction. During M4's development it routinely ran 40+ harness-by-task combinations and millions of sandboxes a day, across desktop tasks, 3D modelling and cybersecurity ranges, with Claude Code, Codex, OpenCode and MiniMax Code among the harnesses.
Specialists trained with MiniMax's CISPO algorithm were consolidated by multi-teacher on-policy distillation, which turned over 97% of generated tokens into gradient updates. For long-context experts, training on 32K prefixes first closed over 80% of the gap to the expert with 10% to 15% of the full-length accelerator-hours. Penalising thinking length alone invited reward hacking, with the model cutting its thinking short and making more tool calls, so a joint penalty on thinking length and turns was used instead, improving DeepSWE v1.1 pass rates at every effort tier with roughly 80% of the original output tokens. A larger AdamW epsilon and Muon momentum lowered from 0.95 to 0.80 removed vocabulary drift and early overshoot. All figures are MiniMax's own.
