The training and deployment of machine learning (ML) models have become extremely energy-intensive. While existing optimization efforts focus primarily on hardware energy efficiency, a significant but overlooked source of inefficiency is software energy waste caused by poor software design. This often includes redundant or poorly designed operations that consume more energy without improving performance. These inefficiencies arise in widely used ML frameworks and applications, yet developers often lack the visibility and tools to detect and diagnose them. We propose differential energy debugging, a novel approach that leverages the observation that competing ML systems often implement similar functionality with vastly different energy consumption. Building on this insight, we design and implement Magneton, an energy profiler that compares energy consumption between similar ML systems at the operator level and automatically pinpoints code regions and configuration choices responsible for excessive energy use. Applied to 9 popular ML systems spanning LLM inference, general ML frameworks, and image generation, Magneton detects and diagnoses 16 known cases of software energy inefficiency and further discovers 8 previously unknown cases, 7 of which have been confirmed by developers.
Figures & tables
Figure 1: Software energy waste, performance issues, and performance-energy trade-offs in the design space.
Figure 2: The power consumption of the join and early exit in DDP manager.
Figure 3: Total energy consumption and breakdowns of top 5 operators in HuggingFace Transformers.
Figure 4: Number of functionally equivalent implementations per category across top ML frameworks and libraries.
Figure 5: (a) Summary of popular machine learning repositories grouped by category. (b) Energy consumption of LLM inference systems; (x,y) means each request contains x input and y output tokens. (c) Energy consumption of operators in different ML libraries. (d) Energy consumption of different image generation systems.
Figure 6: System architecture and workflow of Magneton.
Figure 7: Matching semantically equivalent subgraphs in the computational graph.
Id
Case
Category
Description
c1
vllm-9471
Misconfiguration
Prefill attention consumes more energy with tensor cores disabled.
c2
vllm-10811
Redundant
Decode attention incurs energy waste via redundant data copy.
Table 2: Magneton detection and diagnosis result. - means baselines are unable to perform fine-grained profiling on this case. * means the profiling result is incorrect.
Id
Case
Description
Saved
St.
c17
pytorch-157334
Conv2D is inefficient in NCHW .
21.2%
✓
c18
tf-96396
TF conv. is inefficient in NHWC .
49.5%
✓
c19
pytorch-153195
Default math mode costs more energy.
85.5%
✓
c20
jax-29875
Inefficient cuDNN grouped conv.
55.4%
✓
c21
hf-38977
LMHead processes redundant tokens.
8.7%
✓✓
c22
vllm-20174
Inefficient default prefill attention.
9.9%
✗
Table 3: New issues that Magneton identifies with their descriptions. St.: ✓✓ fixed by our merged patch; ✓ confirmed or acknowledged; ✗ no response.
Figure 8: The sensitivity of Magneton’s semantic equivalence detection algorithm.
Figure 12
Op
Physical
Zeus
Magneton
Value
Value
Error%
Value
Error%
arange
266W
73W
-72.5%
255W
-4.1%
contiguous
317W
73W
-77.0%
311W
-1.9%
linear
455W
88W
-80.7%
459W
+0.9%
FlashAttn
695W
219W
-68.4%
693W
-0.3%
All-Reduce
365W
184W
-49.7%
363W
-0.6%
Table 4: Power measurement methods and relative error rate for different operators.