Editor’s introduction
The study examines compute time and energy consumption in large language models during prefill and decode phases, measuring how input and output token lengths affect performance. The research establishes compute time as a reliable proxy for energy when direct measurements are unavailable, enabling estimation of API-level energy use through paired models.
Introduction
Large Language Models (LLMs) have evolved from primarily supporting isolated conversational interactions to becoming foundational components of increasingly complex applications. As their adoption and usage continue to grow, accurately estimating their energy consumption is becoming an important operational and environmental concern. For open-weight models deployed on accessible hardware, energy consumption can be measured through software telemetry or external power meters.
We address this gap by systematically profiling LLM compute time and energy consumption across a grid of input and output token lengths, independently varying the tokens processed during prefill (input) and those produced during the decode (output) stage.
Based on these empirical observations, we fitted generalized linear models (GLMs) on locally collected compute time and energy data, capturing the contributions of input and output tokens. We show that the number of input tokens has both linear as well as quadratic effects on compute time and energy consumption. These results demonstrate that estimates based predominantly on generated tokens may fail to capture an important component of inference cost for long-context requests.
The fitted GLMs provide a compact and explainable representation of the LLM’s compute time and energy behavior. For each local hardware and software configuration, we fit a GLM pair, one predicting compute time and the other predicting energy consumption for input–output configurations.
Because energy consumption depends on both execution time and power draw, compute time predictions alone are insufficient, particularly for proprietary APIs whose underlying hardware and power characteristics are not observable. Following the local-equivalence approach proposed by Krupp et al., we compare the API compute time GLM with the local compute time GLMs and select the configuration whose behavior is most similar over the evaluated workloads. We refer to this configuration as a workload equivalent and use its paired energy GLM to obtain a locally grounded estimate of API energy consumption.
Our work presents an empirically grounded and explainable modeling approach for estimating LLM compute times and, through locally measured power characteristics, their associated energy consumption. Our method is suitable for both local and API-accessed LLMs and requires no access to the proprietary serving infrastructure. It is particularly relevant to context-intensive applications, including increasingly common multi-turn and agentic workflows.
Modeling Inference Time and Energy
The environmental impact of large-scale machine learning systems has received increasing attention in recent years. Early work primarily framed this issue around the cost of training large neural models, showing that gains in model accuracy often come with substantial financial and environmental costs, and proposing that model comparison should account for both predictive performance and computational resources. Further work showed the dependence of carbon estimation on model architecture, accelerator type, datacenter efficiency, and geographic energy mix, making estimation difficult when these factors are not reported.
With the widespread deployment of LLMs, research on the environmental impact of machine learning has increasingly expanded from training to inference. The lifecycle assessment of BLOOM included its deployment phase, measuring energy consumption over approximately 18 days of serving real API requests and observing continued consumption even during periods of minimal demand. Further work investigated the impact of model size, GPU generations, workloads, and distributed multi-GPU configurations on inference energy, and evaluated the trade-offs among quantization, output accuracy, latency, and energy when running LLMs on a Raspberry Pi. Others attributed per-prompt energy to active accelerators, host CPU and memory, provisioned idle capacity, and datacenter overhead using internal telemetry from the Gemini Apps serving fleet. These studies show that the energy attributed to inference is determined not only by the model and the request, but also by the hardware and infrastructure through which the request is served.
While these studies focus primarily on measuring and attributing inference energy, complementary work has examined the serving mechanisms that determine how computional resources are used during inference. LLM inference was shown to have distinct power phases, with a compute-intensive prefill phase and a longer decode phase with different utilization characteristics, allowing their separation across different hardware resources. The influence of input and output sequence length on inference energy was further investigated by Cavagna et al., who proposed an analytical model accounting for computational and memory access costs and identified non-linear relationships between sequence lengths and energy efficiency. At the application level, Matinpour et al. investigated the impact of orchestration frameworks, foundation models, and deployment constraints, demonstrating that framework selection affects system performance beyond the choice of the underlying model. They also observed increasing end-to-end latency with larger context windows, although their analysis does not separately characterise the contributions of the prefill and decoding phases.
Studies used prompts with lengths of 8, 115–1360, and approximately 64—4096 tokens per request. This range is extended to 50,000 input tokens with fixed output length, but only in the context of locally deployed models running on known hardware.
Estimating Energy for API Deployments
However, commercial APIs expose only request-level information such as token numbers and response time, leaving the underlying infrastructure and power consumption hidden. This limits the applicability of estimators requiring direct measurements or detailed system knowledge and motivates approaches based on observable request information.
EcoLogits, the closest approach to ours, models GPU energy using the number of output tokens, active model parameters, and an assumed batch size, while host-system energy is estimated from the request duration, inferred hardware requirements, and datacenter overhead. However, input token length is not explicitly represented in its energy or compute time models, so the additional prefill cost associated with longer prompts is not separately captured.
Consequently, the timing behavior of proprietary API-based LLMs over substantially longer contexts, and its implications for energy estimation, remains insufficiently characterized. We address this gap by systematically varying input length up to approximately 200,000 tokens while controlling output length and measuring its effect on request duration, compute time, and energy consumption under explicit hardware and power assumptions.
Characterizing Local Compute Time and Energy Consumption
Existing estimation approaches often emphasize output generation, treating input token processing as negligible. This assumption becomes questionable for modern long-context and agentic workloads. We therefore first characterize the effects of input and output length on locally measured compute time and energy consumption. We evaluate our approach on Mistral-Small-2603, a Mixture-of-Experts (MoE) model with 119B total parameters, of which 6B are active. Its size allows it to fit on two H200 GPUs, making it a candidate for local deployment and testing.
Benchmark Construction and Experimental Design
Crucially, our benchmark only aims at generating a prompt of a fixed input token length, while ensuring a fixed output length. To do so, we constructed each prompt out of three parts. Each prompt starts with a randomly generated 32bit nonce (number used once) to inhibit prefix caching, costing approximately 64 tokens. This ensures that the computations required in the prefill phase have to be executed each time and results are not retrieved from the cache. The second part consists of random sentences that can be extended until a defined input token length is reached, allowing the input token length to be scaled to arbitrarily large numbers. Finally, we added a prompt (310 tokens) that generates a large number of output tokens. To control the output token length, we used the max output token parameter, which stops the decoding step once the desired output length is reached. The complete prompt is provided in the supplementary material. Using this setup, the number of input tokens of each prompt and the output tokens of the LLM’s response can be finely controlled. Since LLMs are statistical models, a desired output token length cannot be guaranteed. We safeguard against this case through reruns.
Existing work commonly quantifies LLM inference energy, focusing on tokens generated during the decode phase, leaving the impact of the prefill phase on time and energy consumption underexplored. However, we argue that the prefill phase is becoming increasingly important as modern LLM-based systems process progressively longer input contexts.
If the general assumption in the field holds, the results of our experiments will show that increasing input token numbers has little to no impact on the overall compute time. On the other hand, we expect to see more than a linear increase in compute time since the number of prefill operations scales quadratically with the number of input tokens.
Modeling Compute Time and Energy
To characterize compute time and energy consumption, we fitted statistical models relating both outcomes to the respective numbers of input and output tokens. The models should be interpretable and reflect the computational structure of transformer inference. We therefore favored statistical models over approaches such as deep neural networks, which may achieve low prediction errors but typically require more training data and provide limited insight into the modeled relationships. Specifically, we employ generalized linear models (GLMs) with a quasipoisson error structure and an identity link function.
To fit our models, we used the data points collected in our coarse grid search to fit one compute time and one energy consumption GLM per local configuration. This allows us to characterize the relationship between input and output token numbers and both measured outcomes.
We filtered the local datasets using the standardized deviance residuals of the preliminary GLM fit. Observations with absolute deviance residuals of 3 or greater were removed to eliminate background anomalies and prevent outlier masking during final parameter estimation.
Effects of Input and Output Length
This behavior is consistent with the theoretical stucture of transformer inference. Prefill and decoding process the same input–output workload, while their different power profiles determine how elapsed time contributes to consumed energy. Together with the local measurements, this provides a basis for using compute time behavior to select a local energy model for a comparable workload. The coefficients of the time and energy models can differ because power draw varies across phases and configurations.
Estimating API Energy Through Workload Equivalents
We call the selected configuration a workload equivalent for the API over the evaluated input–output range. The local findings motivate the assumption that similar compute time behavior across these workloads can support a useful energy proxy. The transferred energy estimate is conditional on the power characteristics of the selected local configuration.
Modeling API Compute Time
To better isolate the time attributable to LLM computation time, we developed a benchmark specifically for time and energy estimation that incorporated a network latency estimation procedure, thereby reducing the influence of noise associated with API calls.
Estimating API Energy Consumption
The local time and energy models show analogous dependence on the input–output workload. The API compute time model exhibits the same linear and quadratic input contributions, motivating the assumption that its energy consumption also reflects these workload-dependent costs. Under this assumption, we use the energy GLM paired with the selected workload equivalent to estimate the energy consumed by the API-accessed LLM.
Comparing Energy Estimates
As our empirical results have confirmed, prefill time depends on input length, and assuming it to be constant or linear can lead to inaccurate energy estimates, especially at large context sizes. Current approaches to measuring and estimating inference energy therefore need to be reevaluated using workloads with large numbers of input tokens.
Discussion
The results of our experiments show the relevance of input tokens when estimating the compute time and energy consumption of LLMs. Our approach uses GLM pairings to describe their dependence on the input–output workload. These local models then support the selection of a workload equivalent for API energy estimation.
Prefill Time Must Not Be Neglected
While currently established estimation approaches can be accurate for small input lengths, for larger input lengths, these approaches will systematically underestimate the compute time and consumed energy. In an era where large context sizes are standard, e.g., in AI agents and complex RAG systems, we need to consider energy estimation approaches capable of properly modeling all contributing factors.
Scaling Our Approach Through Workload Equivalents
The fitted GLMs provide an interpretable representation of how compute time and energy vary with input and output length. Especially the better explainability and direct alignment with the transformer architecture, compared to purely data-driven methods, offer a robust approach for real-world benchmarking.
The API application depends on identifying a local workload equivalent whose compute time behavior closely matches that of the API-accessed model. Additional measurements across hardware, software, and batch configurations can expand the available comparisons and may improve the match over the workloads of interest.
While our approach has some distinct disadvantages, such as the cost associated with exploring this configuration space, the benefits are significant. Apart from enabling the estimation of the compute time and energy consumption for otherwise completely opaque models, the GLMs can support the development of more sustainable agentic AI systems. They can inform model selection, software, and hardware configurations based on expected input and output token lengths and their associated energy footprints. As LLM context sizes continue to grow, knowing how compute time and energy consumption scale with it becomes increasingly important.
To expand the available GLM pairs, we further plan to involve the larger research community through hosting a website44 4 [removed for review] that aggregates the GLMs and data recordings of other models and configurations, including different batch sizes.
Coverage of Local Configurations and Workloads
We were able to conduct our experiments only on a limited number of hardware and software configurations, due to limited computational resources. While an exact match with the API version of Mistral-Small-2603 was not among them, our empirical data showed the non-negligible impact of input length on energy consumption. The selected workload equivalent is the closest approximation among the evaluated configurations and over the evaluated token range.
Energy Transfer and Measurement Scope
The shared GLM structure and the local time–energy relationship support the use of a workload equivalent, but the absolute energy estimate depends on local power characteristics. Similar compute time behavior can occur with different hardware, power draw, or serving arrangements. The API energy estimates should therefore be interpreted as estimates under the selected local configuration’s power characteristics, rather than as direct measurements of the provider’s energy consumption.
Our direct measurements cover GPU energy. Applying a PUE factor accounts for an assumed datacenter overhead, while other components of the provider’s energy use, including host-system energy and shared idle capacity, are not directly measured. In addition, the fitted model terms reflect the evaluated model and serving configurations. Other architectures or serving mechanisms may require a different functional form, which can be investigated using the same profiling approach.
Conclusion
Because direct energy measurements are unavailable for proprietary LLMs, we then use compute time to identify a local workload equivalent and use its paired energy model to estimate API energy consumption. This extends the local characterization to API deployments under the power assumptions of the selected configuration.


