Predicting how many tokens a Large Language Model (LLM) will generate is a "holy grail" for infrastructure engineers. If you know a response will be 500 tokens versus 5, you can make much smarter decisions about batch scheduling, memory allocation, and request routing.
However, current research in this area is a bit of a mess. One paper might report a Mean Absolute Error (MAE) of 80, while another reports 260 for the same architecture. In "On the Fundamental Limits of Prefill-Based Decoding Length Prediction," Haowen Shi and colleagues from Xi’an Jiaotong and Shandong Universities argue that we’ve been blaming the wrong thing. The problem isn't necessarily the predictor—it's the inherent randomness of the LLM itself.
TL;DR
This paper proves that LLM decoding length is fundamentally stochastic and follows a predictable "normal law," establishing a theoretical performance floor that no predictor can beat. The authors show that current state-of-the-art predictors are already hitting this limit, meaning future progress requires changing the generation process itself rather than building more complex length-prediction models.
What Problem Does This Paper Address?
LLM inference happens in two stages: prefill (processing the prompt) and decode (generating tokens one by one). Because decoding is sequential and slow, predicting the output length during the prefill phase is vital for efficiency.
The authors identify a "fairness problem" in how these predictors are evaluated. Current benchmarks conflate predictor quality (how good the model is) with task hardness (how random the output is). If a prompt is open-ended (e.g., "Tell me a story"), the output length has high variance. No matter how smart your predictor is, it can't perfectly guess a single number for a random variable.
Methods
The researchers move away from just building better models and instead build a theory of error.
- Decoding as a Stopped Stochastic Process: They model decoding not as a simple sequence, but as a process that "decides" to stop based on a ramping probability.
- The Renewal Model: They assume a long response is a concatenation of "segments" (sentences or reasoning steps). By applying the Central Limit Theorem (CLT) to these segments, they prove that decode length is asymptotically normal.
- The Affine Variance Law: They derive a linear relationship between the expected length ($\mu$) and the standard deviation ($\sigma$): $\sigma = \alpha\mu + b$.
- Lower Bounds: Using the normal distribution, they derive the "Irreducible MAE"—the absolute minimum error any prefill-side predictor must have.
- Architecture-Agnostic Benchmarking: They tested a wide variety of architectures—from simple MLPs to complex Mixture-of-Experts (MoE) and Entropy-Guided Token Pooling (EGTP)—under strictly controlled conditions to see if any could break the theoretical floor.
Datasets
- ShareGPT: The primary dataset used for empirical validation (300 prompts, each decoded 200 times to capture the variance).
- ForeLen: A recent benchmark the authors critique for conflating task difficulty with model performance.
- Cross-Dataset Tests: They used LMSYS-200K, LeetCode, HumanEval, and GSM8K to test how well predictors generalize across different domains.
Key Insights and Ideas
- The "System Error" Ceiling: The total prediction error is the sum of "system error" (the LLM's inherent randomness) and "model error" (the predictor's inaccuracy). The authors find that system error is the dominant factor.
- Normality is Real: By decoding the same prompt 200 times, they found the resulting lengths follow a Gaussian distribution almost perfectly (within 1.9% of the theoretical value).
- Simple is Competitive: Surprisingly, a basic 3-layer MLP that simply concatenates hidden states from all layers performed as well as, or better than, complex state-of-the-art methods like EGTP.
- Relative Metrics Matter: Because absolute error grows with sequence length, the authors argue we should report relative-error metrics (like MAE/$\mu$) to get a fair view of predictor quality across different tasks.
Key Results
The authors established the $\alpha$ and $b$ constants for several popular models, showing how "stable" different models are in their generation.
As seen in Figure 1, Qwen3-4B-Instruct is significantly more stable ($\alpha = 0.1068$) than its "no-thinking" counterpart ($\alpha = 0.2029$).
Quantitatively, for Qwen3-32B on ShareGPT, the theoretical MAE floor is 129.5 tokens. Their best-performing predictor achieved 168.1, meaning the "model error" is only about 38 tokens—the rest is unavoidable noise.
Limitations and Future Work
- Numerical Inconsistency: The authors noted that their prefill features and decode labels were generated on different hardware/software pipelines, which might introduce tiny floating-point discrepancies.
- Static vs. Iterative: This paper focuses on "prefill-only" prediction. While iterative prediction (updating the guess as tokens are generated) can reduce error, it comes with a high computational cost that might not be worth it for all scheduling applications.
- Sampling Sensitivity: The fundamental limits are tied to sampling parameters (like temperature). Future work could explore how to optimize sampling to minimize variance without hurting output quality.
Summary updated