# Learning to Compile Programs to Neural Networks

arXiv: https://arxiv.org/abs/2407.15078 · HTML: https://mlsanity.com/paper/2407.15078/

## Key facts

- Cited by 2 papers in the map (data through 14 Oct 2026).
- First posted on arXiv 21 Jul 2024.

## Built on by (most cited first, 2 of 2)

- [SURGE: On the Potential of Large Language Models as General-Purpose Surrogate Code Executors](https://mlsanity.com/paper/2502.11167/) (2025)
- [Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spaces](https://mlsanity.com/paper/2505.17703/) (2025)

## Abstract (arXiv)

A textitneural surrogate of a program is a neural network that mimics the behavior of a program. Researchers have used these neural surrogates to automatically tune program inputs, adapt programs to new settings, and accelerate computations. Researchers traditionally develop neural surrogates by training on input-output examples from a single program. Alternatively, language models trained on a large dataset including many programs can consume program text, to act as a neural surrogate. Using a language model to both generate a surrogate and act as a surrogate, however, leading to a trade-off between resource consumption and accuracy. We present textitneural surrogate compilation, a technique for producing neural surrogates directly from program text without coupling neural surrogate generation and execution. We implement neural surrogate compilers using hypernetworks trained on a dataset of C programs and find that they produce neural surrogates that are 1.9-9.5× as data-efficient, produce visual results that are 1.0-1.3× more similar to ground truth, and train in 4.3-7.3× fewer epochs than neural surrogates trained from scratch.
