arXiv(opens in a new tab)cs.LGAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.25096

Understanding the Energy Scaling of Large Language Model Inference Across Context Lengths and Attention Architectures

Molka Chkir, Syed Muhammad Danish, Jos Höll, Arghavan Asad

Molka Chkir*, Syed Muhammad Danish*, Jos Höll†, Arghavan Asad*

*Algoma University, Brampton, Canada

†School of Informatics, Reutlingen University, Reutlingen

Emails: {mchkir, syed.danish, arghavan.asad}@algomau.ca, jos.hoell@reutlingen-university.de

Abstract—The growing adoption of large language models (LLMs) has raised increasing concerns about the energy consumption and environmental impact of inference. This paper presents a systematic empirical study of decode-phase energy consumption across representative open-source LLMs employing Multi-Head Attention (MHA), Grouped Query Attention (GQA), and Grouped Query Attention with Sliding Window Attention (SWA) to characterize how attention architecture influences decode-phase energy consumption under varying inference workloads. We evaluate four models across different context lengths, batch sizes, and generation workloads while measuring GPU energy using NVIDIA hardware counters. We examine the effects of context length, attention mechanism, Key-Value (KV) cache growth, and batching on decode-phase energy consumption. Results show that attention mechanism is the primary factor governing how decode energy scales with context length. MHA models exhibit substantially steeper energy growth than GQA models, whereas GQA with SWA maintains nearly constant energy consumption. We further show that model size primarily determines absolute energy consumption, while batching reduces both energy per generated token and request latency by up to 87%. These findings provide practical guidance for selecting energy-efficient LLM architectures and inference configurations.

Index Terms—Large Language Models, Sustainability, Attention, KV Cache

I. INTRODUCTION

LLMs [1] have become the foundation of modern AI applications, enabling capabilities such as conversational assistants, code generation [2], question answering, and summarization [3]. As these models transition from research prototypes to production services, their environmental impact has become an increasing concern. The computational demands of training and serving LLMs result in substantial energy consumption, carbon emissions, and water usage [4]. While model training has traditionally received the most attention, recent studies estimate that inference may account for up to 90% of a model's total lifecycle energy consumption [5]. Consequently, improving inference efficiency has become a key challenge for the sustainable deployment of LLM-powered applications.

Despite growing interest in sustainable LLM inference, existing work remains limited in scope. Most prior studies have focused on the environmental impact of model training [4], [6] or have evaluated inference energy using only a small number of models under fixed workloads [7], providing limited insight into the factors that govern inference energy consumption. One particularly important but underexplored factor is the evolution of attention mechanisms across modern LLM architectures. Contemporary models employ increasingly diverse attention designs, including MHA [8], GQA [9], and Grouped Query Attention combined with SWA [10]. These mechanisms differ fundamentally in how Key-Value states are stored and accessed during autoregressive decoding, leading to different computational and memory behaviors as context length increases. Although these architectural innovations were introduced primarily to improve inference efficiency, their impact on decode-phase energy scaling has not been systematically characterized. Consequently, developers lack evidence-based guidance on how attention architecture influences inference energy and the associated deployment trade-offs.

To address this gap, we present a systematic empirical study of decode-phase energy consumption across representative open-source LLMs employing different attention mechanisms. Rather than measuring only overall energy consumption, our objective is to understand how decode energy scales under realistic inference workloads. Specifically, we investigate how context length, attention mechanism design, KV cache growth during autoregressive generation, and request batching influence decode-phase energy consumption. We address the following research questions (RQ):

– RQ1: How does decode energy per generated token scale with increasing context length?

– RQ2: How do different attention mechanisms influence the scaling of decode energy with context length?

– RQ3: How does token position within a generation sequence affect decode energy as the KV cache grows?

– RQ4: How does batching affect energy per generated token and latency across models and context lengths?

To answer these research questions, we conduct a comprehensive empirical evaluation of four representative open-source LLMs spanning three attention mechanisms: OPT-1.3B and Phi-3 Mini (MHA), Gemma-2-2B (GQA), and Mistral-7B (GQA with SWA). Our results show that attention mechanism design is the primary factor governing decode-energy scaling. MHA models exhibit substantially steeper energy growth than GQA models, whereas the combination of GQA and SWA maintains nearly constant energy consumption as context length increases. Within a generation sequence, decode energy progressively increases for MHA models as the KV cache grows, remains largely stable for GQA models, and is effectively constant with SWA. In contrast, although attention architecture determines energy scaling behavior, absolute energy consumption is primarily driven by model size, meaning that a smaller MHA model may consume less energy per generated token than a larger GQA model despite its less efficient attention mechanism. Finally, batching consistently improves inference efficiency, reducing both energy per generated token and request latency by up to 87% across all evaluated models and context lengths. Together, these findings provide a systematic characterization of how modern attention mechanisms influence decode-phase energy scaling and offer practical guidance for energy-aware deployment of large language models.

The rest of the paper is organized as follows. Section II presents the related work. Section III presents the overall methodology and experimental setup. Section IV discusses the results and analysis for each research question. Section V presents the limitations, while Section VI concludes the paper.

References (21)