Skip to content

Estimate LLM inference impacts from Azure Foundry token meters - #267

Merged
jnioche merged 4 commits into
mainfrom
feat/264-azure-openai-ecologits
Aug 25, 2026
Merged

Estimate LLM inference impacts from Azure Foundry token meters#267
jnioche merged 4 commits into
mainfrom
feat/264-azure-openai-ecologits

Conversation

@dpol1

@dpol1 dpol1 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Fixes #264

The EcoLogits lookup is provider-neutral but only Bedrock had a billing adapter, so LLM usage on Azure stayed unestimated. This adds AzureFoundryTokenEcoLogits, the Azure counterpart of BedrockEcoLogits: it recognises the token meters billed under the Azure OpenAI / Foundry Models category, extracts the model label and the token direction from MeterName, maps the label to the EcoLogits coefficients via mapping.csv and estimates energy and embodied emissions for the output-token rows. The rows then flow through PWUE, carbon intensity, operational emissions and water like any other usage. First step towards the ecologits.azure split sketched in #143.

One thing worth calling out: Quantity (and ConsumedQuantity in FOCUS reports) already holds the consumed token count. The 1K/1M in UnitOfMeasure only describes the pricing block — Microsoft's FOCUS conversion rules define ConsumedQuantity = Quantity and ContractedCost = UnitPrice × Quantity / x_PricingBlockSize — so, unlike the Bedrock adapter with pricing_unit, no unit normalisation is applied. The issue text ("normalise the 1K/1M units") predates that finding.

Changes

  • ecologits/AzureFoundryTokenEcoLogits: filters on the meter category, parses MeterName (input markers Inp/inpt/input, output markers Outp/outpt/opt/out/output; deployment and pricing qualifiers such as Batch, cchd, pp, ShortCo are dropped from the label), scores output tokens only and leaves everything else untouched: unknown labels (warned once by EcoLogits), input and cached tokens, meters without a direction marker (reasoning, embeddings), non-token meters. Native and FOCUS bindings (MeterCategory/MeterName/Quantityx_SkuMeterCategory/x_SkuMeterName/ConsumedQuantity).
  • ecologits/mapping.csv: ten Azure OpenAI labels (gpt 5, 5, 5 mini, 5 nano, 5.1, 5.1 codex, 5.4, gpt 4.1, o1, o1 1217), each checked against the bundled coefficients.csv. Meter names taken from the Azure Retail Prices API.
  • Default configurations: the module is enabled in default-config-azure.json and default-config-azure-focus.json, before PWUE as Bedrock is in the AWS one.
  • Tests: AzureFoundryTokenEcoLogitsTest (parser cases use real meter names, e.g. GPT 5 outpt Glbl 1M Tokens, 5.1 codex opt Gl 1M Tokens, 5.6 terra ShortCo Cd Inp PP Gl 1M Tokens; native/FOCUS invariant: the same inference in both formats yields the same impacts) and AzureFoundryTokenEndToEndTest, which runs two minimal exports through the real default configurations and the EnrichmentPipeline.
  • Docs: module reference.

Verification

350 tests pass. Also ran the job in the Docker image with a fresh jar on the native fixture:

MeterName Quantity kWh embodied gCO2eq operational gCO2eq
GPT 5 outpt Glbl 1M Tokens 1,000,000 2.015 52.7 92.6
gpt 4.1 Outp regnl Tokens 2,000 0.0045 0.13 0.21
input / unmapped model / non-token / non-usage rows null null null

No file overlaps with #266, so the two can be merged in either order.

Left out deliberately

  • PTU, hourly hosting and fine-tuning meters: not token-based.
  • Reasoning and embedding meters: no input/output marker, so they are skipped — a slight underestimate for reasoning models until the fragment is confirmed on real data.
  • Other Foundry model families: the Retail Prices catalogue shows the same meter contract for Llama, Mistral, Cohere, Grok, Qwen (3.3 70b Outp FT DZ Tokens, 4.3 Outp Glbl L Tokens, unit 1K), so they only need mapping.csv entries verified against real exports; DeepSeek, Grok and Qwen have no EcoLogits coefficients anyway. Separate issue once this lands.
  • gpt-5.4 pro/nano and gpt-5.5 aliases: need the refreshed coefficients from Refresh the EcoLogits coefficients from the API #266; three lines once both are merged. gpt-5.6 is not in the EcoLogits API yet.
  • Input-token energy: same choice as the Bedrock adapter (EcoLogits attributes the generation cost to output tokens, see Energy Estimation Accuracy with Input Tokens mlco2/ecologits#86).

A real export would help

The parser is validated against the Retail Prices catalogue and synthetic rows, not against an actual EA/MCA or FOCUS export. If anyone has Azure OpenAI usage, a redacted tuple is enough to confirm the contract — export type plus MeterCategory, MeterName, UnitOfMeasure, Quantity (no cost or identifiers).

dpol1 added 3 commits August 24, 2026 15:42
AzureFoundryTokenEcoLogits is the Azure counterpart of BedrockEcoLogits: it
recognises the token meters billed under the Azure OpenAI / Foundry Models
category, extracts the model label and the token direction from MeterName,
maps the label to the EcoLogits coefficients via mapping.csv and estimates
the energy and embodied emissions of the output-token rows.

Quantity (ConsumedQuantity in FOCUS reports) already holds the consumed
token count: the 1K/1M unit only describes the pricing block, as per the
FOCUS conversion rules published by Microsoft, so it is not used to scale
the quantity. Unknown models, input and cached tokens, PTU, hosting and
fine-tuning meters are left untouched. Ships with the Azure OpenAI aliases
covered by the bundled coefficients and is enabled in both Azure default
configurations.

Fixes #264
Minimal native and FOCUS exports go through the default configurations and
the EnrichmentPipeline: the same inference must yield the same impacts in
both formats, the module must run before the factor and impact modules, and
input, unmapped, non-token and non-usage rows must stay untouched.

@jnioche jnioche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @dpol1

@jnioche jnioche added this to the 1.3 milestone Aug 25, 2026
@jnioche
jnioche merged commit f36057c into main Aug 25, 2026
3 checks passed
@jnioche
jnioche deleted the feat/264-azure-openai-ecologits branch August 25, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add EcoLogits estimates for Azure OpenAI

2 participants