NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Neural Program Synthesis By Self-Learning

Yifan Xu, Lu Dai, Udaikaran Singh, Kening Zhang, Zhuowen TuarXiv 2019

Abstract

AutoAssemblet is a novel neural program synthesis framework designed to generate x86 assembly code through self-learning reinforcement learning. By integrating Monte Carlo Tree Search (MCTS) with a multi-entropy sampling technique, AutoAssemblet efficiently navigates vast code search spaces to satisfy input-output specifications. Experimental results demonstrate that AutoAssemblet significantly outperforms standard imitation learning and reinforcement learning baselines, particularly on complex tasks.

Introduction

Program synthesis—the automated generation of executable code from high-level specifications—remains a fundamental challenge in computer science. Inductive Program Synthesis (IPS) specifically aims to produce code that transforms given inputs into desired outputs. This task is complicated by the combinatorial explosion of the search space, sparse rewards where only perfectly correct programs are rewarded, and the scarcity of high-quality human-labeled training data.

AutoAssemblet addresses these challenges by focusing on low-level x86 assembly. This environment allows the synthesis agent to interact directly with CPU registers and RAM, providing a granular and deterministic world for learning.

Methodology

The AutoAssemblet framework employs three core components to master assembly code generation:

Self-Learning Reinforcement Learning

The system begins with imitation learning on "pilot programs"—valid but randomly generated code sequences. It then transitions to reinforcement learning (RL) to refine its capabilities. A key innovation is the Task Sampling strategy, which re-weights tasks based on the model's current failure rates. By prioritizing difficult tasks, the model avoids overfitting to simple problems and maintains a steady learning gradient.

The AutoAssemblet training pipeline, showing the transition from task sampling to self-learning via policy and value networks.

Multi-Entropy Policy Sampling

To stabilize online RL updates, which are often highly correlated, AutoAssemblet uses multiple "temperatures" ($\tau$) in the softmax function during action sampling. High temperatures encourage broad exploration, while low temperatures exploit known successful paths. This multi-entropy approach serves as a stabilizer, analogous to off-policy replay buffers in other RL contexts.

MCTS with Policy and Value Networks

AutoAssemblet integrates Monte Carlo Tree Search to guide the code generation process. A Policy Network ($\pi_\theta$) reduces the search breadth by suggesting promising instructions, while a Value Network ($V_\psi$) reduces search depth by estimating the likelihood of a partial program leading to a successful solution.

The four stages of the MCTS process: Selection, Expansion, Evaluation, and Backup.

Experimental Setup

The model was trained and evaluated using two primary data sources:

  1. Synthetic Task Pool: Millions of pilot programs generated via random initial policies on an x86 simulator.
  2. Human-Designed Benchmarks: A test set of 130 tasks of varying difficulty, ranging from basic arithmetic to complex logic such as sorting and filtering.

Results

AutoAssemblet demonstrated substantial improvements over baseline methods. It achieved an overall success rate of 62% on human-designed tasks, markedly higher than Imitation Learning (45%) and the REINFORCE algorithm (43%).

The performance gap was most evident in "Hard" tasks, where AutoAssemblet solved 23% of problems, more than doubling the 10% success rate of the MCTS (Prior) baseline. Furthermore, the model exhibited remarkable efficiency, solving problems with a hypothesis space exceeding $2^{23}$ possibilities within just 10 steps.

Discussion and Future Work

While AutoAssemblet represents a significant step forward, it currently has limitations. The model generates "straight-line" code and lacks support for control flow instructions like JMP, CMP, or loops. Additionally, managing memory safety and global long-term planning remains challenging. Future research will focus on incorporating advanced global planning mechanisms to enable the synthesis of programs with complex control flow.

Summary updated

BibTeX
@misc{xu2019neural,
  author = {Yifan Xu and Lu Dai and Udaikaran Singh and Kening Zhang and Zhuowen Tu},
  title = {{Neural Program Synthesis By Self-Learning}},
  year = {2019},
  eprint = {1910.05865},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.05865},
}
Figure