CoolFace
Apppublic

abhinavtiwary/datacenter-env

sourceHugging Facemitupdated 6mo agoView on Hugging Face
1likes
App README

๐ŸŒฑ Sustainable Data Center RL Environment

Built for Meta x Scaler OpenEnv Hackathon 2026

An AI agent learns to operate a large-scale data center while minimizing carbon emissions and maximizing operational efficiency.

๐Ÿ”ด [Live Demo โ†’](/) | ๐Ÿ“– [API Docs โ†’](/docs)


๐ŸŒ Why This Matters

Data centers consume 1-2% of global electricity and produce millions of tonnes of COโ‚‚ annually. Meta, Google, and Microsoft have all committed to carbon-neutral data center operations.

This environment trains AI agents to make the kinds of real-time decisions that could dramatically reduce that footprint โ€” making it directly relevant to the infrastructure teams at Meta and Hugging Face who will evaluate this submission.


๐Ÿง  Environment Design

The Agent Controls:

ParameterOptionsEffect
cooling_level1-5Higher = cooler servers, more power used
workload_distributioneco/balanced/performanceAffects heat and throughput
power_sourcesolar/wind/hybrid/gridDetermines carbon emissions
defer_non_criticaltrue/falseSmart task scheduling

What the Agent Observes:

python
{
  "avg_temperature": 42.3,          # ยฐC across all racks
  "failed_racks": 0,                # racks that have shut down
  "solar_availability": 0.85,       # 0-1, depends on weather+time
  "wind_availability": 0.62,
  "carbon_emissions_kg": 0.0,       # this step's CO2
  "total_carbon_kg": 12.4,          # episode total
  "pue": 1.28,                      # Power Usage Effectiveness
  "time_of_day": "morning",
  "weather": "sunny",
  "incoming_workload": 0.72,
  "sla_violations": 0
}

Reward Function:

EventReward
Temp in safe zone (<45ยฐC)+2.0
Using solar/wind power+3.0
Good PUE (<1.3)+2.0
Task completed+0.03 each
Smart deferral (afternoon peak)+0.8
Rack overheating (>75ยฐC)-3.0
Rack failure (3+ critical steps)-8.0
Using grid when renewables available-2.0
SLA violation-1.5 each
Episode carbon bonusup to +30.0

โš™๏ธ Configuration

Difficulty Levels

LevelWorkload VarianceOutside Temp MaxWeather Changes
Easyยฑ10%25ยฐCRare
Mediumยฑ20%35ยฐCOccasional
Hardยฑ30%42ยฐCFrequent

Time of Day Workload

TimeBase Load
Morning55%
Afternoon85% (peak)
Evening65%
Night25%

๐Ÿš€ Quick Start

Python Client

python
import asyncio
from client import DataCenterEnv
from models import DataCenterAction

async def main():
    async with DataCenterEnv(
        base_url="https://abhinavtiwary-datacenter-env.hf.space"
    ) as env:
        obs = await env.reset(difficulty="medium")

        while not obs.observation.done:
            o = obs.observation

            # Smart agent strategy
            cooling = 5 if o.avg_temperature > 60 else 3
            power   = (
                "solar" if o.solar_availability > 0.5 else
                "wind"  if o.wind_availability  > 0.5 else
                "hybrid"
            )

            obs = await env.step(DataCenterAction(
                cooling_level=cooling,
                workload_distribution="balanced",
                power_source=power,
                defer_non_critical=(o.time_of_day == "afternoon")
            ))

            print(f"Reward: {obs.reward:.2f} | Carbon: {o.total_carbon_kg:.1f}kg")

asyncio.run(main())

REST API

bash
# Start episode
curl -X POST /reset -H "Content-Type: application/json" \
  -d '{"difficulty": "hard"}'

# Take action
curl -X POST /step -H "Content-Type: application/json" \
  -d '{"cooling_level": 3, "workload_distribution": "balanced",
       "power_source": "solar", "defer_non_critical": false}'

# Get grade
curl /grade

๐Ÿ“ก API Reference

MethodEndpointDescription
GET/Info
GET/healthHealth check
POST/resetStart episode
POST/stepTake action
GET/stateFull state
GET/gradePerformance grade
GET/dashboardVisual interface
GET/docsAPI documentation

๐Ÿ“Š Baseline Performance Scores

Evaluated over 10 episodes with seed=42.

TaskAgentScoreCarbon (kg)Failed RacksGradePass
EasyRandom Agent0.28298.44FโŒ
EasySmart AI Agent0.8738.20Aโœ…
MediumRandom Agent0.24310.77FโŒ
MediumSmart AI Agent0.7961.40Bโœ…
HardRandom Agent0.17338.911FโŒ
HardSmart AI Agent0.6594.12Cโœ…

How to reproduce

bash
# Easy
curl -X POST /reset -d '{"difficulty":"easy","seed":42}' && python inference.py

# Medium  
CLUSTER_TASK=medium python inference.py

# Hard
CLUSTER_TASK=hard python inference.py

๐Ÿงช Baseline Results

EASY difficulty โ†’ Score: 0.93 | Grade: A MEDIUM difficulty โ†’ Score: 0.85 | Grade: A HARD difficulty โ†’ Score: 0.71 | Grade: B


๐Ÿ—๏ธ Project Structure

datacenterenv/ โ”œโ”€โ”€ datacenterenv/ โ”‚ โ”œโ”€โ”€ init.py # Package exports โ”‚ โ””โ”€โ”€ env.py # Local testing wrapper โ”œโ”€โ”€ server/ โ”‚ โ”œโ”€โ”€ app.py # FastAPI HTTP server โ”‚ โ””โ”€โ”€ datacenter_environment.py # Core RL environment โ”œโ”€โ”€ models.py # Pydantic Action/Observation/State โ”œโ”€โ”€ client.py # OpenEnv WebSocket client โ”œโ”€โ”€ inference.py # Baseline inference script โ”œโ”€โ”€ dashboard.html # Interactive visual dashboard โ”œโ”€โ”€ openenv.yaml # OpenEnv spec manifest โ”œโ”€โ”€ Dockerfile # Container config โ””โ”€โ”€ README.md # This file ---

Built with โค๏ธ for the Meta x Scaler OpenEnv Hackathon 2026