Skip to main content

Carbon-Aware Machine Learning Training Controller

Project description

๐ŸŒ Carbon-Aware ML Training Controller โ€” CAML-TC

PyPI version PyPI version License: MIT Python Streamlit IEEE EEEIC 2026 Green AI Status


โšก Executive Summary

A reinforcement learningโ€“driven carbon-aware scheduling system that dynamically optimises machine learning workloads using real-time and forecasted UK electricity grid carbon intensity.

๐Ÿ“„ Peer-reviewed research โ€” Accepted at IEEE EEEIC 2026 (Q1, Scopus-indexed, Web of Science)
๐Ÿ”— Try the live app โ€” uses live UK National Grid data, no login required
๐Ÿ“ฆ pip install caml-tc โ€” use as a Python library in your own ML pipeline

The system integrates:

  • ๐Ÿ”ฎ Carbon forecasting with uncertainty-aware confidence weighting
  • ๐Ÿง  Heuristic optimisation with multi-window holistic scoring
  • ๐Ÿค– Risk-aware reinforcement learning โ€” Q-learning MDP trained on 8,000 episodes of real UK grid data

to shift compute workloads into low-emission periods, achieving 28โ€“34% COโ‚‚ reduction under realistic conditions and >50% under optimal conditions โ€” without changing a single line of model code.


๐Ÿ’ก Problem Statement

The UK electricity grid fluctuates between 50 and 260 gCOโ‚‚/kWh within a single day. The same ML training job at 3am versus 7pm evening peak can produce 3โ€“5ร— different carbon emissions.

Modern machine learning workloads are executed without any environmental awareness. This results in:

  • โŒ Unnecessary COโ‚‚ emissions from poorly timed execution
  • โŒ No integration between carbon intelligence and scheduling decisions
  • โŒ Lack of sustainability in ML pipelines despite available grid data
  • โŒ Existing solutions (Google, Meta, Microsoft) are proprietary and inaccessible

Google has done this internally since 2020. Microsoft released a partial SDK. Nobody built an open, deployable version for individual researchers and engineers. Until now.


๐Ÿ“Š Validated Results

Tested on real UK National Grid data. Emissions measured with CodeCarbon.

Strategy Carbon Reduction Conditions
Baseline (immediate execution) 0% โ€”
Heuristic Scheduler ~28% Realistic UK grid
RL Scheduler (CAML-TC) 28โ€“34% Realistic UK grid
RL Scheduler (CAML-TC) >50% Optimal low-variability

RL outperforms heuristics under high grid variability โ€” the conditions where static rules fail and adaptive learning matters most.


๐Ÿš€ Install & Quickstart

pip install caml-tc
from camltc import CarbonScheduler

scheduler = CarbonScheduler(duration_minutes=90, urgency="low")
result = scheduler.recommend()

print(result.best_window)        # "03:00 โ€” 04:30 UTC"
print(result.carbon_saving_pct)  # 31.4
print(result.strategy)           # "rl" or "heuristic"
print(result)                    # full formatted summary

Urgency levels

# Low โ€” aggressive carbon optimisation, longer delay allowed
CarbonScheduler(duration_minutes=120, urgency="low").recommend()

# Medium โ€” balanced (default)
CarbonScheduler(duration_minutes=60, urgency="medium").recommend()

# High โ€” run as soon as a clean-enough window appears
CarbonScheduler(duration_minutes=30, urgency="high").recommend()

๐Ÿง  Key Innovations

  • ๐ŸŒฑ Carbon intensity used as a first-class scheduling signal โ€” not an afterthought
  • ๐Ÿค– Hybrid scheduling architecture โ€” heuristic for stable grids, RL for volatile ones
  • โš–๏ธ Multi-objective RL reward design โ€” jointly optimises carbon intensity, forecast uncertainty, delay penalty, and deadline constraints
  • ๐Ÿ“‰ Exponential forecast confidence decay โ€” wโ‚œ = exp(โˆ’ฮปยทฮ”t) โ€” prevents over-commitment to unreliable long-horizon predictions
  • ๐ŸŽฒ Stochastic noise injection โ€” forces RL agent to learn policies robust to real grid variability, not just noise-free signals
  • ๐Ÿ“ก End-to-end closed-loop pipeline โ€” from raw National Grid API to scheduling decision in one system
  • ๐Ÿงช CodeCarbon-integrated emissions measurement โ€” validated, reproducible results

โš™๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   UK National Grid Carbon API        โ”‚
โ”‚   Real-time + 24h Forecast           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Carbon Intelligence Layer          โ”‚
โ”‚   Confidence decay ยท Volatility      โ”‚
โ”‚   Peak/low detection ยท Uncertainty   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Scheduling Engine                  โ”‚
โ”‚   โ”œโ”€ Heuristic Optimizer             โ”‚
โ”‚   โ”‚    Window scoring ยท Delay penaltyโ”‚
โ”‚   โ””โ”€ RL Policy Agent (Q-Learning MDP)โ”‚
โ”‚        State: (ฮผ, ฯƒ, delay)          โ”‚
โ”‚        Reward: carbon+uncertainty    โ”‚
โ”‚               +delay+deadline        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   ML Workload Simulator              โ”‚
โ”‚   Synthetic training load            โ”‚
โ”‚   CodeCarbon emissions tracking      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Analytics Dashboard (Streamlit)    โ”‚
โ”‚   Forecast Explorer ยท Simulation Lab โ”‚
โ”‚   Strategy Comparison ยท KPI View     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Key Features

  • ๐Ÿ“ก Real-time UK carbon intensity integration via National Grid API
  • ๐Ÿ”ฎ 24-hour carbon forecasting with uncertainty modelling
  • ๐Ÿง  Heuristic + RL scheduling engine โ€” automatically selects best strategy
  • ๐Ÿค– Risk-aware RL agent trained on 8,000 episodes of real UK grid data
  • ๐Ÿงช ML workload simulation with CodeCarbon emissions tracking
  • ๐Ÿ“Š Interactive multi-page Streamlit dashboard
  • ๐Ÿ“ˆ Carbon peak/low detection and optimal window identification
  • โš™๏ธ Multi-strategy emissions comparison (baseline vs heuristic vs RL)
  • ๐Ÿ“ฆ pip-installable Python library for direct pipeline integration

๐Ÿงช System Modules

๐Ÿ“ˆ core/carbon_api.py โ€” Carbon Intelligence Layer

  • Real-time and forecast carbon intensity from UK National Grid
  • Exponential confidence weighting on future predictions
  • Peak/low detection and optimal window identification

โš™๏ธ core/scheduler.py โ€” Heuristic Scheduling Engine

  • Holistic window scoring (carbon intensity + uncertainty + delay penalty)
  • Urgency-parameterised delay penalty coefficient
  • Strong interpretable baseline that RL must genuinely beat

๐Ÿค– core/rl_agent.py โ€” Reinforcement Learning Agent

  • Q-learning with ฮต-greedy exploration and linear epsilon decay
  • State: (ฮผโ‚œ, ฯƒโ‚œ, dโ‚œ) โ€” mean CI, uncertainty proxy, accumulated delay
  • Multi-objective reward: carbon + uncertainty + delay + deadline violation
  • 8,000 training episodes ยท 4-phase iterative development

๐Ÿงช core/simulator.py โ€” Emissions Measurement

  • Synthetic ML workload generation
  • CodeCarbon-based emissions tracking per strategy
  • Reproducible experimental pipeline

๐Ÿ“Š demo/ โ€” Interactive Dashboard

  • app.py โ€” multi-page Streamlit application
  • pages/forecast.py โ€” 24h carbon intensity explorer
  • pages/simulation.py โ€” strategy comparison lab
  • pages/overview.py โ€” KPI and results summary

๐Ÿงฐ Tech Stack

  • Python 3.9+
  • Streamlit โ€” interactive dashboard
  • Plotly โ€” visualisations
  • Pandas / NumPy โ€” data processing
  • CodeCarbon โ€” emissions measurement
  • Custom RL Agent โ€” Q-learning MDP
  • UK Carbon Intensity API โ€” api.carbonintensity.org.uk

๐ŸŒ Environmental Impact

COโ‚‚ Saved Real-World Equivalent
1 kg ๐ŸŒณ ~0.045 trees planted
10 kg ๐Ÿš— ~40 km of driving avoided
100 kg โœˆ๏ธ One short-haul flight offset

Example: A team running 10 GPU training jobs per week, each saving 28โ€“34% emissions, saves hundreds of kg of COโ‚‚ annually โ€” with zero infrastructure changes.


๐Ÿ‡ฌ๐Ÿ‡ง UK Net Zero Relevance

This system is directly aligned with the UK's Net Zero 2050 commitment. It uses the National Grid's own free public carbon intensity API โ€” infrastructure the UK government has already built.

Data centres and AI infrastructure are among the fastest-growing electricity consumers in the UK. CAML-TC provides the scheduling intelligence layer that was missing โ€” making carbon-aware ML accessible to any researcher or engineer, not just those inside Google or Microsoft.


๐Ÿš€ Roadmap

  • PyTorch training callback (on_epoch_end auto-scheduling)
  • HuggingFace Trainer integration
  • AWS / Azure / GCP cloud scheduler hooks
  • Transformer-based CI forecasting (replacing LSTM baseline)
  • Continuous-action RL โ€” DQN, PPO
  • Multi-region geographic shifting (EU / US grids)
  • Carbon-aware CI/CD for ML training pipelines
  • Kubernetes-based orchestration

๐Ÿ“„ Research & Citation

Published at IEEE EEEIC 2026 โ€” International Conference on Environment and Electrical Engineering (Q1, Scopus-indexed, Web of Science)

If you use CAML-TC in your work, please cite:

@inproceedings{rehman2026camltc,
  title     = {Adaptive Carbon-Aware Machine Learning Training under Uncertainty:
               A Unified Scheduling Framework},
  author    = {Rehman, Sufiyan Ul},
  booktitle = {2026 IEEE International Conference on Environment and
               Electrical Engineering (EEEIC)},
  year      = {2026},
  publisher = {IEEE}
}

๐Ÿ‘จโ€๐Ÿ’ป Author

Sufiyan Ul Rehman
AI/ML Researcher ยท Lecturer, Ulster University & Solent University (via QA Higher Education), London
Building intelligent, carbon-aware AI systems for sustainable machine learning infrastructure.

๐Ÿ”— Live App ยท ๐Ÿ“ฆ PyPI ยท ๐Ÿ”ฌ IEEE Paper


๐Ÿ“Œ Closing Statement

The future of machine learning is not only about accuracy and performance,
but also about when and how sustainably computation is executed.

The carbon cost of AI is real. The fix is simpler than anyone realises.
It is just a matter of timing.


๐Ÿ“œ License

MIT ยฉ 2026 Sufiyan Ul Rehman โ€” see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caml_tc-0.1.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caml_tc-0.1.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file caml_tc-0.1.2.tar.gz.

File metadata

  • Download URL: caml_tc-0.1.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for caml_tc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b54175046bcb5afa111e230a0b56e73c188033201facacb31fc227b105c84268
MD5 74e60c599c3dc70d719ef4284b8b6a09
BLAKE2b-256 7cd895510bc7413d9ee384e843328adb1bd3b6645c520e74c316ab1ee36c4d43

See more details on using hashes here.

File details

Details for the file caml_tc-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: caml_tc-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for caml_tc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e610fc671b7f31311f9fc2c6ec1a82c7ea091da18a28232f5dac886adcf2f8b1
MD5 8a33228b6ec60a89fdc07bba828e5396
BLAKE2b-256 4adc5228cce0ec5aec345262b39036950c57282e21b1178683acd1b28cfd5c29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page