Scaling LLM Inference with Optimized Sample Compute Allocation

Kexun Zhang, Shang Zhou, Danqing Wang, William Yang Wang, Lei LiarXiv 2024 · DOI

TL;DR

This paper introduces OSCA, a novel algorithm that optimizes how compute budget is allocated across different LLM inference configurations (like temperature or model choice) to maximize accuracy. OSCA significantly outperforms traditional methods, achieving better results with substantially less compute, especially for complex tasks like code generation and agentic workflows.

What Problem Does This Paper Address?

Large Language Models (LLMs) are powerful, but their inference can be computationally expensive. A key aspect of LLM inference is sampling, where multiple outputs are generated and evaluated to improve the chances of finding a correct or high-quality solution. However, not all problems or tasks benefit equally from the same sampling configuration (e.g., temperature, model). Traditional approaches either use a single "best" configuration (pure allocation) or distribute compute evenly (uniform allocation). This paper addresses the challenge that a fixed, single configuration might not be optimal for all problems within a given task or workflow, leading to wasted compute or suboptimal performance. The core problem is finding an optimal mix of different inference configurations to maximize accuracy for a given compute budget.

Methods

The authors propose OSCA (Optimizes Sample Compute Allocation), which frames the problem of finding the best allocation as a learning problem. Given a set of potential inference configurations, a training dataset of problems, and a compute budget, OSCA learns a distribution of compute to allocate to each configuration to maximize expected accuracy.

The core of OSCA involves:

  1. Estimating Pass Probability: For each configuration and training problem, they estimate the probability of a sample being correct. This is done by sampling a fixed number of times (using a smaller estimation budget, $C_0$) and calculating the success rate.
  2. Learning Allocation: They formulate an optimization problem to maximize the expected "pass@C" (probability of at least one correct sample within compute budget $C$) over the training data. This is solved using a hill-climbing algorithm on the allocation $\pi$, which represents the amount of compute assigned to each configuration. The algorithm iteratively explores neighboring allocations and moves to a better one until no improvement is found. The convexity of the objective function ensures that this approach can find optimal solutions.

Datasets

The paper evaluates OSCA on two benchmarks:

  • LiveCodeBench: This benchmark consists of LeetCode-style programming problems. The authors split their data into training (first 3/5 of problems) and evaluation (last 2/5) sets, with 305 training and 205 evaluation problems.
  • LiveBench: This benchmark covers a broader range of tasks including data analysis, language, reasoning, and coding. They used a 3:7 split for training and testing, resulting in 201 training and 471 testing problems.

Key Insights and Ideas

  • Mixed Allocation is Crucial: The most significant insight is that a single "optimal pure" configuration is often insufficient. Different problems within a task, or different tasks within a workflow, require different sampling strategies. OSCA's ability to mix configurations is key to its success.
  • Uniform Allocation is a Strong Baseline, but Not Optimal: Even a simple uniform distribution of compute across configurations can outperform the best single configuration. However, OSCA's learned, optimized mixed allocation consistently surpasses uniform allocation.
  • OSCA is Robust to Estimation Budget: The estimation budget ($C_0$) for learning the allocation can be significantly smaller than the actual inference budget ($C$) without severely impacting performance, making the learning process more efficient.
  • Domain-Specific Allocation: While OSCA shows generality, its learned allocations tend to be domain-specific, suggesting that optimal configurations can vary significantly across different problem types.

Key Results

  • Code Generation: On LiveCodeBench, OSCA achieved accuracy better than the best single configuration with 128x less compute.
  • Reasoning Tasks: For 4 reasoning tasks on LiveBench, OSCA achieved 25x less compute for comparable accuracy.
  • Agentic Workflows: On SWE-Bench, a complex agentic workflow for software engineering, OSCA improved accuracy by 3x less compute compared to the default configuration.
  • Efficiency Gains: Across various tasks, OSCA consistently demonstrated superior performance, often achieving higher accuracy with significantly fewer samples (compute budget). For example, on LiveCodeBench, OSCA achieved a pass@8 of 73.3%, surpassing the optimal pure allocation with 512 samples.

Limitations and Future Work

  • Limited Hyperparameters: The current OSCA focuses on four hyperparameters: model, temperature, response language, and prompt. The authors suggest exploring a wider range of hyperparameters (e.g., top-k, top-p, repetition penalty) to create more diverse configuration sets.
  • Compute Budget Limit: The experiments were limited to a maximum compute budget of 512 samples. Further investigation into how OSCA scales with even larger compute budgets is warranted.
  • Domain Specificity: While OSCA's learned allocations are effective, they show domain-specific tendencies. Future work could explore methods for more generalizable or instance-level allocation.
  • Scalability: The authors mention that future work could explore optimizing additional hyperparameters and testing the scalability of the method with larger compute budgets.

Summary updated

BibTeX
@misc{zhang2024scaling,
  author = {Kexun Zhang and Shang Zhou and Danqing Wang and William Yang Wang and Lei Li},
  title = {{Scaling LLM Inference with Optimized Sample Compute Allocation}},
  year = {2024},
  eprint = {2410.22480},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.22480},
}
Figure