Back to prompt library
Build a Generative Workload Token and Power Cost Attribution Engine — implementation
Linked challenge: Build a Generative Workload Token and Power Cost Attribution Engine
Prompt source
implementation69 lines11 sectionsNo variables1 code block
## Build
Correlate per-request token usage with real-time accelerator power consumption. Attribute energy and hardware depreciation costs across internal teams and model architectures.
## User
FinOps and Sustainability Lead
## Workflow
1. Ingest serving request logs alongside DCGM and Neuron power telemetry records.
2. Calculate Joules-per-token and watt-hour attribution across concurrent tenants.
3. Prompt hosted Claude to summarize cost attribution anomalies and carbon footprints.
4. Compile an auditable monthly billing and sustainability report for department heads.
## Interface
Multi-tenant dashboard displaying energy consumption charts, Joules/token heatmaps, and cost allocation breakdowns.
## Data
Create synthetic time-aligned logs combining open-weight model request traces (token counts) and sampled power draw (Watts) metrics.
Starter examples below are synthetic. They are not downloaded records.
## Source
[NVIDIA DCGM exporter](https://raw.githubusercontent.com/NVIDIA/dcgm-exporter/main/README.md)
Extracts DCGM GPU power draw metrics (DCGM_FI_DEV_POWER_USAGE) to calculate precise watt-hour consumption per inference window.
## Tools
pydantic-ai, anthropic-claude, mlflow.
Guarantees mathematical schema consistency across energy measurements, token tallies, and currency conversions.
Hosted Claude API for natural language variance reporting and sustainability insight drafting.
## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.
## Acceptance
- Calculates energy-per-token metrics across at least two concurrent tenant workloads.
- Reconciles aggregate power draw against individual request attributions within 3% tolerance.
- Produces verified FinOps cost summaries exportable as JSON.
## Starter Examples
```json
[
{
"input": {
"tenant_id": "search-team",
"window_hours": 1,
"tokens_processed": 5000000,
"avg_power_watts": 420,
"kwh_rate_usd": 0.12,
"node_depreciation_hourly_usd": 1.5
},
"expected_output": {
"energy_consumed_kwh": 0.42,
"energy_cost_usd": 0.05,
"total_attributed_cost_usd": 1.55,
"joules_per_token": 0.302,
"efficiency_rating": "optimal"
}
},
{
"input": {
"tenant_id": "idle-team",
"window_hours": 1,
"tokens_processed": 0,
"avg_power_watts": 110,
"kwh_rate_usd": 0.12,
"node_depreciation_hourly_usd": 1.5
},
"expected_output": {
"energy_consumed_kwh": 0.11,
"energy_cost_usd": 0.013,
"total_attributed_cost_usd": 1.513,
"joules_per_token": 0,
"efficiency_rating": "idle_waste"
}
}
]
```
## Safety
Calculates accounting figures only; does not manipulate power caps or server governor settings.
Use mock external writes. Require human review before any real deployment.