Skip to content

About

Carbon-aware cloud scheduler run live on 13 AWS regions, with 25k verified forecasts and a guard that disables models that don't deliver

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Carbon-Aware Cloud Scheduler Typing SVG

Python FastAPI React Vite Data


What it does · Live pilot · Quick start · API · Architecture · Research

New here? Read the guide for humans. Working on this repo with an AI assistant? Point it at the guide for AI.


What this actually does

Cloud workloads can run in more than one region. Electricity grids are dirtier at some hours than others, and dirtier in some places than others. This project scores every candidate region every hour, using real historical carbon-intensity data, and picks the cleanest one that still meets a latency budget — then shows its work.

Three things live on top of the same scoring engine, each answering a different question:

Placement Audit

/ — the product

Triage a fleet workload by workload: move, shift in time, stay, blocked by cost, never move, or fix compliance first — each with the rule that decided it, tonnes of CO₂, and what the change costs.

Forecasting

/forecasting — models on trial

ARIMA and CarbonLSTM forecasts at 1/3/6/12 h, each model's cleanest hour, and the no-regret guard's verdict on whether that delay was allowed — plus every model's verified track record.

Pilot telemetry

/pilot — what actually ran

Decisions, chosen offsets and AWS dispatch outcomes from three independent scheduling pipelines that ran on live EC2 from 9 to 28 September 2026.

Also: /console (score one workload across the fleet), /playground (tune weights, add and remove servers, watch it switch or refuse), /report (printable audit), /about (what the project does and does not claim).


▸ Click to expand: what "manual vs. auto" actually looks like
sequenceDiagram
    participant Clock as Real historical clock
    participant Engine as Scoring engine (/score)
    participant Client as Client console

    loop every hour tick
        Clock->>Engine: real carbon intensity at this hour
        Engine->>Engine: filter by latency SLA, then score
        alt switching mode = auto
            Engine->>Client: top pick applied immediately
            Note over Client: active server updates itself
        else switching mode = manual
            Engine->>Client: top pick surfaced as a recommendation
            Client-->>Client: waits for "Apply switch" click
        end
    end
Loading

Same clock, same scoring, same data either way — the only variable is whether a human has to press a button before it takes effect.


The live pilot

From 9 to 28 September 2026, three scheduling policies ran side by side in one AWS account, from a small orchestrator instance in us-east-1, dispatching real jobs to a 12-instance EC2 fleet through AWS Systems Manager. The pilot is finished and the fleet has been terminated; what remains is the record.

Pipeline Policy
aws-adaptive Reactive — scores current intensity, never delays
aws-lstm CarbonLSTM forecasts 12 h ahead, delays only when the guard allows
aws-arima ARIMA(2,1,2) forecasts, same guard

The final record is 390 reactive, 390 CarbonLSTM and 391 ARIMA cycles, and 38,185 verified forecasts. Every forecast was recorded and then scored against the intensity actually measured when its target hour arrived:

Model Horizon Verified Direction correct Regret
ARIMA(2,1,2) 1 h 4,801 64.8% 19.1%
ARIMA(2,1,2) 3 h 4,794 61.3% 26.2%
ARIMA(2,1,2) 6 h 4,786 59.9% 27.8%
ARIMA(2,1,2) 12 h 4,708 57.5% 28.9%
CarbonLSTM 1 h 4,798 63.1% 17.8%
CarbonLSTM 3 h 4,792 68.7% 18.8%
CarbonLSTM 6 h 4,782 74.9% 17.6%
CarbonLSTM 12 h 4,724 78.1% 19.4%

Pooled over the whole pilot, from scripts/summarize_forecast_results.py. The first days include a defect that fitted the live forecasters on year-old history, which hurts ARIMA most.

That record decides whether a model is allowed to delay work at all:

  • error is not enough. ARIMA had the lower 1-hour error and still delivered net-negative savings on the delays it recommended, so the guard disabled it.
  • on 20 September the same rule flagged CarbonLSTM's 1-hour forecasts (−0.5% delivered, 49.5% regret on the post-fix record at that date) and set that horizon to never delay. In this pilot that changed no live decision — the runner's 1-hour stage can't propose a delay, and dispatch uses the 6-hour stage.
  • at teardown the guard had ARIMA disabled at every horizon and CarbonLSTM disabled at 1 hour, with a 15% promised-saving threshold at 3, 6 and 12 hours.
  • thresholds live in data/forecast_calibration.json. scripts/reverify_and_calibrate.py recommends; a human edits the applied block. Nothing re-enables a forecaster automatically.

Scheduling itself was a cron.d entry on the orchestrator, and a daily teardown check terminates the whole fleet on a fixed date, so a pilot cannot outlive its budget.

Known limits of this pilot: one cloud provider, 19 days in one season, cycles were irregular in the first week, and the Tokyo instance sat stopped from 13 September, so dispatches to it failed.

Does retraining on newer data help?

The pilot's CarbonLSTM weights were trained on 2021–2025 and never updated. After the pilot they were retrained with history through 31 July 2026 and compared on a held-out window, 1 August to 27 September 2026, across 13 zones. A control set, retrained on the same 2021–2025 data with a different seed, shows how much the numbers move from retraining alone.

Model Mean error vs pilot weights Direction correct (6 h) Regret Saving per decision
Pilot weights (2021–2025) 100 74.9% 21.8% 4.37%
Control (same data, reseeded) 102.3 75.8% 20.8% 4.40%
Retrained (to 31 July 2026) 99.4 76.5% 19.3% 4.61%
Persistence 104.4 n/a never delays 0

The retrained model is slightly better on every decision metric, but the gain is about the size of the retraining noise the control exposes, and each set was trained once. It is reported as a small, unconfirmed improvement. Per-zone numbers are in data/public/lstm_retrain_backtest.json; the scripts are download_history_range.py, retrain_lstm_sets.py and backtest_lstm_retrain.py.


Architecture

flowchart LR
    subgraph Data["Real data (2021–2025)"]
        CSV[Electricity Maps<br/>hourly CI history]
    end

    subgraph Backend["FastAPI · carbon_scheduler/"]
        HIST[history_api.py<br/>real hour-by-hour lookup]
        SCORE["/score<br/>filter + weighted rank"]
        RESEARCH[research_api.py<br/>26 reproducible results]
        ZONES["/regions/zones<br/>real electricity zones"]
    end

    subgraph Frontend["React + Vite · carbon_scheduler_ui/"]
        HOME["/ Model showcase"]
        PLAY["/playground Sandbox"]
        CONSOLE["/console Client fleet"]
    end

    CSV --> HIST
    HIST --> SCORE
    ZONES --> CONSOLE
    SCORE --> HOME
    SCORE --> PLAY
    SCORE --> CONSOLE
    RESEARCH --> HOME
Loading

One scoring endpoint, POST /score, backs all three pages — the showcase, the sandbox, and the console just supply different region lists.


Quick start

1 · Backend (FastAPI, port 8001)
cd carbon_scheduler
pip install fastapi uvicorn pydantic python-dotenv requests statsmodels torch
cp ../.env.example ../.env             # then fill in ELECTRICITY_MAPS_TOKEN
python -m uvicorn api:app --host 127.0.0.1 --port 8001 --reload
2 · Frontend (React + Vite, port 5173)
cd carbon_scheduler_ui
npm install
npm run dev

Open http://localhost:5173 — the frontend proxies /api/* straight to the backend on :8001, so both need to be running.

3 · Optional: historical replay and forecasting

The licensed history and the trained weights are not in this repo. With your own Electricity Maps token:

cd carbon_scheduler
python scripts/import_yearly_csv.py       # multi-year CSV exports -> data/history/
python scripts/train_lstm.py              # writes models/lstm_{zone}.pt
python scripts/export_public_evidence.py  # derived-only evidence -> data/public/

scripts/download_ci_history.py is the API alternative, but it fetches only the trailing 10 days and replaces each data/history/ci_history_{zone}.json. Do not run it over a multi-year import. To add a date range without touching data/history/, use scripts/download_history_range.py.

Get an Electricity Maps token at electricitymaps.com; academic access is free on an institutional address. The scoring engine and the replay run on real measured values — nothing here is randomly generated.


API reference

Method Endpoint What it returns
GET /regions/ Current region pool with live/simulated carbon + latency
GET /regions/zones Real electricity zones only (name/lat/lng) — powers the console's zone picker
GET /regions/history/range Bounds of the licensed 2021–2025 dataset — returns 403 unless CADSS_SERVE_LICENSED_HISTORY=1
GET /regions/history/at?timestamp= Per-region intensity at one historical hour — same 403 gate
POST /score Filters by latency SLA, scores by weighted carbon/latency/resources, returns a ranked, explainable decision
POST /forecast LSTM (per-zone, falls back to ARIMA) carbon forecast + best delay window
POST /carbon/estimate Operational + embodied (Scope 3) lifecycle CO₂ estimate
POST /scaling/elastic CarbonScaler-style elastic vCore recommendation
POST /schedule/joint Joint spatial + temporal shift for delay-tolerant workloads
GET /pilot/telemetry Live pilot decisions and dispatch outcomes (instance identifiers stripped)
GET /forecasting/multi-stage ARIMA + CarbonLSTM forecasts at 1/3/6/12 h with the guard's decision per stage
GET /forecasting/verification Verified accuracy, direction and regret per model and horizon
GET /research/manifest Index of every reproducible research result exposed on the site
▸ Example: score a client's own fleet (what /console sends)
curl -X POST http://localhost:8001/score \
  -H "Content-Type: application/json" \
  -d '{
    "regions": [
      {"name": "prod-api-1", "carbon": 427.7, "latency": 42, "resources": 80, "lat": 38.13, "lng": -78.45},
      {"name": "prod-api-2", "carbon": 575.6, "latency": 65, "resources": 80, "lat": 19.07, "lng": 72.87}
    ],
    "weights": {"carbon": 0.4, "latency": 0.3, "resources": 0.3},
    "max_latency": 200
  }'

The response includes the ranked list, rejected regions with reasons, the final pick, and a plain-language explanation — the same shape whether the caller is the showcase, the sandbox, or the console.


The data

No synthetic numbers back the headline claims on this site.

  • Carbon intensity — real hourly history (2021–2025) per electricity zone, sourced from Electricity Maps under academic access. Not redistributed here (see licensing).
  • Latency — measured from real vantage points against real cloud endpoints (carbon_scheduler/aws/measure_cloud_latency.py).
  • Forecasting — a trained per-zone LSTM (services/lstm_forecaster.py, 24-hour input, 6-hour output) with an ARIMA(2,1,2) fallback, evaluated against held-out real data.
  • Live verification — every forecast the pilot made, scored against the intensity measured at its target hour.
  • Every research result traces back to a script in carbon_scheduler/scripts/ that anyone can re-run.

Repo layout

carbon_scheduler/            FastAPI backend
├── api.py                     scoring, forecasting, multi-stage + verification endpoints
├── history_api.py             licensed history lookup (gated off by default)
├── research_api.py            reproducible research result manifest
├── models/                    Region, Workload dataclasses (trained .pt weights are gitignored)
├── services/                  scheduler, forecasters, failsafe engine + no-regret guard,
│                              forecast tracker, calibration instrument
├── aws/                       orchestrator deploy, the three pilot runners, SSM dispatch,
│                              latency measurement, teardown
├── scripts/                   every result in the report, as a re-runnable script
└── data/                      result JSON; public/ holds the derived evidence that is safe
                               to publish (licensed history and raw logs stay local)

carbon_scheduler_ui/          React + Vite frontend
├── src/pages/                 Audit, AuditReport, Console, Forecasting, Pilot, Playground, About
├── src/sim/                   in-browser port of the scheduler + audit model, with parity
│                              tests against the Python engine
├── src/hooks/                 useLiveScheduler, useClientFleet, useHistoricalReplay…
└── src/components/            demo/, layout/, research/ building blocks

Research methodology

▸ Click to expand: how "carbon saved" is actually measured

A carbon-aware scheduler can save carbon two different ways:

  1. Structural — knowing in advance which regions have permanently cleaner electricity (a one-time decision).
  2. Adaptive — reacting every hour to which region is cleanest right now (an always-on decision).

A third question sits on top: whether a forecast should be acted on at all. scripts/reverify_and_calibrate.py answers it from verified outcomes rather than from error metrics.

carbon_scheduler/scripts/held_out_generalization_test.py separates the first two with a genuine held-out split (the static baseline never sees the years it's judged on), then significance_test_adaptivity.py tests whether the adaptive gain is statistically real. Both are re-run live to produce every number shown under Decomposition on the homepage — nothing is pasted in.


Data source and licensing

Carbon-intensity data comes from Electricity Maps (https://www.electricitymaps.com), used under academic access granted for this undergraduate research project.

Their Terms of Service permit academic use but not redistribution of the data itself. This repository therefore contains no measured carbon-intensity values:

  • the licensed 2021–2025 hourly history (carbon_scheduler/data/history/, data/raw_yearly/) is not published — regenerate it with your own token via scripts/import_yearly_csv.py (or scripts/download_ci_history.py for the trailing 10 days);
  • the raw pilot logs and forecast-verification records are not published either, because each record carries measured intensity at a timestamp;
  • what is published, under carbon_scheduler/data/public/, is the derived subset every result in the report is computed from: forecast error, direction correctness, regret, percentage savings, region decisions, offsets, guard status and dispatch outcomes. Generate it with python scripts/export_public_evidence.py.

If you cite or build on this work, attribute the underlying data to Electricity Maps.


footer

Undergraduate research project · Sahyadri College of Engineering and Management · data by Electricity Maps

About

Carbon-aware cloud scheduler run live on 13 AWS regions, with 25k verified forecasts and a guard that disables models that don't deliver

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages