How CarbonTrace works out the carbon
CarbonTrace looks at three things: opening a web page, one program asking another for data (an API call) and asking an AI a question. Each one uses electricity, and making electricity gives off carbon. I'll take each one step by step, with the numbers the code uses.
Four words come up a lot. A watt (W) is how fast something uses electricity. A watt-hour (Wh) is how much it uses: one watt for one hour. A kilowatt-hour (kWh) is a thousand watt-hours. CO2e counts carbon dioxide and the other gases that warm the planet, all as if they were carbon dioxide.
Opening a web page
-
The page travels to you
A web page is a bundle of files that comes from a server, across the network, to your screen. Their size is counted in bytes. This page is 24,988 bytes at full size. It gets squeezed on the way, so fewer bytes travel, but I count the full size.
-
Moving it uses electricity
Data centres, networks and your device all use electricity to send and show those bytes, and so did making all that hardware. The model counts 0.81 kWh for every gigabyte, which is about a billion bytes. For this page that's 0.019 Wh.
-
Electricity gives off carbon
Power stations that burn gas or coal give off carbon. The model uses an older world average of 442 g of CO2e for each kWh. Today's is higher, so these numbers lean low. Each visit to this page makes 0.0083 g, and about 6,000 visits make as much as one cup of tea.
An API call
-
One program asks another
An app asks a server for something, like a list of users. In this example the server works on it for 500 milliseconds, which are thousandths of a second.
-
A slice of a server does the work
A server handles lots of requests at once, so one request gets a slice of its power. I count that slice as 50 W for as long as the request runs. I didn't measure it; it's my rough figure for a typical slice. Here it comes to 0.0069 Wh.
-
Electricity gives off carbon
At 442 g of CO2e for each kWh, this call makes 0.0031 g. About 16,000 calls like it make as much as one cup of tea.
Asking an AI
-
The AI reads and writes tokens
AI models read and write in tokens, which are words and bits of words. In this example the question is 500 tokens long and the answer is 150.
-
Writing the answer is the work
The AI reads your whole question in one go. It writes the answer a token at a time, and each new token means another full pass through the model, so writing costs far more than reading. I count only the answer: 0.85 Wh for every thousand tokens, which comes to 0.13 Wh here. I took that figure from a study of large models running on busy, shared servers. Real models vary a lot.
-
The building around the chips uses power too
Cooling and power supplies in the data centre use energy on top of what the chips use. The same study gives a range for that extra, and I take the middle of it: 1.21 times the chips' energy. That makes 0.15 Wh.
-
Electricity gives off carbon
At 442 g of CO2e for each kWh, the question makes 0.068 g. About 730 questions like it make as much as one cup of tea.
From grams to cups of tea
-
Grams you can picture
A gram of CO2e is hard to picture, so CarbonTrace divides the grams by the carbon in something everyday. A cup of tea is about 50 g, so 730 questions like the one above fill one cup.
It uses four everyday things:
- 50 g for a cup of tea. My own estimate; it depends on the kettle and the milk.
- 400 g for a mile in an average passenger car. The US EPA's figure, rounded up.
- 5 g for charging a phone. My own estimate. It's below the US EPA's figure, so it shows more charges than the EPA would.
- 10 kg for what one tree takes in over a year. My own estimate, set low on purpose so it never overstates what a tree does.
What it leaves out
- The power your own setup draws. CarbonTrace counts bytes, seconds and tokens, then uses fixed figures for the energy. Nothing measures what your device, your network or the server draws.
- Where your electricity comes from. Every figure on this page uses one world average. When a report names its region, the server fetches that year's real figure for the US, the EU or Sweden from Climatiq (Ember's data); everywhere else still gets the world average.
- Everything around the server or chip for API calls and AI prompts: networks, the devices at each end and the making of the hardware. The web page model counts those. The other two count only the server or chip at work, and for AI prompts the cooling and power supplies of the building it sits in.
- Long questions. Only the answer's tokens count, so a question that carries a long document or a big chunk of code gets undercounted. Nobody has measured what reading costs on real, busy servers yet, so I'd rather name the gap than guess a number.
- Which AI answers. CarbonTrace doesn't use the model's name, so a small model and a large one get the same figure for the same answer.
- Training the AI. It counts the energy to answer your question. Building the model isn't in it.
- The moving drawings on this page. Your device works a little harder to move them, and the page's weight only counts its bytes. If you've asked your device for less motion, they stay still.
These are estimates for learning and for spotting trends and heavy spots. They aren't certified carbon accounting.