Add Ecologits-based LLM inference energy estimation for AWS Bedrock#163
Add Ecologits-based LLM inference energy estimation for AWS Bedrock#163dpol1 wants to merge 23 commits intoDigitalPebble:mainfrom
Conversation
Modeled the data using a `ModelImpacts` static inner class, inspired by the `Impacts` class in `BoaviztAPIClient` to maintain codebase consistency.
|
a good start @dpol1! here are the variatons pricing unit / usage type I found in my dataset |
|
Why did you choose the name EcoLogitsStore ? Not sure what the Store bit is about. Why not just call it |
|
You make a fair point! Actually your feedback is valuable, I didn't know how to call it. |
you sound surprised :-)
what about simply |
|
Haha, you got me! Just wanted to make sure we were perfectly aligned. |
|
no offence but this interaction feels like I am refining prompts from chatGPT. |
Set up config init, column mapping, and Javadoc. Enrich logic pending.
Compute energy and CO₂ for Bedrock models from CUR metadata, normalizing token counts and splitting input/output tokens.
Use usageType to split input/output tokens for energy calculation. Fallback to ratio split when ambiguous. Fix modelId lookup key and aggregate results instead of overwriting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Looking at the sample CUR data you shared, I want to highlight two edge cases based on how the module is currently built:
Think this points needs a new PR, @jnioche pls give me a feedback on this I will also push the general documentation for the new |
indeed
yes, this would be a separate feature
great, let me know when you want me to review this PR |
- Add human-readable model names to bedrock.json alongside AWS model IDs. - Update unit tests to reflect new fields.
Co-authored-by: Claude AI <claude@anthropic.com>
|
@jnioche Ready for review now. |
jnioche
left a comment
There was a problem hiding this comment.
thanks @dpol1 - have left a few comments
What do you mean by: The EcoLogits coefficients are derived from research data and should be validated before use in production reporting
?
it is true of any external data we use like Boavizta - no need to specify it
did you compare the results you are getting here with examples from Ecologits?
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Show resolved
Hide resolved
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Outdated
Show resolved
Hide resolved
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Show resolved
Hide resolved
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Outdated
Show resolved
Hide resolved
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Outdated
Show resolved
Hide resolved
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Outdated
Show resolved
Hide resolved
Added it out of an abundance of caution since AI energy estimation is a relatively new field, but you're 100% right. It's redundant. I've removed it to keep the docs consistent with other modules.
I realized the coefficients I put in |
- Add warning logs for missing model IDs or coefficients to aid debugging. - Simplify extraction of usage types and product maps from row data. - Update energy and emissions values via direct assignment instead of accumulating from previous values.
- Replace placeholder values in bedrock.json with more precise estimates for all supported models. - Update unit tests to reflect the new coefficients.
|
Moorning @jnioche, I've now extracted the values precisely from the EcoLogits Python library and updated Also worth noting - EcoLogits already has direct/proxy support for the latest models (like Claude 4.6 Sonnet and Opus). (Of course, if you already have the exact Bedrock CUR strings for the newer models, let me know and I'll add them to the JSON right away). |
|
thanks @dpol1 |
|
Glad to contribute to this - Makes total sense to release the current batch first so this feature gets the right spotlight in 0.10. Take your time with the review and testing, and let me know if you need any further tweaks! |
one thing worth investigating is that the billing can have references to batch inference, which I know has quite an impact on the energy used. Maybe worth checking if batching is taken into account by Ecologits? https://bentoml.com/llm/inference-optimization/static-dynamic-continuous-batching this site is on my to read list and contains loads of useful explanations. |
think this article from EcoLogits might be useful: https://ecologits.ai/latest/methodology/llm_inference/
will have a look and report back the findings for both |
EcoLogits & batch size — TL;DREcoLogits does model batch size in its formulas (energy/token and latency/token), but then hardcodes
Concrete numbers (CMU/HuggingFace, ACL 2025): continuous batching + vLLM cuts energy by up to 73% vs unoptimized baselines on real workloads (BurstGPT, Azure traces). Batch size effect on energy is non-linear: drops until ~B=64, then plateaus + KV cache pressure kicks in. Practical implication: EcoLogits numbers should be read as a "mid-batch estimate (B=64)". They underestimate cost in low-traffic scenarios (effective B << 64) and overestimate for async batch inference (e.g. Bedrock batch mode, priced at 50% of on-demand — a clear signal of a different infrastructure path and energy profile). Suggested action: add a note in the docs flagging the B=64 assumption. For now, the most useful patch is just to document the assumption. Dynamic implementation requires data that we don't have. @jnioche What are your thoughts on this? How would you prefer to proceed regarding a potential dynamic implementation in the future? |
src/main/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogits.java
Outdated
Show resolved
Hide resolved
src/test/java/com/digitalpebble/spruce/modules/ecologits/BedrockEcoLogitsTest.java
Outdated
Show resolved
Hide resolved
best to document for now as you suggested and raise the issue with the Ecologits project itself. We can just mirror what they do for now and refine later. Worst case we could add a factor to modify the values to compensate for the under/overestimation depending on batch or non batch |
- Use `row.getJavaMap()` instead of manual `instanceof` checks for map extraction from `Row`, aligning with `Networking.java`. - Update tests to convert Java maps to Scala maps when building `GenericRowWithSchema`.
- Refactor bedrock.json to use aliases for model variants, reducing redundancy. - Update EcoLogits to register multiple model IDs from an optional aliases field.
Document the limitations of the EcoLogits `B=64` baseline, as shown in DigitalPebble#163.
|
hi @dpol1 are you planning more work on this PR or is it ready to review? Thanks! |
|
Hi @jnioche, ready for review! |
Summary
Adds a new
EnrichmentModulefor estimating the energy consumption and embodied emissions of LLM inference on AWS Bedrock, using static coefficients derived from the EcoLogits project.This follows the same pattern as$gCO_2eq$ ).
BoaviztAPIstatic: a static data file bundled in the JAR is loaded atinit()time, and the module matches Bedrock CUR rows to per-model coefficients to compute base energy (kWh) and embodied emissions(
Key design decisions (Discussed in #143)
PUE->AverageCarbonIntensity->OperationalEmissions).pricing_unitis parsed to handle unit normalization (e.g., converting "1K tokens" or "1M tokens" to individual tokens).Current state
Resolved Uncertainties & Technical Notes
productmap (key:model).1K tokens) seen in the sample data by adding aparseTokenMultipliernormalizer.productcolumn. Since Spark SQL passes ascala.collection.Mapat runtime but local tests might use ajava.util.Map, the code handles both usingJavaConvertersand@SuppressWarnings("unchecked")to preventClassCastException.