Solve the Sudoku: Few-Shot Energy-Latency Map Profiling for Sustainable LLM Serving
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:00 Our next presentation has actually prepared a video for us to watch, but they'll be online to take questions. So this is from the Hong Kong University of Science and Technology. Kunming Zhang will be presenting and he'll be talking about how to generate a mapping between energy and performance metrics. Good morning, everyone. My name is Kunming Zhang from the Hong Kong University of Science and Technology, Guangzhou. I'm sorry I cannot join you in person, but I'm very glad to have the opportunity to present our work today. Before introducing our methods, let me start with the simple questions. An energy-aware LLM serving system needs to know which configuration is fast enough and which one consumes less energy. But building this information also requires real GPU profiling. So can a few measured configurations reveal the latency and energy of all of the configurations we did not measured? Here is the brief pipeline of sustainable serving scheduler. Suppose a request comes with a latency budget. The system can choose among many configurations to service the different engines, different GPU, different model, and different batch size. To do the decisions, you must know the latency and energy information of each configuration.
1:29 That is the map. It records the information for each configuration. With this information, the scheduler can then filter out the choices that meets the latency budget and rank them by energy. The map is very useful, but you paid a lot of GPU times and energy to get a full map. There are three common methods to reduce the cost of map construction. The first one is interpolation. It needs to measure broadly across the grid. The second one is black-box predictor. It also needs to collect many labeled profiling runs. The third one is simulation. It's based on the kernel database. It still needs 30 GPU hours for each GPU engine database. This method still requires substantial profiling runs. So, can we recover the map from only a few measurements? Our answer is yes. The key is the gray box and reusable rule.
2:42 Our rule is an empirical kernel family scaling law. Just like solving the Sudoku, you can fill the whole map with only the few clues if you have a rule. Let's come to the detail of our rule. For our first observations, we found that the kernel family composition shifts with workload. This figure is about the attention kernel's share of total kernel latency in the decode phase. We can see that as the input length growing up, the share of the attention grow from 3% to 15%. The GEMM remains the dominant, but its relative share falls. It means that if we don't decompose the kernel family and just use the end-to-end models for prediction, the models must learn both the kernel family scaling and the composition shifts. Indeed, the learning burdens would be large.
3:43 So, in the following step, we decompose the kernel family and model each signal separately. Our key idea is to derive a separate scaling law for each kernel family based on their dominant computation pattern. For example, attention is driven by context growth, especially in decode phase. This computation will grow up as the output context being longer. The GEMM is mainly dominated by the token level dense arithmetic. Memory families such as the activations and element-wise are dominated by the cache and data movement. We translate these execution patterns into the feature skeleton in the log space. We use the log output length, log batch size, and the square log batch size. The square terms capture the fact that increasing batch size would change the GPU utilization and memory behavior. So, the linear scale is not enough. Attention requires more specific features because its computation is accumulated.
4:58 So, we derive this formula according to the prefix sum formula. The prefill stage follows the same design principles as the decode phase, but has a different skeleton. Note that these terms are not the theoretical rules. They are empirical rules. More importantly, because these laws are based on the computation patterns, they can share across the different GPUs and models within the same serving engine. Here is the complete model. We first decompose the stage level latency or energy into seven measured kernel families. And then, we sum the family costs to get the total stage costs. For each kernel family, the costs consists of two components. The right module is the empirical scaling law we introduced on the previous slides. And the left one is the intercept term with specific semantics. The first intercept is the base scale for a given kernel family. The second term captures the GPU-specific effects and the third capture the model-specific effects. The semantics of this framework is very important. For example, our kernel family scaling laws are shared within the engine. This means that when we fit this model, we can pull the data from different GPUs and models together to fit this. It is also work in the intercept term. When we fit the GPU effect intercept, we can pull the data from the same GPU but different models together to fit this. The semantics
6:44 is also useful for generalizations. If a GPU and a model has both been observed but their exact combination is new, you can compose the GPU effects and the model effects intercept together to predict the pair. If the GPU or model is completely new, we can keep the shared scaling law fixed and calibrate only the missing deployment scale, the missing intercepts with a few target-side measurements. And now we can answer the question, how many measurements should we need to recover the map within this framework? Our experiment shows that three shots per stack are enough. The experiments are done in three GPU, three models, and two engines. One stack here means the GPU model engine pairs. And one shot here means the one configuration. With only three configurations per stack and 54 configurations in total, we can reach 9.6% mean WAPE across the prefill and decode phase and latency and energy. We also find that the six shots improved WAPE only to 9.0%. The extra gain is limited. So we think that the three shots are enough. A natural question is whether the improvement simply comes from pooling the data? To answer this, we conduct an ablation study using exactly the same data.
8:29 With pooling alone, XGBoost achieved a mean WAPE of only 38%. When we added the shared scaling structure, the error dropped sharply to 11%. And we further combined the kernel decomposition in it. The value dropped to about 10%. So the main gain comes from the scaling structure, while the family decomposition provides a smaller improvement. Next, let's see whether this structure also generalizes to the unseen settings. For the first experiments, we remove one exact GPU model pairs, while we're keeping the GPU observed and the model observed. With no more target measurements, we just compose the GPU effects and model effects together to do the predictions, and we get 13% WAPE. This indicating that our model is semantically usable. Next, we remove the entire GPU or the model level.
9:40 The zero shot performance is very bad. We just get 45% and 80% in the unseen model tasks and unseen GPU tasks. While, when we have one more shot to calibrate the intercept, the results come to the 16% and 15%, showing the great performance in generalizations. The accuracy is only the half of our story. Our main target is to reduce energy costs in the map construction.
10:20 To achieve the WAPE of 9.2%, XGBoost need 792 profiling runs. By our measures, we only need the 54 physical measurements to achieve the 9.6% WAPE. In estimation, we just cost 15 times lower energy to recover the map. Now, I'm going to talk about the hard case and boundaries of our model. In our evaluation, the WAPE of prefill energy is the hard case.
10:57 One likely contributor is the difficulty of attributing the energy to a very short window. The prefill stage is the short window. We sample the power by the NVML, while the NVML provides low rate and lagged power samples. This figure shows that the blue trace is the NVML samples, and we can see that the prefill stage lasts for about 0.6 seconds, while the NVML power response begins roughly 0.2 seconds later. In other words, the sampling lag affects one-third of the entire prefill window. Although we have tried several ways to address these issues, we haven't fully solved it. This is something we are still exploring now.
11:52 Our current evaluations cover three GPUs, three models, two serving engines, and all of the configurations are evaluated in the single GPU. For the future work, we will extend the work to multi-GPU, multi-node, and MoE serving. The overall framework can remain the same, but we will need to introduce the new kernel family, such as the communication family and the routing experts family.
12:23 Let me close the loop. Energy-aware serving needs the deployment-specific energy and latency map, but the dense profiling makes the map expensive to build. We use the empirical kernel family scaling framework to recover the map from the few measurements. And using this framework, we recover the map with only three shots per stack and reach 9.6% mean WAPE. Compared to the black-box models, we saved the profiling energy cost from 916 to 64 kJ. That's all of my presentation. Thank you for your attention. I'm happy to take any questions now. Thank you for the Zoom. Hi, Kunming. Thanks for your talk.
13:28 Questions from the audience? Yes, we did. Yeah. One of the questions that I had was you showed how for new GPUs, you need a handful of points. I think it was like one point even brings you down from an error of 45% down to like 16%. I'm curious if you also tried looking at non-GPU type of architectures or even different vendors. Like is the gap there more? And do you need additional points to be able to kind of ground your estimates? Or, for example, if you looked at a TPU or any intuition- Sorry, your sound is low. Can you speak again and speak louder? Yeah. So the question was, if you broaden from just GPU architectures to other types of AI accelerators,
14:31 how would your process scale to those other types of hardware platforms? Okay. Do you mean these ones, the unseen GPU and the unseen model task? Yes, yeah. Okay. And for these experiments, we just left the GPU unseen and the zero-shot experiments. We cannot see these GPUs in our experiments. And the performance is very bad. And we just use one shot. The shot is in the medians of the configurations. For example, maybe the median configuration of the batch size and the median configurations of the input lengths. And we just use the one-shot to calibrate the GPU effects. Just like this one, the intercepts of the GPU effects or the model effects. Just use one shot to calibrate it. And we can get this good performance.
15:43 Sounds like one shot is needed, I think. You can't just extend to unseen things. I had a comment and maybe just something worth thinking about. The structure of this problem, there's an analogy in kind of medical treatment studies where they usually have multiple treatments they want to test. And usually they care about combinations of treatments. And there's never like a pool of patients big enough to test all combinations. So they have a very specific structure of how they combine treatments on different patients in order to kind of maximize their coverage and try to extract some sort of signal from their experiment. It really boils down to selecting like the right set of points to test. And I guess I'm curious, the shots that you do get to make here, how carefully selected are they?
16:35 Are they like randomly generated? Are you trying to sample the space in some particularly careful way to extract a good signal? And to get the signals, we use the Nsight Systems. And to use the NVIDIA Nsight Systems, this tool to help us to make the measurements. By this tool, we can get the specific timelines of the kernel family and the kernel excels. And we just use this tool to get the measurements to decompose into the kernel family scale. I think my question is about, if you look at the matrix and you try to pick which boxes in the matrix to measure, the selection of the boxes probably matters to how effectively you can kind of recreate the signal. So how do you guys go and choose which boxes to measure?
17:28 Okay, you mean the one shot, how to select the target shot? That's right. Yes, and I also do the sensitivity analysis. And for the zero shot, it is bad. And I just split the configurations into the three areas. For the low configurations, for the low batch size, low input length is the low areas, and the middle ones, and the high one. The high one is maybe the out of memory ones. Yes, and we found that the high areas, we can have the best performance. But for the balance default, we also, we finally choose the middle, in the middle areas. It means that for the range of the middle area, we just randomly choose one shot in it.
18:20 Got it. That makes sense. Okay, any other questions from the audience? All right, so let's move on. Thank you very much, Kunming. Thank you.