TL;DR
Before deploying a large language model (LLM), engineers know its accuracy and latency, but rarely its energy bill. Wattribution solves this by measuring the energy of every individual layer while the full model is actually running, using a high-resolution GPU power buffer that refreshes every 20 ms instead of once per second. Trained on 34 million per-layer measurements, a lightweight estimator can then predict the energy of an unseen LLM from its configuration alone—no GPU execution required—with a median error of 13.1% on unseen models.
What Problem Does This Paper Address?
AI inference is now a major driver of data center electricity demand, yet energy consumption remains a second-class metric compared to accuracy and latency. Measuring it directly requires physical hardware, instrumented setups, and many repetitions.
To predict energy before deployment, researchers have tried building layer-wise estimators: measure each layer's energy, then add them up. The catch? Existing methods measure layers in isolation. Running a single layer repeatedly changes the GPU's clock frequency and voltage compared to running the full model. As a result, isolated layer energies underestimate the real workload and require empirical "fudge factors" to match reality. Worse, standard GPU power tools (like nvidia-smi) average power over ~1 second—far too slow to capture neural network layers that execute in under a millisecond.
Methods
The authors tackle this in three steps:
- Characterizing the right power sensor: For the first time, they characterize NVIDIA's
nvmlDeviceGetSamplesbuffer across nine GPUs (from Turing to Blackwell). Unlike the defaultnvidia-smireading, this sample buffer provides a new timestamped power reading roughly every 20 ms, covering 84–100% of runtime from Ampere onward. - The Wattribution protocol: Instead of isolating layers, Wattribution measures them inside the complete model's forward pass, preserving the GPU's real operating state. Forward hooks record each layer's start and end times, while a background thread polls the sample buffer every 10 ms. Power is reconstructed via a "backward hold" and integrated over each layer's execution window, then averaged over multiple repetitions to eliminate phase alignment noise.
- Analytical, layer-wise estimation: Using only features known from the model's configuration (batch size, prompt length, generated tokens, precision, MACs, and memory traffic in bytes), the authors train lightweight tree-based regressors (mostly Random Forests and XGBoost) for each layer type and phase (prefill vs. decode). Because the training data comes from full-model execution, the predicted layer energies simply add up to the total model energy—no correction factor needed.
Datasets
The authors introduce a new, controlled dataset of nearly 34 million per-layer energy measurements collected on an NVIDIA RTX 6000 Ada GPU. It spans 11 decoder-only LLMs across 5 families (Qwen3, Llama, Gemma 3, Mistral, and Phi), ranging from 0.6B to 8B parameters, evaluated over 200 inference configurations (1,548 total runs; 88 additional configurations exceeded GPU memory).
Key Insights and Ideas
- Batch size is the biggest lever: Increasing batch size from 1 to 128 drops the energy per generated token by up to 60× (e.g., from ~9 to 0.15 J/token on Qwen3-8B), because parallel requests share the cost of each decode step.
- Prefill can dominate: Long prompts make the prefill phase expensive and enlarge the KV cache read at every decode step. With an 8,192-token prompt and 16 generated tokens, prefill accounts for 66% of total run energy. Generating more tokens amortizes this fixed cost.
- Bytes per element drive precision cost:
fp16andbf16consume virtually the same energy, whereasfp32multiplies energy per token by up to 2.8×. - Normalization layers are surprisingly hungry: During decode, normalization layers account for the largest share of energy (~37% on average), followed by the attention core (~24%), with linear projections taking smaller shares.
Key Results
- Protocol validity: Wattribution adds a median overhead of just 6.9%, achieves high repeatability (median coefficient of variation of 2.3%), and its per-layer energies sum to the full generation energy within 0.7% without any correction factor.
- Prediction accuracy: The estimator achieves a Median Absolute Percentage Error (MedAPE) of 4.8% on unseen configurations, 13.1% on unseen models (leave-one-model-out), and 16.9% on unseen model families (leave-one-family-out)—outperforming parameter, FLOPs, and roofline baselines (which range from 18.9% to 51.4% MedAPE).
- Model ranking: In leave-one-model-out validation, the estimator preserves energy rankings with a Spearman correlation of 0.969 and picks the more energy-efficient of two models 90% of the time.
Limitations and Future Work
- GPU-only focus: The study measures GPU energy (up to 85% of LLM inference energy), leaving out CPU energy, which the authors plan to capture in parallel in future work.
- Single GPU hardware: The 1,548-run campaign was conducted on one GPU model (RTX 6000 Ada); testing how the estimator transfers across the other characterized GPUs is a next step.
- Inference engines: Measurements rely on Hugging Face Transformers; adapting Wattribution to production serving engines like vLLM or TensorRT-LLM remains future work.
Summary updated