Carbon-Aware Machine Learning Training Controller
Project description
๐ Carbon-Aware ML Training Controller โ CAML-TC
โก 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 applicationpages/forecast.pyโ 24h carbon intensity explorerpages/simulation.pyโ strategy comparison labpages/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_endauto-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caml_tc-0.1.1.tar.gz.
File metadata
- Download URL: caml_tc-0.1.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f9218c7215ea97abf584aef38fccbc9d6cc94f888017395027216fcb28786c6
|
|
| MD5 |
c48e0247f3022a84bc66b4c9f7c07d29
|
|
| BLAKE2b-256 |
fdbf888e5950e13fe522b4025bcab490429dcf0528431df2f55f3eeca99312e5
|
File details
Details for the file caml_tc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: caml_tc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9205d828b354fade299fb4ed14b5976024bb98c3273297b9b0b2c8ad9fbf1b55
|
|
| MD5 |
a782755f9cc420954c0d7f832ab8f8e1
|
|
| BLAKE2b-256 |
aec66e5bfa1577bc3d4ebe144e405d4db2266ce226801633dfa7f213b945114e
|