S*: Test Time Scaling for Code Generation

Dacheng Li, Shiyi Cao, Chengkun Cao, Xiuyu Li, Shangyin Tan, Kurt Keutzer, Jiarong Xing, Joseph E. Gonzalez, Ion Stoica · DOI

Abstract

S is a novel hybrid test-time scaling framework specifically optimized for code generation. By integrating parallel sampling with sequential iterative debugging and an adaptive input synthesis selection mechanism, S enables smaller language models to significantly outperform larger counterparts and allows non-reasoning models to surpass state-of-the-art reasoning models like OpenAI’s o1-preview.

Introduction

Test-time scaling—allocating more computational resources during inference—has demonstrated remarkable success in mathematical reasoning, most notably with models like OpenAI’s o1. However, its application to code generation remains relatively unexplored. Unlike mathematics, where verification often relies on static matching, code requires functional verification through execution. S* addresses this by leveraging the unique advantage of code: the availability of an interpreter for feedback. It bridges the gap between simple parallel sampling (Best-of-N) and isolated self-debugging by providing a unified framework for generating and selecting high-quality solutions.

Methodology: The S* Framework

S* introduces a two-stage process designed to maximize the utility of test-time compute.

The S* framework: Stage 1 (Generation) uses iterative debugging, and Stage 2 (Selection) uses adaptive input synthesis.

Stage 1: Generation via Iterative Debugging

The framework begins by generating $N$ code samples in parallel. These samples then undergo a sequential debugging phase where each is executed against public test cases. If a sample fails, the resulting error message and output are provided as feedback to the model for refinement. Empirical results suggest that two rounds of debugging provide the optimal balance between performance and compute.

Stage 2: Selection via Adaptive Input Synthesis

Selecting the best candidate from a pool of improved samples is a critical challenge. S* employs "adaptive input synthesis" to move beyond simple LLM-as-a-judge heuristics. The system clusters samples by behavior and prompts an LLM to generate specific test inputs that can distinguish between pairwise clusters. By executing the code on these custom inputs, the selection process is grounded in actual functional behavior rather than abstract prediction.

Experimental Setup

The effectiveness of S* was evaluated across 12 different Large Language Models (LLMs), ranging from 0.5B to 32B parameters, including instruction-tuned and reasoning-specialized models. Benchmarking was conducted using:

  • LiveCodeBench (v2 and v4): A holistic benchmark featuring real-world competitive programming problems to ensure minimal data contamination.
  • CodeContests: A dataset of complex competitive programming tasks.

Results and Discussion

S* consistently improved performance across all tested models, demonstrating that test-time scaling is a universal lever for code quality.

Performance of various models with S* scaling compared to baselines and OpenAI o1 models on LiveCodeBench.

Key Findings

  • Scaling Efficiency: S allows smaller models to "punch above their weight." For instance, Qwen2.5-Coder-7B with S outperformed its 32B baseline by over 10%.
  • Enhancing Reasoning Models: Even models with native Chain-of-Thought capabilities, such as DeepSeek-R1-Distill-Qwen-32B, saw significant gains (from 69.1% to 85.7% on LiveCodeBench) when provided with explicit execution feedback.
  • Surpassing State-of-the-Art: GPT-4o-mini with S* achieved a Pass@1 of 61.3%, exceeding the performance of OpenAI’s o1-preview (57.6%). The R1-Distill-Qwen-32B variant reached 85.7%, nearing the performance of o1-high.

Conclusion and Future Work

S* establishes a new frontier for test-time scaling in code generation. While highly effective for algorithmic problems, future work is needed to extend this framework to large-scale software engineering tasks involving complex multi-file dependencies (e.g., SWE-bench). Additionally, optimizing the cost and latency associated with iterative debugging and adaptive selection remains an important area for practical deployment.

Summary updated

BibTeX
@misc{li2025s,
  author = {Dacheng Li and Shiyi Cao and Chengkun Cao and Xiuyu Li and Shangyin Tan and Kurt Keutzer and Jiarong Xing and Joseph E. Gonzalez and Ion Stoica},
  title = {{S*: Test Time Scaling for Code Generation}},
  year = {2025},
  eprint = {2502.14382},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.14382},
}
Figure