Offline Energy-Optimal LLM Serving: Workload-Based Energy Models for LLM Inference on Heterogeneous Systems
This transcript was made by AI. The open source speech recognition model Whisper (large-v3-turbo) transcribed the recording with faster-whisper. Names and technical terms were checked against the paper, but it can still contain mistakes. The recording is the reference.
0:01 Hello, my name is Grant Wilkins, and today I'm going to talk to you a little bit about how we did some offline energy optimal LLM serving by creating some energy models based on workloads for LLM inference from the University of Cambridge. I'm presenting on behalf of Professor Keshav and Professor Mortier. So without further ado, as we all know, and as is reflected in the program of this year's HotCarbon, energy demand of AI is on the rise. With the adoption of these softwares and these services, there's a large ecological impact that is being seen worldwide. Here are just a few news articles that have been sent to me not only by professors, but also family members, and everyone is covering this, how there is just a lot of environmental costs associated with generative AI.
0:58 And so for one of the first times in several years, there's a large demand of energy in the United States and in other places in the world that's on the rise, largely attributed to the widespread adoption of AI and its use of heterogeneous resources that are a bit more power hungry than your traditional data center, CPU centric services. And it's not just energy as well. And it's not just energy as well. There's other issues such as water and carbon in this work. We're taking a little bit of advantage of the combination of the relationship between energy and carbon while it's not always a direct relationship, oftentimes where there's more energy, there's more carbon usage. And so our solution to this issue is to look at workload based models.
1:50 So based on the number of input tokens, the number of output tokens required by these models. If we look at the node and device level energy usage, what kind of optimizations can we make? This is in contrast to looking in aggregate, which a lot of studies do and a lot of current literature focuses on these larger yearly trends rather than the actual systems level experimental results. And so our goal is to provide these and also to kind of start a conversation about how these different measurements can be useful. So our contributions in this paper are that we have quantified the energy usage of several open source LLMs. We've also developed some different workload based models for energy consumption and runtime. We've also demonstrated that offline routing with an operational tuning parameter can be effective in reducing the amount of energy using the aforementioned models.
2:52 And we've also open source or energy profiling tools. Oftentimes, I believe that sometimes energy measurements are a little bit mystifying and so are sometimes difficult to implement. And so our hope with this is that different practitioners can use this to profile their own LLM setups and solutions. So hopping straight into our results, we have focused primarily on collecting energy for varying the number of input tokens and the number of output tokens, while holding each of the respective variables constant. So in this case, we hold the number of output tokens at 32 and we vary how many input tokens we're feeding into a given LLM. Here are the different LLMs that we've focused on in our profiling. And what you can see in the case of throughput is that there's some level of saturation with the number of input tokens.
3:52 What that means is that whenever you increase the number of input tokens, there's some almost maximal throughput that is reached. And in the case of energy per token, you almost see an inverse effect that there is some energy per token or energy efficiency, as we're also calling it, that is reached by the model. Notable, notable, notable outliers of this is the Mixtral sparse mixture of experts model, which combines a few 7 billion parameter expert models into a larger model that has the abilities of something like a 50 billion parameter model. This is the first known study, I believe, that quantifies these energy savings, and so we're excited to share that. Now, the output tokens is a little bit of a different story. Alpha tokens in general are a lot more expensive to generate because if you think of how information is fed through these models, every time a successive output token is created, it gets appended as a vector to these matrices, meaning the matrices grow, multiplications become a lot larger.
5:13 And therefore, each successive output token is in general just more expensive. And so you see that throughput actually falls with the number of output tokens when keeping the number of output tokens constant. And energy per token rises. Again, Mixtral is a bit of an outlier. It behaves asymptotically a little bit more like Llama 2, 13 billion parameters. But the trend still remains that with more parameters, you're going to spend more energy, but you're also going to get more accuracy. And so what we noticed is that the energy associated with these models and the runtime as well were not independent for the number of input tokens and our output tokens. They actually had a coupled effect. We validated this through some analysis of variance experiments and found in general that there was actually a nice energy model that relied on not just the input tokens, not just the output tokens, but also both of them.
6:15 And so with this specific model, we fit energy models and runtime models for every single LLM that we had tested. This led to some very accurate models that were statistically significant that then could be used in optimization. So our optimization framework was essentially trying to minimize the energy of processing a certain number of queries. If we take a set of Q queries and we partition it to Q K. How much energy and how much accuracy can we trade off using some parameter zeta? The details of this, of course, we're glossing over a little bit, but you can, of course, read the paper and hopefully get some more clarification. But essentially what we wanted to do is we want to form a disjoint partition of these of these queries and route each specific query to a given model in an offline fashion.
7:19 This again is offline. So we have perfect knowledge of the system, including how many output tokens are going to be associated with the number of input tokens. And so what we realize or what we reach with our offline routing is that for processing 500 500 queries that with our zeta parameter, you can easily trade off energy and accuracy. When zeta is zero, we're going to have the most accurate models doing a lot of the work. Most of the queries are going to go to the Llama 2 70 billion model. And though, as zeta increases up to one, we shift a lot of the work over to some of our smaller models like Llama 2 7 billion and 13 billion parameter that also are less accurate, but also more runtime efficient.
8:11 And so one can imagine that zeta can be responsive to something like energy prices or sustainability, sustainable energy availability such that you during times, let's say around 5 p.m. or something when sustainable energy is maybe being diverted somewhere else, you would have a less accurate, but also more energy efficient system. And you would do some rate limiting to make sure only paying users or something like that were getting to use the highest quality model. But also then you could offer things more rapidly and with a given fixed accuracy. And so what we find is that this is a navigable space and that data center operators could use this tuning parameter zeta. So limitations of this work, of course, are that we didn't use any optimizations for inference.
9:12 We didn't use DeepSpeed or vLLM, which are existing optimizations, meaning that power measurements are in a certain sense an upper bound on the A100 GPUs that we used. And also zeta parameter tuning is not automated. One can also imagine that there would be a nice extension to this where based on, again, energy prices or sustainable energy availability that you could tune zeta automatically. Also, there's no current extension to the online setting. So again, future work would be based on some arrivals, you would have the energy. You could make a decision based on the estimated energy that a specific query was going to take. Finally, a takeaway is that we can profile a system and rapidly create accurate models of energy consumption that can be used to make informed scheduling decisions.
10:14 Future work hopefully will build on the limitations that we've outlined and make this more robust and versatile, extending beyond the kind of batched offline setting that we've focused on specifically in this paper. If you have any questions, my email is right here below. I'd be happy to talk to any of you all. Again, apologies for not being able to make it in person. I hope it's a great conference and everything. And I thank you all for listening. Without further ado, thank you so much.