SpotRunScenario
Economics scenarios · Implementation: mlsysim/engine/scenario_definitions/economics.py.
Construct this scenario with keyword inputs. The fields below show the types and defaults declared by this class.
A training run of run_duration on fleet, on demand against spot capacity.
Spot adds checkpoint_overhead_fraction of the run for checkpoints and restart_per_interruption for each of interruptions_per_day per day of the run.
Notes
Equation: spot bill = device count * (useful hours + checkpoint hours + restart hours) * spot price.
Assumptions: The run keeps a fixed fleet. Interruption counts use complete baseline days; restart overhead does not generate more interruptions.
Excludes: Partial-day interruptions, fluctuating spot prices, queue delay, and availability risk.
References
Derivation: spot bill = device count * (useful hours + checkpoint hours + restart hours) * spot price. The individual properties state units and intermediate accounting; this class introduces no fitted coefficient.
Examples
The named scenario supplies illustrative inputs; the output is calculated.
>>> from mlsysim import Scenarios
>>> case = Scenarios.Llama2_70BSpotRun512
>>> round(float(case.gpus), 3)
512.0Attributes
| Name | Description |
|---|---|
| checkpoint_extra_hours | Additional wall-clock hours from the declared checkpoint fraction of useful run |
| checkpoint_overhead_fraction | |
| fleet | |
| gpus | Device count supplied by the scenario’s fleet registry entry. |
| interruptions | Expected interruption count for complete baseline days only; partial days are |
| interruptions_per_day | |
| longer_share | Fractional run-time increase caused by spot checkpoint and restart overhead. |
| on_demand_cost | Baseline USD charge: device count times useful hours times on-demand hourly price. |
| on_demand_rate | |
| restart_per_interruption | |
| restart_total_hours | Additional hours from interruption count times restart duration per interruption. |
| run_days | Baseline useful run duration as a scalar number of days. |
| run_duration | |
| run_hours | Baseline useful run duration as a scalar number of hours. |
| savings | USD saved by spot relative to on-demand; negative means a cost increase. |
| savings_share | Fraction of baseline on-demand cost saved; requires nonzero baseline cost. |
| spot_base_cost | USD charge for useful work alone at the spot hourly price, before overhead. |
| spot_rate | |
| spot_total_cost | USD charge for all billed spot device-hours at the spot rate. |
| spot_total_hours | Billed spot wall-clock hours, adding useful work, checkpoint, and restart time. |
| workload |
fleet
Type: Fleet.
Declared default: required.
workload
Type: Optional[Workload].
Declared default: None.
run_duration
Type: Quantity.
Declared default: required.
on_demand_rate
Type: Quantity.
Declared default: required.
spot_rate
Type: Quantity.
Declared default: required.
checkpoint_overhead_fraction
Type: float.
Declared default: required.
interruptions_per_day
Type: int.
Declared default: required.
restart_per_interruption
Type: Quantity.
Declared default: required.
gpus
engine.scenario_types.SpotRunScenario.gpus
Device count supplied by the scenario’s fleet registry entry.
Equation: return fleet.total_accelerators.
run_hours
engine.scenario_types.SpotRunScenario.run_hours
Baseline useful run duration as a scalar number of hours.
Equation: return run_duration.to('hour').magnitude.
run_days
engine.scenario_types.SpotRunScenario.run_days
Baseline useful run duration as a scalar number of days.
Equation: return run_duration.to('day').magnitude.
on_demand_cost
engine.scenario_types.SpotRunScenario.on_demand_cost
Baseline USD charge: device count times useful hours times on-demand hourly price.
Equation: return gpus * run_hours * _usd_per_hour(on_demand_rate).
spot_base_cost
engine.scenario_types.SpotRunScenario.spot_base_cost
USD charge for useful work alone at the spot hourly price, before overhead.
Equation: return gpus * run_hours * _usd_per_hour(spot_rate).
checkpoint_extra_hours
engine.scenario_types.SpotRunScenario.checkpoint_extra_hours
Additional wall-clock hours from the declared checkpoint fraction of useful run time.
Equation: return checkpoint_overhead_fraction * run_hours.
interruptions
engine.scenario_types.SpotRunScenario.interruptions
Expected interruption count for complete baseline days only; partial days are discarded by floor division.
Equation: return interruptions_per_day * (run_hours // 24).
restart_total_hours
engine.scenario_types.SpotRunScenario.restart_total_hours
Additional hours from interruption count times restart duration per interruption.
Equation: return interruptions * restart_per_interruption.to('hour').magnitude.
spot_total_hours
engine.scenario_types.SpotRunScenario.spot_total_hours
Billed spot wall-clock hours, adding useful work, checkpoint, and restart time.
Equation: return run_hours + checkpoint_extra_hours + restart_total_hours.
spot_total_cost
engine.scenario_types.SpotRunScenario.spot_total_cost
USD charge for all billed spot device-hours at the spot rate.
Equation: return gpus * spot_total_hours * _usd_per_hour(spot_rate).
savings
engine.scenario_types.SpotRunScenario.savings
USD saved by spot relative to on-demand; negative means a cost increase.
Equation: return on_demand_cost - spot_total_cost.