Prefill-Guided Trace Allocation for Sample-Efficient Test-Time Scaling

Zhi Yao, Zhiqing Tang, Hanshuai Cui, Qianli Ma, Fanshuai Meng, Weijia JiaNeurIPS 2026

TL;DR

When Large Language Models (LLMs) tackle math problems, generating multiple solutions and taking a majority vote—a technique called self-consistency—dramatically boosts accuracy, but wastes massive compute on easy questions the model got right on the first try. Existing shortcuts wait until answers are already generated to stop sampling, discovering too late that the extra work wasn't needed. This paper introduces HATS, a lightweight scheduler that reads the model's "initial impression" of a prompt before generating a single word, letting it skip extra work on easy problems and cut token costs by 40–52% while keeping accuracy intact.

What Problem Does This Paper Address?

Test-time scaling improves LLM reasoning by spending extra compute at inference time rather than retraining the model. The workhorse here is self-consistency (SC): instead of trusting one answer, you sample multiple reasoning paths ("traces")—say, four or eight—and take a majority vote.

The catch? Fixed-budget SC treats "What is 2+2?" the exact same way it treats an Olympiad math problem. Compact reasoning models already solve over 70% of standard math benchmarks on their very first deterministic ("greedy") attempt, meaning all those extra voting traces are pure computational overkill.

Existing adaptive methods try to stop early by checking if generated answers agree with each other. However, this creates a timing gap: agreement signals only become reliable after you've already paid the heavy GPU cost of decoding multiple long reasoning chains. Running a separate "verifier" model alongside the reasoner isn't an option either when you're squeezed onto a single 24GB GPU. The authors ask: can we predict whether extra traces are worth buying before we start decoding?

Methods

Enter HATS (Hidden-State Adaptive Trace Scheduler), which operates on a simple philosophy: don't try to predict the final answer—just predict whether the first greedy attempt is trustworthy.

Figure 1: Overview of HATS allocation around a four-sample SC target. Prefill routing sends easy, borderline, and hard problems to one checked trace, a small vote, and the full budget, respectively.

HATS splits the process into two novel components layered over standard LLM serving (vLLM):

  1. Prefill Difficulty Estimator (PDE+): When an LLM reads a prompt (the "prefill" stage), its internal layers build a rich representation of the problem before generating any output tokens. PDE+ takes the final-layer hidden states averaged over the last five prompt tokens and feeds them into a tiny two-layer neural network (MLP). Trained on just ~500 examples of whether the model's greedy answer was right or wrong, PDE+ outputs a difficulty risk score $d \in [0, 1]$.
  2. Multi-Stage Adaptive Probe (MSAP): Routing errors are asymmetric—stopping too early ruins accuracy, while sampling too much just costs tokens. So HATS doesn't blindly trust PDE+. Instead, it always decodes one greedy trace first and runs two sanity guards: Did the parser extract a valid, un-truncated math answer? and Was the model's token log-probability confident?
  3. Easy problems (low risk score + valid parse) commit immediately after 1 trace.
  4. Borderline problems commit if confidence is high; otherwise, they enter a "small vote," sampling until just 2 traces agree.
  5. Hard problems get the full budget, sampling until 3 traces agree or hitting the cap.

Datasets

No new benchmarks are introduced. The authors train PDE+ and run primary evaluations on MATH-500 (500 competition math problems). To test zero-shot transfer—applying the MATH-trained estimator directly to new domains without any new labels or tuning—they evaluate across seven additional math benchmarks: GSM8K (500-problem subset), AIME 2022–2024 (90 problems), SVAMP, GSM-Hard, MinervaMath, AMC23, and AIME 2025.

Key Insights and Ideas

  • Water-filling for LLM compute: Using a theoretical allocation analysis, the authors show that uniform sampling is mathematically suboptimal under diminishing returns. Compute should work like water filling uneven terrain—flowing only to problems with the highest marginal accuracy gain. Consequently, PDE+ doesn't need to output calibrated probabilities; it just needs to rank hard problems above easy ones.
  • Policy beats raw scorer quality: When the authors swapped competing activation-routing scorers into HATS, they found that binary gates (which force an all-or-nothing choice between 1 trace and full SC) have to send ~80% of problems to the full budget just to protect accuracy. HATS's graded escalation (1 trace $\rightarrow$ small vote $\rightarrow$ full vote) plus post-decode guards is what actually unlocks big token savings.
  • Single-stream vs. real-world serving: In a naive single-question-at-a-time setup, HATS is actually slower in wall-clock time than fixed SC because the GPU briefly idles between checking the greedy probe and launching extra votes. Under continuous batching (how production servers actually run), other users' requests fill those idle bubbles, turning token savings directly into higher throughput and freed KV-cache memory.

Key Results

Evaluated primarily on DeepSeek-R1-Distill-Qwen-7B on MATH-500 (and extended across 8 models from 7B to 32B):

Table 2: MATH-500 accuracy–compute results. Token saving is relative to the fixed-budget reference within each block. Replay and oracle rows are diagnostic references rather than online baselines.
  • Substantial Token Savings: Under a 4-sample cap (SC-4), HATS stays within 2.6 percentage points of fixed SC-4 accuracy (80.60% vs. 83.20%; narrowing to a 1.6-point gap under strict out-of-fold validation) while cutting samples by 48.0% and decoded tokens by 40.2%. Every online post-decode baseline either missed the accuracy target or blew past the token budget.
  • Scaling Up: With an 8-sample cap (HATS-K8), it slightly beats SC-8 accuracy (83.60% vs. 83.40%) while saving 51.7% of tokens.
  • Zero-Shot Generalization: Across 8 models and 8 benchmarks without target labels, HATS automatically scales effort to match dataset difficulty—spending ~1.8 samples on grade-school math (GSM8K, saving 53–73% tokens) and ~3.0 samples on brutal Olympiad problems (AIME, saving 15–18% tokens).
  • Real Serving Speedups: On a single RTX 3090 with continuous batching, HATS answers 19.4% more problems per hour at matched concurrency—and up to 65.7% more because its smaller memory footprint lets the GPU double its concurrency from 32 to 64 without bogging down.

Limitations and Future Work

  • Math-specific guards: The safety guards rely on extracting clean final answers and checking symbolic equivalence (via SymPy), restricting the current setup to mathematical reasoning rather than open-ended generation.
  • Calibration overhead & transfer gaps: Every new base model requires ~500 greedy-labeled examples to train its own PDE+ MLP. Furthermore, zero-shot transfer isn't magical: on GSM8K, the MATH-trained probe ranked errors near random chance (0.54 AUC), forcing the post-decode guards to do the heavy lifting and leaving a 2.8-point accuracy dip.
  • Tail latency: While median latency drops dramatically (58% of problems finish in one shot), the hardest P95/P99 problems take longer than fixed SC because they pay for two sequential rounds of generation instead of one parallel batch.

Future directions include expanding to larger SC budgets, designing guards for non-mathematical tasks, and building latency-aware schedulers to tame that two-round tail latency.

Summary updated

Abstract

Self-consistency is a widely adopted test-time scaling method that improves LLM reasoning by majority-voting over sampled traces. However, fixed-budget self-consistency applies the same trace count to every problem, even when the first greedy attempt already produces the correct answer, wasting substantial compute on resource-constrained hardware. Existing adaptive methods rely on post-decode agreement signals that become reliable only after complete traces have been generated, yet a prefill-stage oracle reveals that a large fraction of this cost can be eliminated before spending the full budget. We introduce the Hidden-State Adaptive Trace Scheduler (HATS), which predicts greedy-trace reliability from prefill hidden states before allocating additional sampled traces. HATS validates one greedy probe before routing easy problems to a single trace, borderline problems to a small vote, and hard problems to the full budget. A compute-optimal allocation analysis shows that extra samples should go where marginal accuracy gain is highest, explaining why non-uniform spending outperforms fixed budgets. On MATH-500 with DeepSeek-R1-Distill-Qwen-7B, HATS comes within 2.6 points of four-sample self-consistency accuracy while reducing samples by 48% and decode tokens by 40%, and with an eight-sample cap it matches eight-sample self-consistency accuracy with 52% fewer tokens. Without target labels, the same estimator keeps accuracy close to the four-sample target across eight models and eight mathematical benchmarks, and under continuous batching it answers 19% more problems per hour at matched concurrency. These results support prefill-guided scheduling as a practical compute-saving mechanism for test-time scaling.
BibTeX
@inproceedings{yao2026prefill,
  author = {Zhi Yao and Zhiqing Tang and Hanshuai Cui and Qianli Ma and Fanshuai Meng and Weijia Jia},
  title = {{Prefill-Guided Trace Allocation for Sample-Efficient Test-Time Scaling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=BhyoBRJYPG},
}
Figure