Code World Model

Meta FAIR releases CWM, a 32B open-weights coder trained to model code execution and to act inside containers. It mid-trains on Python interpreter traces and agentic Docker trajectories, then upgrades with multi-turn RL across SWE, coding, and math. CWM is both a strong coder and a testbed for world-model-style reasoning in software environments.
Ask this paper
Execution-aware training recipe: Pretrain 8T tokens, then mid-train 5T on Python execution traces and ForagerAgent trajectories collected in containerized repos, followed by SFT (100B) and joint multi-task RL with a GRPO-style algorithm and asynchronous rollouts. Results include 120M traced functions, ~70k repo-level traces, and 3M agentic trajectories.
Model + context scaling: Dense 32B decoder with alternating local/global sliding-window attention and 131k max context. Scaled RoPE, GQA, FP8 training, and long-context bucketization are used to keep throughput sane. Inference can fit on a single 80 GB H100 with quantization.
Agentic RL design for SWE: The agent works inside a repo sandbox with a minimal toolset (bash, edit, create, submit), runs tests, builds patches with git diff, and is rewarded by hidden tests plus patch-similarity shaping. Self-bootstrapped traces improve format adherence before RL.
Performance highlights: On SWE-bench Verified, 53.9% base pass@1 and 65.8% with test-time scaling (best@k); chart on page 3 shows CWM competitive with much larger or closed models. Also LCB-v5 68.6, Math-500 96.6, AIME-24 76.0, CruxEval-Output 94.3.
Why it matters for AI devs: CWM exposes trace-prediction tokens to simulate Python execution in prompts, enabling grounded reasoning, neural-debugger workflows, and trace-guided code synthesis. Ablations show execution traces boost CruxEval, and ForagerAgent boosts agentic NLLs and SWE pass@1.
Abstract
We release Code World Model (CWM), a 32-billion-parameter open-weights LLM, to advance research on code generation with world models. To improve code understanding beyond what can be learned from training on static code alone, we mid-train CWM on a large amount of observation-action trajectories from Python interpreter and agentic Docker environments, and perform extensive multi- task reasoning RL in verifiable coding, math, and multi-turn software engineering environments. With CWM, we provide a strong testbed for researchers to explore the opportunities world modeling affords for improving code generation with reasoning and planning in computational environments. We present first steps of how world models can benefit agentic coding, enable step-by-step simulation of Python code execution, and show early results of how reasoning can benefit from the latter. CWM is a dense, decoder-only LLM trained with a context size of up to 131 k tokens. Independent of its world modeling capabilities, CWM offers strong performance on general coding and math tasks: it reaches pass@1 scores of 65.8 % on SWE-bench Verified (with test-time scaling), 68.6 % on LiveCodeBench, 96.6 % on Math-500, and 76.0 % on AIME 2024. To support further research on code world modeling, we release model checkpoints after mid-training, SFT, and RL. Download the Paper AUTHORS Written by Jade Copet Quentin Carbonneaux Gal Cohen Jonas Gehring Jacob Kahn Jannik Kossen Felix Kreuk Emily McMilin Michel Meyer Yuxiang Wei David Zhang Kunhao Zheng Jordi Armengol-Estape Pedram Bashiri Maximilian Beck Pierre Chambon Abhishek Charnalia Chris Cummins Juliette Decugis Zacharias Fisches François Fleuret Fabian Gloeckle Alex Gu Michael Hassid Daniel Haziza Badr Youbi Idrissi Christian Keller Rahul Kindi Hugh Leather Gallil Maimon Aram Markosyan Francisco Massa Pierre-Emmanuel Mazaré Vegard Mella Naila Murray Keyur Muzumdar Peter O'Hearn Matteo Pagliardini Dmitrii Pedchenko Tal Remez Volker Seeker Marco Selvi Oren Sultan Sida Wang Luca Wehrstedt Ori Yoran Lingming Zhang Taco Cohen Yossi Adi Gabriel Synnaeve Publisher arXiv Research Topics Natural Language Processing (NLP) Core Machine Learning Related Publications July 17, 2026 CONVERSATIONAL AI REINFORCEMENT LEARNING Learning to Reason by Analogy via Retrieval-Augmented Reinforcement Fine-Tuning Zilin Xiao , Qi Ma , Jason Chen , Xintao Chen , Avinash Atreya , Hanjie Chen , Vicente Ordonez July 17, 2026 Read the Paper July 13, 2026 AR/VR RESEARCH S-EMBER: A Large-Scale Benchmark for Streaming Egocentric Memory Retrieval Xiaodong Wang , Xuanyi Zhao , Pedro Rodriguez , Devendra Singh Sachan , Barlas Oguz , Seungwhan Moon , Shang-Wen Li , Gargi Ghosh , Xin Dong , Wen-Tau Yih July 13, 2026 Read the Paper July 03, 2026 HUMAN & MACHINE INTELLIGENCE ROBOTICS Interpreting Physics in Video World Models Sonia Joseph , Quentin Garrido , Randall Balestriero , Matthew Kowal , Thomas Fel , Shahab Bakhtiari , Blake Richards , Mike Rabbat July 03, 2026 Read the Paper June 05, 2026 CONVERSATIONAL AI RANKING AND RECOMMENDATIONS Superintelligent Retrieval Agent: The Next Frontier of Agentic Retrieval Zeyu Yang , Qi Ma , Jason Chen , Anshumali Shrivastava June 05, 2026 Read the Paper See All Papers Help Us Pioneer The Future of AI We share our open source frameworks, tools, libraries, and models for everything from research exploration to large-scale production deployment. Join our Team Our approach About AI at Meta People Careers Research Infrastructure Resources Demos Meta AI Assistant Media Generation Vibes AI Studio Latest news Blog Newsletter Foundational models Llama Our approach Our approach About AI at Meta People Careers Research Research Infrastructure Resources Demos Meta AI Meta AI Assistant Media Generation Vibes AI Studio Latest news Latest news Blog Newsletter Foundational models Llama Privacy Policy Terms Cookies Meta © 2026