Nesformer compiles an NES CPU into Qwen weights
2026-10-31 · GitHub
nesformer, open-sourced by Drew Breunig on GitHub, compiles the NES 6502 CPU (core of the 2A03), its 2 KB work RAM and a cartridge's program ROM into a standard Qwen3_5ForCausalLM checkpoint. The README stresses that nobody trained the weights: a compiler computed every one. When you play, the model predicts the CPU execution log one token at a time, while a small host program draws the picture, reads the controller and fires the vblank interrupt.
It builds on Divyansh Agrawal's Qwenputer, which earlier compiled a CHIP-8 and a RISC-V CPU into Qwen3.5-4B, reusing its compiler and key trick of using the model's Gated DeltaNet state as machine memory. The author says every CPU token in test runs came from the model and every frame of the bundled test games matches a conventional 6502 emulator exactly. Simon Willison covered it, noting the author said on Hacker News that he used Opus 5.5 prompts and a 15-year-old NES CPU conformance suite.
You need Python 3.11+, install numpy, scipy, numba and pillow, download the weights, and run python -m nesformer run pointing at a .nes file. NROM-board (iNES mapper 0) games such as Super Mario Bros. and Donkey Kong work; you supply the ROM, and the project ships only three freely redistributable test ROMs. The first run spends about 20 seconds compiling with numba, then each frame takes 1–6 seconds, so 10 seconds of gameplay takes about 25 minutes.
It has no practical use; it is a proof of concept that model weights can be a computer. Limits are obvious: very slow and only simple cartridge boards. Please confirm the legal source of any ROM before use.