MLOpsProduction ML Sustainability & Carbon-Aware Operations

How do you measure and reduce the carbon footprint of production ML systems?

Question 159 of 164 · Updated

On this page

Sustainable MLOps means measuring the environmental impact of the complete machine-learning service and reducing it without breaking model quality, latency, reliability, privacy, or business requirements. It is not simply choosing a smaller GPU or moving a workload to a region described as green. Teams need a repeatable measurement boundary, a meaningful unit of useful work, reliable energy and carbon-intensity data, and operational controls that make reductions verifiable.

Curriculum boundary: Question 133 covers inference cost optimization and cost per useful prediction. This lesson addresses a different objective: energy use, operational and embodied greenhouse-gas emissions, carbon intensity by location and time, and lifecycle sustainability across training, deployment, inference, storage, networking, and supporting operations. A cheaper workload may still have a higher carbon footprint, and a lower-carbon schedule must not violate product deadlines or resilience requirements.

1. Understand the footprint of an ML system#

A production ML system consumes resources across more than the model's forward pass:

  • Data preparation: ingestion, validation, feature engineering, transformations, and repeated data scans.
  • Training: accelerator time, CPU and memory, distributed communication, checkpointing, evaluation, and failed or repeated runs.
  • Experimentation: hyperparameter sweeps, architecture searches, ablations, and discarded experiments.
  • Model delivery: artifact storage, image builds, CI tests, staging, shadow deployments, rollout overlap, and rollback capacity.
  • Inference: online requests, batch jobs, streaming consumers, embedding generation, reranking, and LLM token generation.
  • Platform overhead: orchestration, idle replicas, feature stores, databases, monitoring, logs, networking, backups, and disaster-recovery capacity.
  • Hardware lifecycle: emissions associated with manufacturing and transporting servers, accelerators, storage, and networking equipment.

A narrow measurement of GPU training time can miss a large part of the operational system. The Green Software Foundation's Software Carbon Intensity (SCI) approach explicitly requires a declared software boundary and includes material supporting infrastructure such as compute, storage, networking, monitoring, logging, training, testing, backup, and redundancy. The boundary should be documented rather than silently excluding inconvenient components.

2. Use a consistent carbon-intensity model#

A useful conceptual model is:

Operational\ emissions\ (O) = Energy\ (E) \times Carbon\ intensity\ (I)

The Software Carbon Intensity framework also accounts for allocated embodied emissions:

SCI = (E \times I + M) / R

Where:

  • E is energy consumed by the defined software boundary, usually measured in kWh.
  • I is the carbon intensity of the electricity used, such as gCO₂e/kWh, for the relevant location and time.
  • M is the allocated embodied emissions of the hardware needed to operate the software.
  • R is a functional unit that represents useful work, such as one successful prediction, 1,000 inference requests, one completed training run, or one business transaction.

The exact unit and boundary matter. A service that handles more requests can have higher total emissions but lower emissions per successful prediction. Report both total emissions and intensity so that efficiency improvements do not conceal growth in overall impact.

For a production ML platform, useful functional units include:

  • grams of CO₂e per 1,000 valid, on-time predictions;
  • kg CO₂e per completed training run that passes evaluation;
  • grams of CO₂e per 1,000 generated tokens at a defined quality level;
  • kg CO₂e per completed batch of records;
  • emissions per customer transaction or other meaningful business outcome.

Avoid using attempted requests as the denominator when failed, invalid, or late responses do not deliver the intended service.

3. Establish a defensible measurement boundary#

Write down which resources are included and how shared resources are allocated. A practical boundary may include:

  1. Training and evaluation compute.
  2. Hyperparameter and experiment workloads.
  3. Model-serving compute and memory.
  4. Feature retrieval, preprocessing, and data movement.
  5. Storage, networking, logging, monitoring, and orchestration.
  6. Idle and standby capacity required by the service's SLO and recovery design.
  7. CI/CD, model packaging, testing, staging, and deployment.
  8. Material hardware embodied emissions, where data is available.

For shared clusters, do not attribute the entire GPU or node footprint to every tenant. Use a documented allocation method based on measured device energy, accelerator time, CPU/memory usage, or another defensible resource share. State whether the result is measured, estimated, or allocated. If a provider does not expose energy data, disclose the proxy and its limitations rather than presenting an estimate as a meter reading.

Keep the same boundary, functional unit, time window, and calculation method when comparing a baseline with an optimized candidate. Otherwise, an apparent reduction may simply be a change in accounting.

4. Instrument training and inference#

For workloads running on hardware you control, tools such as CodeCarbon can track CPU, GPU, and RAM energy and estimate emissions using regional electricity carbon intensity. Its outputs can include energy consumed, emissions, hardware details, region, and utilization. Integrate the measurement with experiment identifiers and model versions.

A minimal training pattern is:

PYTHON
from codecarbon import EmissionsTracker tracker = EmissionsTracker( project_name="risk-model-training", output_dir="./emissions" ) tracker.start() try: train_and_evaluate() finally: emissions_kg = tracker.stop() print(f"Estimated emissions: {emissions_kg} kg CO2e")

Treat this as an instrumentation example, not a complete carbon-accounting system. Check the installed CodeCarbon version and measurement backend. Hardware energy counters are preferable where available; fallback estimates can have substantial error. A machine-level measurement on a shared host may include other workloads. CodeCarbon's documented scope does not automatically cover every data-center, network, storage, cooling, or hardware-lifecycle contribution.

For production inference, associate telemetry with a stable service and workload identity. Collect, where supported:

  • energy or power readings by node, accelerator, and time interval;
  • CPU/GPU model, count, utilization, memory, and device allocation;
  • region, cloud zone, and the carbon-intensity source and timestamp;
  • requests, successful outputs, tokens, records, or transactions delivered;
  • model version, serving configuration, batch size, and workload class;
  • idle time, queueing, retries, failures, and replica warmup;
  • storage, network, feature-store, and platform overhead estimates.

For third-party hosted model APIs, provider-side energy telemetry may not be exposed. Use a documented provider estimate or a transparent model-based estimate if appropriate, keep it separate from directly measured local compute, and avoid implying that a client-side timer measures the provider's actual electricity use.

5. Numerical example: emissions per useful prediction#

Suppose an inference service consumes 240 kWh during one month. For this illustrative calculation, assume the relevant electricity carbon intensity averages 400 gCO₂e/kWh.

Operational emissions are:

LaTeX

Assume an additional 24 kgCO₂e of embodied hardware emissions is allocated to the same service-month under a documented allocation policy. The monthly footprint is therefore 120 kgCO₂e.

If the service delivers 12 million valid, on-time predictions, then:

LaTeX

The reported intensity is 10 gCO₂e per 1,000 useful predictions. The example is illustrative: actual results depend on the measurement boundary, hardware, electricity mix, utilization, allocation method, and functional unit. Do not compare this number with another service unless those assumptions are sufficiently aligned.

6. Numerical example: carbon-aware scheduling#

Assume a non-urgent nightly training job requires 60 kWh and can run in either of two approved regions or time windows:

  • Window A has an illustrative grid intensity of 500 gCO₂e/kWh.
  • Window B has an illustrative grid intensity of 200 gCO₂e/kWh.

The operational emissions are:

  • Window A: .
  • Window B: .

For the same amount of work and energy, Window B reduces the calculated operational emissions by 60%. This does not mean every job should be delayed or moved. The alternative region must satisfy data-residency rules, availability, security, model/data locality, cost, and completion deadlines. Carbon intensity data must also be sufficiently current and relevant to the chosen accounting method.

7. Reduce energy before shifting workloads#

Efficiency improvements usually provide a durable foundation:

Model and algorithm

  • Choose the smallest model that meets the required quality and safety thresholds.
  • Benchmark simpler baselines before adopting a larger architecture.
  • Use quantization, pruning, distillation, or compilation only after validating accuracy, calibration, subgroup behavior, and hardware compatibility.
  • Stop unproductive experiments and use principled search budgets.
  • Avoid retraining when the expected benefit does not justify the cost and risk.

Training pipeline

  • Cache valid intermediate artifacts and avoid repeated preprocessing.
  • Use early stopping and resource-aware hyperparameter search.
  • Tune data loading, accelerator utilization, batch size, and distributed communication.
  • Checkpoint at a frequency that balances recovery cost with storage and write overhead.
  • Cancel abandoned or superseded runs and clean up orphaned compute.
  • Schedule non-urgent jobs to avoid long idle gaps and unnecessary accelerator reservations.

Inference service

  • Right-size CPU/GPU hardware against representative traffic.
  • Use dynamic batching only where its queueing delay meets the latency contract.
  • Reuse safe computations and avoid duplicate feature retrieval.
  • Use caching only when freshness, tenant isolation, privacy, and invalidation are correct.
  • Reduce oversized payloads, unnecessary serialization, and repeated model loading.
  • Scale down unused capacity while preserving warm capacity required by SLOs and disaster recovery.

Platform and data

  • Reduce redundant copies and retention of datasets and model artifacts.
  • Compress or partition data where it reduces total work rather than merely moving it elsewhere.
  • Bound excessive telemetry and log payloads while retaining audit and incident evidence.
  • Profile network transfer and distributed-training communication.
  • Remove unused environments, images, endpoints, and persistent volumes.

A reduction in energy is meaningful only if the same useful work is delivered at an acceptable quality and reliability level.

8. Apply carbon-aware scheduling and placement#

When workloads are flexible, incorporate location- and time-dependent carbon intensity into scheduling. Candidates include:

  • offline training and evaluation jobs;
  • non-urgent batch inference;
  • embedding refreshes and index rebuilds;
  • data transformations and backfills;
  • non-critical hyperparameter searches.

A scheduler can rank eligible execution windows by expected emissions, then apply hard constraints for deadline, region, data residency, hardware availability, cost, and recovery requirements. For a latency-sensitive online endpoint, do not move requests to a distant region solely because its electricity is cleaner; network latency, data movement, availability, and user experience may make that decision worse overall.

Use a carbon-intensity feed with a timestamp, region, provenance, and fallback policy. Distinguish average grid intensity from marginal or forecast intensity when the methodology requires it. If the signal is missing or stale, use the documented fallback and record that the schedule was not carbon-optimized.

9. Include sustainability in model and infrastructure decisions#

A production comparison should evaluate more than one metric:

DimensionExample measure
EnvironmentalkWh, kgCO₂e, SCI per functional unit
Model qualityAccuracy, task loss, calibration, safety metrics
Servicep95/p99 latency, throughput, availability, freshness
ResourceGPU-hours, CPU-hours, memory, storage, network
EconomicsFully allocated cost per useful prediction
GovernanceBoundary, assumptions, data source, approvals

Do not assume that lower cost always means lower emissions. A cheaper region may have a more carbon-intensive grid; a faster accelerator may use more power but finish the job sooner; a smaller model may require more retries or produce lower-quality outputs. Compare end-to-end results using the same workload and acceptance criteria.

10. Make carbon a CI/CD and training-pipeline signal#

Treat the carbon report as a versioned evaluation artifact, not a one-off notebook screenshot. A release or training pipeline can:

  1. Define a representative workload and functional unit.
  2. Record the model, code, dataset, runtime, hardware, and region versions.
  3. Measure a baseline and candidate under comparable conditions.
  4. Calculate energy, operational emissions, and the applicable embodied allocation.
  5. Report uncertainty and measurement coverage.
  6. Validate quality, latency, reliability, privacy, and fairness guardrails.
  7. Compare emissions per useful unit and total emissions.
  8. Require review when the footprint materially increases or evidence is incomplete.
  9. Store the report with the model artifact and approval record.

An illustrative policy might be:

YAML
sustainability_evaluation: workload: inference_profile_v5 functional_unit: 1000_valid_on_time_predictions compare_with: production_model_v12 require_same: - request_mix - region_or_documented_grid_factor - measurement_boundary - evaluation_window report: - energy_kwh - operational_co2e - embodied_co2e_allocation - co2e_per_functional_unit - measurement_coverage - uncertainty_notes release_gates: model_quality_pass: true latency_slo_pass: true reliability_slo_pass: true privacy_and_fairness_checks_pass: true unexplained_emissions_regression: false on_missing_measurement: review

The thresholds and policies must be chosen for the organization and workload. Do not reject a safety-critical fix simply because its short-term footprint rises; document the reason, evaluate alternatives, and consider the longer-term impact.

11. Monitor the footprint after deployment#

A model's carbon intensity can change when traffic, hardware, grid mix, model version, token length, or utilization changes. Monitor:

  • total energy and emissions by service, model, environment, and region;
  • emissions per successful prediction, transaction, batch, or token;
  • GPU/CPU utilization, idle capacity, memory, and energy per workload;
  • carbon-intensity values, source, region, timestamp, and missing-data rate;
  • training runs, experiment counts, retries, and failed-job energy;
  • data movement, storage growth, and platform overhead;
  • quality, latency, availability, and freshness alongside environmental metrics;
  • measurement coverage and changes in allocation assumptions.

Set alerts for sustained regressions, not noisy individual samples. A carbon alert should trigger investigation and controlled remediation, not blindly stop a production service. Recalculate baselines after material architecture or accounting changes and preserve the prior methodology for historical comparison.

12. Production failure scenarios#

Scenario A: the carbon dashboard reports a sudden improvement after a GPU migration.

  • Check whether the new GPU energy counter is supported and whether the measurement now omits accelerator power.
  • Compare device inventory, utilization, job duration, and measurement backend.
  • Mark the result as incomparable until the instrumentation gap is resolved.

Scenario B: a carbon-aware scheduler sends training to a low-carbon region but the job misses its deadline.

  • Inspect data-transfer time, region capacity, queue delay, and the freshness of the carbon signal.
  • Add deadline and residency constraints to eligible placement choices.
  • Keep a safe fallback region and report when a job uses it.

Scenario C: quantization reduces energy but increases harmful prediction errors.

  • Compare quality, calibration, decision changes, and affected subgroups on the same evaluation cohort.
  • Reject the optimization if critical model-quality or fairness gates fail.
  • Record the environmental gain as an experimental result, not an approved production improvement.

Scenario D: a shared GPU's full energy is attributed to one tenant.

  • Inspect the allocation boundary and concurrent workload schedule.
  • Replace whole-device attribution with a documented resource-share method where defensible.
  • Label the result estimated if exact tenant-level energy cannot be measured.

Scenario E: training emissions fall but total platform emissions rise.

  • Check inference traffic, idle replicas, logging, feature-store reads, storage, and rollout overlap.
  • Compare total emissions and per-functional-unit intensity separately.
  • Avoid declaring success from a training-only metric.

Scenario F: the tracker uses a stale or generic grid factor.

  • Inspect the carbon-intensity source, region, timestamp, and fallback behavior.
  • Record the uncertainty and recompute where better data is available.
  • Do not present the estimate with false precision.

13. Common mistakes#

  1. Measuring only GPU training and ignoring inference and supporting services.
  2. Reporting total emissions without a functional unit or useful-work denominator.
  3. Comparing different boundaries, grid factors, or workload mixes as if they were equivalent.
  4. Treating estimated energy as direct meter data.
  5. Assuming a local process tracker isolates GPU energy on a shared accelerator.
  6. Ignoring hyperparameter sweeps, retries, idle capacity, and failed experiments.
  7. Excluding CI/CD, monitoring, storage, networking, backup, or redundancy without documenting why.
  8. Treating a cleaner region as automatically eligible despite residency and latency constraints.
  9. Optimizing energy while degrading model quality, fairness, or reliability.
  10. Using offsets as a substitute for reducing avoidable energy and hardware demand.
  11. Claiming precision that the measurement method cannot support.
  12. Treating one low-carbon training run as proof that the deployed system is sustainable.

14. Practical operator checklist#

  • [ ] Define the software boundary and document included and excluded components.
  • [ ] Select a useful functional unit for each workload type.
  • [ ] Record energy, carbon intensity, region, time, and measurement method.
  • [ ] Separate direct measurements, estimates, and allocated embodied emissions.
  • [ ] Instrument training, experiments, inference, and material platform overhead.
  • [ ] Compare baseline and candidate using identical workload and accounting assumptions.
  • [ ] Optimize model size, compute efficiency, utilization, and redundant work.
  • [ ] Apply carbon-aware scheduling only within deadline, residency, and reliability constraints.
  • [ ] Gate optimizations on quality, fairness, latency, security, and availability.
  • [ ] Store the report with model and pipeline provenance.
  • [ ] Monitor total footprint and emissions per useful unit after deployment.
  • [ ] Revisit assumptions when hardware, traffic, regions, or measurement tools change.

15. Trade-offs and design choices#

  • Energy efficiency vs. latency: Larger batches and slower hardware can improve energy per item but may violate interactive deadlines.
  • Carbon-aware location vs. data locality: A lower-carbon region can increase network transfer, latency, or regulatory risk.
  • Accelerator utilization vs. resilience: Removing idle capacity lowers energy but can increase cold starts and failure recovery time.
  • Smaller model vs. task quality: Compression and distillation can reduce compute but may degrade calibration, subgroup performance, or safety.
  • Measurement detail vs. operational overhead: Fine-grained telemetry improves attribution but consumes resources and may itself create storage and processing cost.
  • Total footprint vs. footprint intensity: Per-request efficiency can improve while total emissions rise with demand; report both.
  • Operational vs. embodied emissions: Extending hardware life can reduce manufacturing impact but older equipment may consume more electricity. Evaluate the full lifecycle and actual workload.

16. Key takeaway#

Sustainable MLOps turns environmental impact into an operational engineering measure. Define the system boundary, measure energy and carbon intensity transparently, normalize by useful work, reduce waste across the ML lifecycle, and use carbon-aware placement only when operational constraints permit. Every claimed reduction should be reproducible and should preserve model quality, fairness, reliability, and user outcomes.

References and further reading#

  • ISO/IEC 21031:2024, *Software Carbon Intensity (SCI) specification*: https://www.iso.org/standard/86612.html
  • Green Software Foundation, *Software Carbon Intensity specification*: https://sci.greensoftware.foundation/
  • Lannelongue, Grealey, and Inouye, *Green Algorithms: Quantifying the Carbon Footprint of Computation*, Advanced Science (2021): https://doi.org/10.1002/advs.202100707
  • Google Cloud, *Optimize AI and ML workloads for energy efficiency*, Well-Architected Framework: https://docs.cloud.google.com/architecture/framework/sustainability/ai-ml-energy-efficiency
  • CodeCarbon, *Methodology*: https://docs.codecarbon.io/3.3/explanation/methodology/
  • CodeCarbon, *Output formats and energy/emissions reporting*: https://docs.codecarbon.io/latest/reference/output/
  • CodeCarbon, *FAQ: measurement accuracy and limitations*: https://docs.codecarbon.io/latest/explanation/faq/
  • Luccioni et al., *Estimating the Carbon Footprint of BLOOM, a 176B Parameter Language Model*, Journal of Machine Learning Research (2023): https://jmlr.org/papers/v24/23-0069.html

Related questions

Explore other topics:Machine LearningRetrieval-Augmented GenerationAI Agents