Skip to main content

engine.solvers.sustainability

engine.solvers.sustainability

Sustainability solvers: facility power, run footprints, carbon placement, time shifting, and demand.

Domain implementations behind mlsysim.solvers (the public import path, derived from engine.solvers.__init__); kept per-domain so the logic stays reviewable. Added 2026-10-20.

Every model here works on a rated-power (TDP) basis unless a caller passes a measured power: these are upper-bound planning accounts, not meter readings. The power chain is accelerator power, times the rack’s IT-to-accelerator ratio (hosts, switches, conversion inside the IT boundary), times PUE (facility overhead, applied once at the facility boundary). Carbon is facility energy times a grid carbon intensity.

Classes

Name Description
CarbonPricedPlacementModel Placement of one run among regions with and without a carbon price.
CascadeEnergyModel Edge-first cascade: every input runs a small edge model; a fraction
DataMovementEnergyModel Modeled dynamic energy of using one weight: arithmetic against moving it.
DemandReboundModel Fleet energy after a per-unit efficiency change and a volume change: e x v.
DevelopmentSweepModel Final-run equivalents a development sweep consumes: candidates x relative cost.
DutyCycledPowerModel Average power of stages each active a fraction of the time, against a reference always-on power.
EmbodiedPaybackModel Time for a more efficient replacement to repay its manufacturing carbon.
FacilityPowerModel The power chain from accelerators to the facility meter.
GridPlacementModel One facility energy placed on several grids, optionally after an energy cut.
PueRetrofitModel Energy and cost saved by lowering PUE under a fixed IT load over a period.
RepeatedWorkEnergyModel Accelerator energy repeated when a fleet rolls back by each named interval.
RunFootprintModel One training run’s energy, operational carbon, embodied carbon, and water.
ServiceLifeExtensionModel Cut in embodied carbon charged per year when a service life grows: 1 - short / long.
ServingCrossoverModel Calculate serving days needed to match a one-time energy expenditure.
TemporalShiftModel Deadline-constrained carbon-aware time shifting of one flexible run.
WaterUseModel Water consumed for an IT energy at a water usage effectiveness: W = E_IT x WUE.

CarbonPricedPlacementModel

engine.solvers.sustainability.CarbonPricedPlacementModel()

Placement of one run among regions with and without a carbon price.

The run’s duration is the days the fleet needs to spend it_energy at mfu (EconomicsModel’s IT energy per day is region-independent); the PlacementOptimizer then ranks regions by total cost, once with the carbon price and once without.

Methods

Name Description
solve Placement of one run among regions with and without a carbon price.
solve
engine.solvers.sustainability.CarbonPricedPlacementModel.solve(
    fleet,
    it_energy,
    regions,
    carbon_price_per_ton,
    mfu,
    reference_grid,
)

Placement of one run among regions with and without a carbon price.

Parameters
Name Type Description Default
fleet object Fleet supplying accelerator count, power, price, and environment defaults. required
it_energy Quantity IT energy in kWh or compatible units; nonnegative. required
regions List[str] Nonempty list of registered grid names; unrecognized names are skipped. required
carbon_price_per_ton float Nonnegative carbon price in USD per metric ton CO2e. required
mfu float Dimensionless model FLOPs utilization in [0, 1]. required
reference_grid object Grid profile used to determine the region-independent IT energy per day. required
Returns
Name Type Description
CarbonPricedPlacementResult Duration in days, chosen regions, and taxed/untaxed objective mappings in USD.
Notes

Equation: duration_days = IT_energy / modeled_IT_energy_per_day; objective[region] = TCO[region] + carbon_tonnes[region] * carbon_price_per_ton.

Assumptions: EconomicsModel gives region-independent IT energy per day; candidates share fleet and MFU. Excludes: Region-specific runtime changes, data-transfer bills, and deployment eligibility.

References

Derivation: Convert the fixed IT-energy budget to duration, then enumerate EconomicsModel totals with and without the carbon charge.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = CarbonPricedPlacementModel().solve(Systems.Clusters.Research_256, Q_("1 MWh"), ["Quebec"], 100, 0.5, Infrastructure.Grids.Quebec)
>>> result.best_region == "Quebec"
True

CascadeEnergyModel

engine.solvers.sustainability.CascadeEnergyModel()

Edge-first cascade: every input runs a small edge model; a fraction escalation is sent (transmit) to a large cloud model. Mean energy per input E_edge + p (E_tx + E_cloud) against always sending to the cloud.

Methods

Name Description
solve Edge-first cascade: every input runs a small edge model; a fraction.
solve
engine.solvers.sustainability.CascadeEnergyModel.solve(
    edge_energy,
    transmit_energy,
    cloud_energy,
    escalation,
)

Edge-first cascade: every input runs a small edge model; a fraction.

Parameters
Name Type Description Default
edge_energy Quantity Energy spent locally on every input, in joules. required
transmit_energy Quantity Transmission energy for an escalated input, in joules. required
cloud_energy Quantity Cloud processing energy for an escalated input, in joules. required
escalation float Fraction of inputs sent to the cloud, in [0, 1]. required
Returns
Name Type Description
CascadeEnergyResult Escalated, mean, and cloud-only energies in mJ, plus dimensionless relative saving.
Notes

Equation: cloud_only = transmit_energy + cloud_energy; mean = edge_energy + escalation * cloud_only; saving = 1 - mean / cloud_only.

Assumptions: Every input pays edge cost; a fixed fraction also pays transmission and cloud costs. Excludes: Accuracy changes, queueing, retries, and load-dependent power.

References

Derivation: Use the expectation of a two-branch decision: fixed edge cost plus escalation probability times remote cost.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = CascadeEnergyModel().solve(Q_("1 mJ"), Q_("1 mJ"), Q_("10 mJ"), 0.1)
>>> result.mean_energy < result.cloud_only_energy
True

DataMovementEnergyModel

engine.solvers.sustainability.DataMovementEnergyModel()

Modeled dynamic energy of using one weight: arithmetic against moving it.

A weight of bytes_per_param read once for flops_per_param FLOPs costs bytes x E_byte to move and FLOPs x E_flop to compute. The energy crossover E_byte / E_flop is the arithmetic intensity at which the two match; operand_bytes prices one operand fetch against one FLOP.

Methods

Name Description
solve Modeled dynamic energy of using one weight: arithmetic against moving it.
solve
engine.solvers.sustainability.DataMovementEnergyModel.solve(
    energy_per_flop,
    energy_per_byte,
    flops_per_param,
    bytes_per_param,
    operand_bytes,
)

Modeled dynamic energy of using one weight: arithmetic against moving it.

Parameters
Name Type Description Default
energy_per_flop Quantity Positive dynamic arithmetic energy in pJ/flop. required
energy_per_byte Quantity Positive transfer energy in pJ/byte. required
flops_per_param float Positive arithmetic operation count per weight use. required
bytes_per_param Quantity Positive bytes transferred for one weight. required
operand_bytes Quantity Positive bytes transferred for one operand fetch. required
Returns
Name Type Description
DataMovementEnergyResult Compute, transfer, and operand energies in pJ; dimensionless energy ratios; arithmetic intensities in FLOP per byte; and a dimensionless balance batch.
Notes

Equation: compute_energy = flops_per_param * energy_per_flop; movement_energy = bytes_per_param * energy_per_byte; crossover_intensity = energy_per_byte / energy_per_flop.

Assumptions: Each weight is transferred once per modeled use; energy per operation and byte is fixed. Excludes: Caches, static power, communication protocols, and precision- dependent kernel effects.

References

Derivation: Price the operation and byte counts separately; equating their energies gives the energy ridge point E_byte/E_flop.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = DataMovementEnergyModel().solve(Q_("1 pJ/flop"), Q_("10 pJ/byte"), 2, Q_("2 byte"), Q_("2 byte"))
>>> result.movement_energy > result.compute_energy
True

DemandReboundModel

engine.solvers.sustainability.DemandReboundModel()

Fleet energy after a per-unit efficiency change and a volume change: e x v.

Methods

Name Description
solve Fleet energy after a per-unit efficiency change and a volume change: e x v.
solve
engine.solvers.sustainability.DemandReboundModel.solve(
    per_unit_factor,
    volume_factor,
)

Fleet energy after a per-unit efficiency change and a volume change: e x v.

Parameters
Name Type Description Default
per_unit_factor float Nonnegative new-to-old energy ratio per unit of work. required
volume_factor float Nonnegative new-to-old workload volume ratio. required
Returns
Name Type Description
DemandReboundResult Dimensionless total-energy ratio after both changes.
Notes

Equation: net_factor = per_unit_factor * volume_factor.

Assumptions: Per-unit energy and total volume factors multiply independently. Excludes: Causal prediction of induced demand and changes in workload mix.

References

Derivation: Total energy is energy per unit times unit count; dividing new by old cancels the baseline units.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = DemandReboundModel().solve(0.5, 2)
>>> result.net_factor == 1
True

DevelopmentSweepModel

engine.solvers.sustainability.DevelopmentSweepModel()

Final-run equivalents a development sweep consumes: candidates x relative cost.

Methods

Name Description
solve Final-run equivalents a development sweep consumes: candidates x relative cost.
solve
engine.solvers.sustainability.DevelopmentSweepModel.solve(
    candidates,
    relative_cost,
)

Final-run equivalents a development sweep consumes: candidates x relative cost.

Parameters
Name Type Description Default
candidates float Nonnegative number of development candidates. required
relative_cost float Nonnegative cost per candidate relative to a final run. required
Returns
Name Type Description
DevelopmentSweepResult Dimensionless development cost measured in final-run equivalents.
Notes

Equation: final_run_equivalents = candidates * relative_cost.

Assumptions: Every candidate has the same supplied relative cost. Excludes: Failed runs, shared preprocessing, and variable candidate budgets.

References

Derivation: Sum equal candidate costs after normalizing each by final-run cost.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = DevelopmentSweepModel().solve(4, 0.5)
>>> result.final_run_equivalents == 2
True

DutyCycledPowerModel

engine.solvers.sustainability.DutyCycledPowerModel()

Average power of stages each active a fraction of the time, against a reference always-on power.

Methods

Name Description
solve Average power of stages each active a fraction of the time, against a reference always-on power.
solve
engine.solvers.sustainability.DutyCycledPowerModel.solve(
    powers,
    duty_cycles,
    reference_power,
)

Average power of stages each active a fraction of the time, against a reference always-on power.

Parameters
Name Type Description Default
powers Dict[str, Quantity] Nonempty mapping of stage names to nonnegative power quantities. required
duty_cycles Dict[str, float] Stage-name mapping to active fractions in [0, 1]; must cover powers. required
reference_power Quantity Positive always-on comparison power in watts. required
Returns
Name Type Description
DutyCycledPowerResult Stage contributions and average power in microwatts, and reference-to- average power ratio.
Notes

Equation: average_power = sum(stage_power * stage_duty); reduction = reference_power / average_power.

Assumptions: Stage powers are additive; duty fractions describe the same observation window. Excludes: Sleep leakage, switching energy, and correlated peak-power constraints.

References

Derivation: Time-averaging each rectangular active-power contribution gives power times duty fraction; add the contributions.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = DutyCycledPowerModel().solve({"stage": Q_("10 W")}, {"stage": 0.5}, Q_("10 W"))
>>> result.average_power == Q_("5 W")
True

EmbodiedPaybackModel

engine.solvers.sustainability.EmbodiedPaybackModel()

Time for a more efficient replacement to repay its manufacturing carbon.

The replacement does the old device’s work with saved_fraction less energy, running continuously at the old device’s power; the carbon it avoids per day is the saved energy times the grid intensity, and payback is the embodied carbon divided by that daily saving.

Methods

Name Description
solve Time for a more efficient replacement to repay its manufacturing carbon.
solve
engine.solvers.sustainability.EmbodiedPaybackModel.solve(
    embodied,
    device_power,
    saved_fraction,
    intensities,
)

Time for a more efficient replacement to repay its manufacturing carbon.

Parameters
Name Type Description Default
embodied Quantity Replacement manufacturing carbon in kg CO2e; nonnegative. required
device_power Quantity Power per accelerator in watts; nonnegative rated or supplied measured power. required
saved_fraction float Fraction of baseline power avoided, in (0, 1]. required
intensities Dict[str, Quantity] Nonempty mapping of grid names to positive carbon intensities in g/kWh. required
Returns
Name Type Description
EmbodiedPaybackResult Saved power in kW, daily energy in kWh, daily avoided carbon in kg, and per- grid payback times in days.
Notes

Equation: saved_power = device_power * saved_fraction; avoided_carbon_per_day = saved_power * one_day * intensity; payback = embodied / avoided_carbon_per_day.

Assumptions: Replacement provides equal useful work continuously; power saving and positive grid intensities stay fixed. Excludes: Idle periods, changing demand, old-device disposal, and discounting future emissions.

References

Derivation: Divide the one-time manufacturing carbon by avoided carbon per day to obtain a carbon-balance time.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = EmbodiedPaybackModel().solve(Q_("1 kg"), Q_("1 kW"), 0.5, {"site": Q_("100 g/kWh")})
>>> result.payback["site"] > Q_("0 day")
True

FacilityPowerModel

engine.solvers.sustainability.FacilityPowerModel()

The power chain from accelerators to the facility meter.

Accelerator power is devices x device_power; the IT load multiplies it by the rack’s IT-to-accelerator ratio (hosts, switches, network adapters, and conversion losses inside the IT boundary); the facility draws the IT load times PUE. The facility figure is what the grid connection must supply at every instant.

Methods

Name Description
solve The power chain from accelerators to the facility meter.
solve
engine.solvers.sustainability.FacilityPowerModel.solve(
    devices,
    device_power,
    it_ratio,
    pue,
)

The power chain from accelerators to the facility meter.

Parameters
Name Type Description Default
devices float Accelerator count, positive and dimensionless. required
device_power Quantity Power per accelerator in watts; nonnegative rated or supplied measured power. required
it_ratio float Dimensionless IT-to-accelerator power ratio, at least one for this boundary. required
pue float Dimensionless facility-to-IT energy ratio, at least one. required
Returns
Name Type Description
FacilityPowerResult Accelerator, IT, facility, support, and facility-overhead powers in MW.
Notes

Equation: P_acc = devices * device_power; P_IT = P_acc * it_ratio; P_facility = P_IT * PUE.

Assumptions: All devices draw the same supplied power; ratios describe nested boundaries. Excludes: Transient peaks, redundancy margins, and capacity admission.

References

Derivation: Apply each boundary ratio once; subtract accelerator from IT and IT from facility to isolate overhead.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = FacilityPowerModel().solve(2, Q_("100 W"), 1.2, 1.1)
>>> result.facility_power > result.it_power
True

GridPlacementModel

engine.solvers.sustainability.GridPlacementModel()

One facility energy placed on several grids, optionally after an energy cut.

Emissions are E x CI per grid; energy_cut is a fractional energy reduction applied before the grid factor (an algorithmic saving), so a placement and an efficiency gain can be compared at one energy.

Methods

Name Description
solve One facility energy placed on several grids, optionally after an energy cut.
solve
engine.solvers.sustainability.GridPlacementModel.solve(
    energy,
    intensities,
    energy_cut=0.0,
)

One facility energy placed on several grids, optionally after an energy cut.

Parameters
Name Type Description Default
energy Quantity Facility energy in kWh; nonnegative. required
intensities Dict[str, Quantity] Nonempty mapping of grid names to positive carbon intensities in g/kWh. required
energy_cut float Fractional energy reduction in [0, 1]; default zero. 0.0
Returns
Name Type Description
GridPlacementResult Emissions before and after the cut in metric tons, lowest/highest intensity grid names, and their dimensionless intensity ratio.
Notes

Equation: emissions[grid] = energy * intensity[grid]; reduced_emissions = emissions * (1 - energy_cut).

Assumptions: All regions serve identical energy demand and all intensities are positive. Excludes: Regional latency, electricity cost, marginal dispatch, and placement feasibility.

References

Derivation: At fixed energy, carbon ordering equals intensity ordering; scale both by the same fractional energy saving.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = GridPlacementModel().solve(Q_("1 kWh"), {"low": Q_("10 g/kWh"), "high": Q_("100 g/kWh")})
>>> result.lowest == "low"
True

PueRetrofitModel

engine.solvers.sustainability.PueRetrofitModel()

Energy and cost saved by lowering PUE under a fixed IT load over a period.

Methods

Name Description
solve Energy and cost saved by lowering PUE under a fixed IT load over a period.
solve
engine.solvers.sustainability.PueRetrofitModel.solve(
    it_power,
    pue_before,
    pue_after,
    period,
    electricity_price,
)

Energy and cost saved by lowering PUE under a fixed IT load over a period.

Parameters
Name Type Description Default
it_power Quantity Constant IT load in watts; nonnegative. required
pue_before float Initial dimensionless PUE, at least one. required
pue_after float Replacement dimensionless PUE, at least one. required
period Quantity Duration in hours or compatible time units; nonnegative. required
electricity_price Quantity Energy price in USD/kWh; nonnegative. required
Returns
Name Type Description
PueRetrofitResult Before/after facility powers and saved power in MW, saved energy in MWh, and saved electricity cost in USD.
Notes

Equation: saved_power = IT_power * (PUE_before - PUE_after); saved_energy = saved_power * period; saved_cost = saved_energy * price.

Assumptions: IT load and electricity price stay fixed across both PUE cases. Excludes: Retrofit capital cost, downtime, and changes in IT demand.

References

Derivation: Subtract the facility-power products before integrating over the period; price only the energy difference.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = PueRetrofitModel().solve(Q_("1 kW"), 1.4, 1.2, Q_("1 day"), Q_("0.1 USD/kWh"))
>>> result.saved_energy > Q_("0 kWh")
True

RepeatedWorkEnergyModel

engine.solvers.sustainability.RepeatedWorkEnergyModel()

Accelerator energy repeated when a fleet rolls back by each named interval.

Methods

Name Description
solve Accelerator energy repeated when a fleet rolls back by each named interval.
solve
engine.solvers.sustainability.RepeatedWorkEnergyModel.solve(
    devices,
    device_power,
    rollbacks,
)

Accelerator energy repeated when a fleet rolls back by each named interval.

Parameters
Name Type Description Default
devices float Accelerator count, positive and dimensionless. required
device_power Quantity Power per accelerator in watts; nonnegative rated or supplied measured power. required
rollbacks Dict[str, Quantity] Named nonnegative rollback intervals in time units. required
Returns
Name Type Description
RepeatedWorkEnergyResult Named rollback energy expenditures in MWh.
Notes

Equation: energy[interval] = devices * device_power * rollback_time[interval].

Assumptions: All devices repeat work at constant supplied power for each interval. Excludes: Recovery I/O, idle power, and facility overhead.

References

Derivation: Integrate fleet accelerator power over each repeated-work interval.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = RepeatedWorkEnergyModel().solve(2, Q_("100 W"), {"short": Q_("1 hour"), "long": Q_("2 hour")})
>>> result.energy["long"] == 2 * result.energy["short"]
True

RunFootprintModel

engine.solvers.sustainability.RunFootprintModel()

One training run’s energy, operational carbon, embodied carbon, and water.

Energy follows the power chain over the run’s device-hours: accelerator energy device_hours x device_power, IT energy times the rack ratio, facility energy times PUE. Operational carbon applies each named grid’s intensity to facility energy. Embodied carbon is devices x embodied_per_device at manufacture; the run is charged its time share, device_hours x embodied_per_device / service_life. Water applies each WUE to IT energy (WUE’s denominator is IT energy).

Methods

Name Description
solve One training run’s energy, operational carbon, embodied carbon, and water.
solve
engine.solvers.sustainability.RunFootprintModel.solve(
    device_hours,
    devices,
    device_power,
    it_ratio,
    pue,
    intensities,
    embodied_per_device,
    service_life,
    wue=None,
)

One training run’s energy, operational carbon, embodied carbon, and water.

Parameters
Name Type Description Default
device_hours Quantity Aggregate accelerator operating time in hours; count is dimensionless. required
devices float Accelerator count, positive and dimensionless. required
device_power Quantity Power per accelerator in watts; nonnegative rated or supplied measured power. required
it_ratio float Dimensionless IT-to-accelerator power ratio, at least one for this boundary. required
pue float Dimensionless facility-to-IT energy ratio, at least one. required
intensities Dict[str, Quantity] Nonempty mapping of grid names to positive carbon intensities in g/kWh. required
embodied_per_device Quantity Manufacturing carbon per accelerator in kg CO2e; nonnegative. required
service_life Quantity Positive service lifetime in hours or compatible time units. required
wue Optional[Dict[str, Quantity]] Named water-use factors in liters per kWh of IT energy; nonnegative. None
Returns
Name Type Description
RunFootprintResult Power breakdown, duration in hours, energy in MWh, operational and embodied carbon in metric tons, embodied fractions, and optional water in liters.
Notes

Equation: E_acc = device_hours * device_power; E_IT = E_acc * it_ratio; E_facility = E_IT * PUE. Allocated embodied carbon = device_hours * embodied_per_device / service_life.

Assumptions: Device-hours aggregate equal-power accelerators; embodied carbon is allocated uniformly over the supplied service life. Excludes: Manufacturing timing, retirement credits, and variation of grid intensity within the run.

References

Derivation: Integrate device power over aggregate hours, apply the two overhead ratios, and charge manufacturing carbon in proportion to consumed service hours.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = RunFootprintModel().solve(Q_("2 hour"), 2, Q_("100 W"), 1.2, 1.1, {"site": Q_("100 g/kWh")}, Q_("1 kg"), Q_("1 year"))
>>> result.facility_energy > result.it_energy
True

ServiceLifeExtensionModel

engine.solvers.sustainability.ServiceLifeExtensionModel()

Cut in embodied carbon charged per year when a service life grows: 1 - short / long.

Methods

Name Description
solve Cut in embodied carbon charged per year when a service life grows: 1 - short / long.
solve
engine.solvers.sustainability.ServiceLifeExtensionModel.solve(
    short_life,
    long_life,
)

Cut in embodied carbon charged per year when a service life grows: 1 - short / long.

Parameters
Name Type Description Default
short_life Quantity Positive original service life in time units. required
long_life Quantity Positive extended service life in compatible time units. required
Returns
Name Type Description
ServiceLifeExtensionResult Dimensionless reduction in annual embodied-carbon allocation.
Notes

Equation: annual_charge_reduction = 1 - short_life / long_life.

Assumptions: Identical embodied carbon is spread uniformly over either positive lifetime. Excludes: Replacement operating energy and changes in useful work.

References

Derivation: Annual charges are C/short and C/long; their relative reduction cancels C and equals 1-short/long.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = ServiceLifeExtensionModel().solve(Q_("1 year"), Q_("2 year"))
>>> result.annual_charge_reduction > 0
True

ServingCrossoverModel

engine.solvers.sustainability.ServingCrossoverModel()

Calculate serving days needed to match a one-time energy expenditure.

Methods

Name Description
solve Calculate serving days needed to match a one-time energy expenditure.
solve
engine.solvers.sustainability.ServingCrossoverModel.solve(
    one_time_energy,
    requests_per_day,
    energy_per_request,
)

Calculate serving days needed to match a one-time energy expenditure.

Parameters
Name Type Description Default
one_time_energy Quantity One-time energy expenditure in joules or compatible units. required
requests_per_day float Positive request count per calendar day, supplied as a scalar. required
energy_per_request Quantity Positive energy per request in joules; request count is dimensionless. required
Returns
Name Type Description
ServingCrossoverResult Daily serving energy in MWh and dimensionless elapsed day count at crossover.
Notes

Equation: daily_energy = requests_per_day * energy_per_request; crossover_days = one_time_energy / daily_energy.

Assumptions: Positive constant daily request volume and per-request energy. Excludes: Load growth, idle infrastructure, and latency constraints.

References

Derivation: Divide one-time energy by daily serving energy; each quotient unit denotes one day of demand.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = ServingCrossoverModel().solve(Q_("1 kWh"), 100, Q_("1 J"))
>>> result.crossover_days > 0
True

TemporalShiftModel

engine.solvers.sustainability.TemporalShiftModel()

Deadline-constrained carbon-aware time shifting of one flexible run.

Picks the start time with the lowest total emissions among starts that finish by the deadline and have capacity. Waiting is charged the extra energy it causes, so a later start wins only if it avoids more carbon than the wait adds.

Methods

Name Description
solve Best deadline-feasible start of one flexible run on a time-varying grid signal.
solve
engine.solvers.sustainability.TemporalShiftModel.solve(
    intensities,
    power,
    duration,
    slack,
    step=None,
    deferral_energy=None,
    standby_power=None,
    capacity_available=None,
)

Best deadline-feasible start of one flexible run on a time-varying grid signal.

Parameters
Name Type Description Default
intensities List[Quantity] Carbon intensity per step, in g/kWh or compatible units, starting at the run’s release; finite and nonnegative; must cover duration + slack. Average or marginal intensity is the caller’s choice. required
power Quantity Facility power while the run executes (IT power times PUE), in kW or compatible units; finite and nonnegative. required
duration Quantity Run duration; a positive whole number of steps. required
slack Quantity The run must finish by release + duration + slack; a nonnegative whole number of steps. Zero forces an immediate start. required
step Quantity Length of one signal step; default one hour. None
deferral_energy Quantity One-time extra energy caused by deferring, such as restaging input data, in kWh or compatible units; finite and nonnegative; default zero. None
standby_power Quantity Extra power drawn while waiting, such as reserved capacity kept powered, in kW or compatible units; finite and nonnegative; default zero. Use zero if the hardware draws that power either way. None
capacity_available List[bool] Per-step bool: True if capacity is free. A start is feasible only if every step it occupies is free. Non-bool values are rejected. Default: all free. None
Returns
Name Type Description
TemporalShiftResult Chosen start and completion time; start-now, run, overhead, and net emissions in kg CO2e; net saving and saving fraction (None if start-now emits nothing); net emissions per candidate start (None if infeasible); and the shortest wait that saves carbon (None if none does).
Notes

Equation: with n run steps, step energy E = power * step, and candidate wait k in {0, …, slack/step}, run(k) = sum over t from k to k+n-1 of E * CI[t]; overhead(0) = 0 and, for k > 0, overhead(k) = deferral_energy * CI[0] + sum over t from 0 to k-1 of standby_power * step * CI[t]; net(k) = run(k) + overhead(k). Among starts with capacity in steps k to k+n-1, the chosen wait minimizes net(k), taking the earliest wait on ties, and net_saving = net(0) - min net(k). If start-now has no capacity, net(0) is hypothetical (immediate_feasible is False) and net_saving can be negative.

Assumptions: The run is non-preemptive and contiguous; power is constant; intensity is uniform within each step; deferral energy is drawn at release. Excludes: Pausing or migrating a started run, partial capacity, forecast error, runtime changes from moving the run, failures, and penalties other than the hard deadline.

References

Derivation: Emissions are energy times intensity summed per step; checking every feasible start gives the exact minimum. Related work: Radovanovic et al., Carbon-Aware Computing for Datacenters, https://arxiv.org/abs/2106.11750.

Examples
>>> from mlsysim import Q_
>>> signal = [Q_(500, "g/kWh"), Q_(500, "g/kWh"), Q_(100, "g/kWh")]
>>> result = TemporalShiftModel().solve(signal, Q_("10 kW"), Q_("1 hour"), Q_("2 hour"))
>>> result.best_start.m_as("hour"), result.net_saving.m_as("kg")
(2.0, 4.0)

WaterUseModel

engine.solvers.sustainability.WaterUseModel()

Water consumed for an IT energy at a water usage effectiveness: W = E_IT x WUE.

Methods

Name Description
solve Water consumed for an IT energy at a water usage effectiveness: W = E_IT x WUE.
solve
engine.solvers.sustainability.WaterUseModel.solve(it_energy, wue)

Water consumed for an IT energy at a water usage effectiveness: W = E_IT x WUE.

Parameters
Name Type Description Default
it_energy Quantity IT energy in kWh or compatible units; nonnegative. required
wue Dict[str, Quantity] Named water-use factors in liters per kWh of IT energy; nonnegative. required
Returns
Name Type Description
WaterUseResult Mapping of site names to water quantities in liters.
Notes

Equation: water[site] = IT_energy * WUE[site], converted to liters.

Assumptions: Every WUE uses IT energy as its denominator and remains constant. Excludes: Supply-chain water and facility-energy WUE conventions.

References

Derivation: Multiply liters per IT kWh by IT kWh; the energy unit cancels.

Examples
>>> from mlsysim import Q_, Systems, Infrastructure
>>> result = WaterUseModel().solve(Q_("1 kWh"), {"site": Q_("1 liter/kWh")})
>>> result.water["site"] == Q_("1 liter")
True
Back to top