Predicting the execution performance of code—such as memory consumption or GPU latency—is a long-standing challenge in systems engineering and compiler research. Traditionally, this required complex static analysis or heavy, domain-specific feature engineering. A new paper, "Regression Language Models for Code," proposes a simpler, unified approach: treating performance prediction as a translation task where the "language" is source code and the "target" is a sequence of digits representing performance metrics.
The Challenge of Static Performance Prediction
Static performance prediction involves estimating metrics without actually executing the code. This is notoriously difficult due to the open-ended nature of programming languages and the complexity of modern hardware.
Historically, researchers have relied on two primary methods:
- Manual Feature Engineering: Counting specific commands, loops, or memory accesses to build tabular models.
- Specialized Graph Neural Networks (GNNs): Representing code or neural architectures as computation graphs.
Both methods are inherently brittle. Introducing a new programming language or a novel hardware accelerator often necessitates redesigning features or model architectures from scratch. The authors sought to answer a fundamental question: Can a general-purpose Large Language Model (LLM) "read" code and accurately predict its performance metrics across diverse domains?
Methodology: Regression as Text Generation
To address this, the researchers introduce Regression Language Models (RLMs), utilizing an encoder-decoder architecture based on T5Gemma.
The core innovation lies in how the model handles continuous numerical values. Instead of appending a standard regression head that outputs a single floating-point number, the authors frame regression as text generation. A target metric (e.g., 72.5 ms) is represented as a sequence of tokens comprising a sign, an exponent, and a mantissa (e.g., <+><-><1><7><2><5>).
Key technical choices include:
- Frozen Encoders: The encoder weights, pretrained on massive code datasets, are kept frozen while only the decoder is trained. This drastically reduces training costs and leverages the model's pre-existing understanding of code syntax and semantics.
- Digit-by-Digit Tokenization: This normalization-free approach prevents the numerical instabilities common in standard regression tasks. It allows the model to seamlessly predict values across wildly different scales, from $10^{-2}$ to $10^6$.
- Multi-Objective Autoregression: Because the model generates tokens sequentially, it can predict multiple metrics in a single pass. For example, it can predict a neural network's accuracy and subsequently predict its latency conditioned on that accuracy, naturally capturing the trade-offs between speed and precision.
Datasets and Evaluation
The study evaluated RLMs across a diverse suite of benchmarks:
- APPS & CodeNet: High-level programming datasets (Python, C++, Java, etc.) used to predict peak memory usage.
- KernelBook: A dataset of Triton GPU kernels used to predict execution latency on NVIDIA A6000 GPUs.
- NAS Benchmarks: Standard Neural Architecture Search spaces (like NASBench-101/201) represented as text-based ONNX graphs.
- SNAS: A novel synthetic dataset of 85.5K CNN architectures created by the authors for pretraining.
Key Insights and Results
The RLM approach yielded several surprising insights and state-of-the-art results:
- Code is Just Text (Even Graphs): RLMs can process dense, serialized ONNX graphs and outperform state-of-the-art GNNs. This suggests that the sequential processing of LLMs is sufficient to capture complex graph topologies, provided the serialization is consistent.
- Autoregression Captures Correlation: By predicting metrics sequentially, the decoder learns inherent computational constraints—for instance, recognizing that a model with higher Floating Point Operations (FLOPs) will likely exhibit higher latency.
- In-Context Learning is Insufficient: The authors compared their trained RLMs against massive general-purpose models using few-shot prompting. The relatively small 300M-parameter RLM significantly outperformed the larger models, demonstrating that task-specific "in-weight" training remains essential for high-precision numeric regression.
- State-of-the-Art Performance:
- On the APPS dataset, the RLM achieved a >0.9 Spearman-rank correlation for memory prediction, indicating exceptional capability in ranking solution efficiency.
- A single unified model achieved a >0.5 average Spearman-rank across 24 different programming languages in CodeNet, including niche languages like Lua and Haskell.
- On five classic NAS benchmarks, the RLM achieved the highest average Kendall-Tau (0.46), surpassing specialized graph-based methods.
- The model successfully predicted latencies for the same neural network across four different hardware devices simultaneously.
Limitations and Future Directions
While highly effective, the RLM approach faces certain limitations:
- Context Window Constraints: Very large programs or complex neural network graphs can exceed standard token limits (e.g., 2048 tokens), leading to truncation. While this did not severely impact current benchmarks, it poses a bottleneck for analyzing massive software systems.
- Zero-Shot Generalization: The model handles many languages well, but its performance on "purely zero-shot" languages—those entirely unseen during regression training—is significantly lower.
- Scaling Challenges: The authors noted that scaling the model to 600M+ parameters required highly sensitive hyperparameter tuning, indicating that simply increasing model size does not trivially solve regression challenges.
Ultimately, this work paves the way for massively simplifying computational graph analysis, demonstrating that complex systems performance prediction can be effectively reframed as a generic next-token prediction task.
Summary updated