openg2g.datacenter¶
openg2g.datacenter.base
¶
Abstract base class for datacenter backends and base state types.
DatacenterState
dataclass
¶
State emitted by a datacenter backend each timestep.
Contains only universally applicable fields. LLM-inference-specific
fields (batch sizes, replicas, latency) live on LLMDatacenterState.
Source code in openg2g/datacenter/base.py
LLMDatacenterState
dataclass
¶
Bases: DatacenterState
State from a datacenter serving LLM workloads.
Extends DatacenterState with per-model batch size, replica count,
and observed inter-token latency fields used by LLM controllers.
Source code in openg2g/datacenter/base.py
DatacenterBackend
¶
Bases: Generic[DCStateT], ABC
Interface for datacenter power simulation backends.
Source code in openg2g/datacenter/base.py
dt_s
abstractmethod
property
¶
Native timestep as a Fraction (seconds).
state
abstractmethod
property
¶
Latest emitted state.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If accessed before the first |
history(n=None)
abstractmethod
¶
step(clock)
abstractmethod
¶
apply_control(command)
abstractmethod
¶
reset()
abstractmethod
¶
Reset simulation state to initial conditions.
Called by the coordinator before each start(). Must clear all
simulation state: history, counters, RNG seeds, cached values.
Configuration (dt_s, models, templates) is not affected.
Abstract so every implementation explicitly enumerates its state. A forgotten field is a bug -- not clearing it silently corrupts the second run.
Source code in openg2g/datacenter/base.py
start()
¶
Acquire per-run resources (threads, solver circuits).
Called after reset(), before the simulation loop. Override for
backends that need resource acquisition (e.g., OpenDSSGrid
compiles its DSS circuit here). No-op by default because most
offline components have no resources to acquire.
Source code in openg2g/datacenter/base.py
stop()
¶
Release per-run resources. Simulation state is preserved.
Called after the simulation loop in LIFO order. Override for
backends that acquired resources in start(). No-op by default.
LLMBatchSizeControlledDatacenter
¶
Bases: DatacenterBackend[DCStateT]
Datacenter that serves LLM workloads and supports batch-size control.
Marker layer between DatacenterBackend and concrete implementations.
Controllers that issue set_batch_size commands or read
active_replicas_by_model / observed_itl_s_by_model from state
should bind their generic to this class.
Source code in openg2g/datacenter/base.py
phase_share_by_model
property
¶
Per-model phase share vectors [frac_A, frac_B, frac_C].
Returns an empty dict by default. Consumers treat missing keys
as uniform [1/3, 1/3, 1/3]. Override in subclasses that know
actual server-to-phase placement.
dt_s
abstractmethod
property
¶
Native timestep as a Fraction (seconds).
state
abstractmethod
property
¶
Latest emitted state.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If accessed before the first |
history(n=None)
abstractmethod
¶
step(clock)
abstractmethod
¶
apply_control(command)
abstractmethod
¶
reset()
abstractmethod
¶
Reset simulation state to initial conditions.
Called by the coordinator before each start(). Must clear all
simulation state: history, counters, RNG seeds, cached values.
Configuration (dt_s, models, templates) is not affected.
Abstract so every implementation explicitly enumerates its state. A forgotten field is a bug -- not clearing it silently corrupts the second run.
Source code in openg2g/datacenter/base.py
start()
¶
Acquire per-run resources (threads, solver circuits).
Called after reset(), before the simulation loop. Override for
backends that need resource acquisition (e.g., OpenDSSGrid
compiles its DSS circuit here). No-op by default because most
offline components have no resources to acquire.
Source code in openg2g/datacenter/base.py
stop()
¶
Release per-run resources. Simulation state is preserved.
Called after the simulation loop in LIFO order. Override for
backends that acquired resources in start(). No-op by default.
openg2g.datacenter.config
¶
Datacenter facility and workload configuration.
TrainingRun
dataclass
¶
A single training workload window.
Attributes:
| Name | Type | Description |
|---|---|---|
t_start |
float
|
Global simulation time when training becomes active (seconds). |
t_end |
float
|
Global simulation time when training stops (seconds). |
n_gpus |
int
|
Number of GPUs running the training workload. |
trace |
TrainingTrace
|
Single-GPU training power trace. |
target_peak_W_per_gpu |
float
|
The trace is rescaled so its peak equals this value. |
Source code in openg2g/datacenter/config.py
TrainingSchedule
¶
Ordered collection of training windows, built with |.
Example:
schedule = (
TrainingRun(t_start=500, t_end=1500, n_gpus=2400, trace=trace_a)
| TrainingRun(t_start=2000, t_end=3000, n_gpus=1200, trace=trace_b)
)
Source code in openg2g/datacenter/config.py
ServerRamp
dataclass
¶
A single server ramp event.
Transitions the active-server fraction to target linearly over
[t_start, t_end].
Attributes:
| Name | Type | Description |
|---|---|---|
t_start |
float
|
Global simulation time when the ramp begins (seconds). |
t_end |
float
|
Global simulation time when the ramp ends (seconds). |
target |
float
|
Target active-server fraction after the ramp (0.0--1.0). |
Source code in openg2g/datacenter/config.py
ServerRampSchedule
¶
Ordered collection of server ramp events, built with |.
Semantics: before the first ramp, fraction = 1.0. During each
[t_start, t_end] window, the fraction linearly interpolates from
the previous level to target. Between ramps, the fraction holds
at the last target.
An empty schedule means all servers are active (fraction = 1.0) at all times.
Example:
ramps = (
ServerRamp(t_start=2500, t_end=3000, target=0.2)
| ServerRamp(t_start=3200, t_end=3400, target=1.0)
)
Source code in openg2g/datacenter/config.py
fraction_at(t)
¶
Evaluate the active-server fraction at time(s) t.
Piecewise-linear interpolation between ramp events. Before the first ramp, fraction = 1.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | ndarray
|
Scalar or array of global simulation times (seconds). |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Active-server fraction(s), same shape as t. |
Source code in openg2g/datacenter/config.py
DatacenterConfig
dataclass
¶
Physical datacenter facility configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
gpus_per_server |
int
|
Number of GPUs per physical server rack. |
base_kw_per_phase |
float
|
Constant base load per phase (kW). |
Source code in openg2g/datacenter/config.py
WorkloadConfig
¶
What runs in the datacenter: inference, training, and ramp events.
Accepts flexible input types and normalizes them internally:
- A single TrainingRun is wrapped in a TrainingSchedule.
- A single ServerRamp is wrapped in a ServerRampSchedule.
- None yields an empty schedule.
Properties always return schedule types, eliminating isinstance
checks at consumption sites.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inference
|
LLMInferenceWorkload
|
LLM inference workload specification. |
required |
training
|
TrainingRun | TrainingSchedule | None
|
Training workload window(s). |
None
|
server_ramps
|
ServerRamp | ServerRampSchedule | None
|
Server ramp event(s). |
None
|
Source code in openg2g/datacenter/config.py
openg2g.datacenter.layout
¶
Server layout and power augmentation primitives.
Provides the shared components for scaling per-GPU power measurements to datacenter-level three-phase power output. These primitives are backend-agnostic and can be used by both offline (trace-based) and online (live GPU) datacenters.
ActivationPolicy
¶
Bases: ABC
Per-model activation policy that answers "which servers are active?"
Created by ActivationStrategy.for_model and bound to a specific
model's server pool.
Source code in openg2g/datacenter/layout.py
active_mask(t)
abstractmethod
¶
Boolean mask of active servers at time t.
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape |
active_indices(t)
¶
Indices of active servers at time t.
The default implementation returns indices in ascending order via
np.where(active_mask(t)). Subclasses may override to return
indices in a specific order (e.g., priority order) to control
floating-point summation order in the datacenter.
Returns:
| Type | Description |
|---|---|
ndarray
|
1-D int array of active server indices. |
Source code in openg2g/datacenter/layout.py
ActivationStrategy
¶
Bases: ABC
Factory that creates per-model ActivationPolicy instances.
A strategy is instantiated once and passed to the datacenter. When
the datacenter builds each model's server layout, it calls
for_model to create a model-specific ActivationPolicy.
Subclass to implement custom activation strategies. The phase_list
argument in for_model enables phase-aware load balancing.
Source code in openg2g/datacenter/layout.py
for_model(*, num_servers, phase_list, rng)
abstractmethod
¶
Create a policy for one model's server pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_servers
|
int
|
Number of physical servers for this model. |
required |
phase_list
|
ndarray
|
Phase assignment per server (0=A, 1=B, 2=C), shape
|
required |
rng
|
Generator
|
RNG for randomized decisions (priority ordering, etc.). Implementations must consume RNG calls deterministically so that downstream layout generation is reproducible. |
required |
Returns:
| Type | Description |
|---|---|
ActivationPolicy
|
Policy that answers |
Source code in openg2g/datacenter/layout.py
RampActivationStrategy
¶
Bases: ActivationStrategy
Activate servers by fixed random priority, following a ServerRampSchedule.
At time t, the top-k servers (by random priority) are active, where
k = round(schedule.fraction_at(t) * num_servers).
This is the default strategy used by OfflineDatacenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
ServerRampSchedule
|
Temporal ramp schedule mapping time to active-server fraction. |
required |
Source code in openg2g/datacenter/layout.py
ServerLayout
dataclass
¶
Per-model server layout describing how GPUs are organized.
Attributes:
| Name | Type | Description |
|---|---|---|
num_servers |
int
|
Number of physical servers for this model. |
total_gpus |
int
|
Total GPU count across all servers. |
gpus_per_replica |
int
|
GPUs per model replica. |
gpus_per_server_list |
ndarray
|
GPU count per server (last may be partial). |
phase_list |
ndarray
|
Phase assignment per server (0=A, 1=B, 2=C). |
activation_policy |
ActivationPolicy
|
Determines which servers are active at time t. |
stagger_offsets |
ndarray
|
Per-server offsets for desynchronization. In offline mode these are integer indices into a power template; in online mode they can be float time offsets into a rolling buffer. |
amplitude_scales |
ndarray
|
Per-server power multiplier for inter-server variation. |
noise_fraction |
float
|
Gaussian noise standard deviation as a fraction of per-server power. |
Source code in openg2g/datacenter/layout.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
build(model_spec, *, gpus_per_server, stagger_range, activation_strategy, amplitude_scale_range, noise_fraction, rng)
classmethod
¶
Build a server layout for one model.
This is a pure function of its inputs (plus RNG state). The caller is responsible for providing a consistently-seeded RNG so that layout generation is reproducible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_spec
|
LLMInferenceModelSpec
|
Model specification (replicas, GPUs per replica, etc.). |
required |
gpus_per_server
|
int
|
Number of GPUs per physical server rack. |
required |
stagger_range
|
int | float
|
Upper bound for per-server stagger offsets. If |
required |
activation_strategy
|
ActivationStrategy
|
Strategy for determining active servers. |
required |
amplitude_scale_range
|
tuple[float, float]
|
|
required |
noise_fraction
|
float
|
Gaussian noise standard deviation as a fraction of per-server power. |
required |
rng
|
Generator
|
Random number generator (consumed for phase assignment, activation policy, stagger offsets, and amplitude scales). |
required |
Returns:
| Type | Description |
|---|---|
ServerLayout
|
Frozen |
Source code in openg2g/datacenter/layout.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
AugmentedPower
dataclass
¶
Result of power augmentation for one simulation timestep.
Attributes:
| Name | Type | Description |
|---|---|---|
power_w |
ThreePhase
|
Three-phase total power (watts), including base load. |
power_by_model_w |
dict[str, float]
|
Per-model total active power (watts). |
active_replicas_by_model |
dict[str, int]
|
Per-model active replica count. |
Source code in openg2g/datacenter/layout.py
PowerAugmenter
¶
Scales per-GPU power through server layouts to three-phase power.
Given per-GPU power values for each server (one value per server per model), applies per-server scaling, noise, activation masking, and phase summation to produce datacenter-level three-phase power.
This class is backend-agnostic. The offline datacenter feeds it template-indexed values; the online datacenter can feed it live-measured values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layouts
|
dict[str, ServerLayout]
|
Per-model server layouts. |
required |
base_w_per_phase
|
float
|
Constant base load per phase (watts). |
0.0
|
seed
|
int
|
Random seed for noise RNG. |
0
|
Source code in openg2g/datacenter/layout.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
step(per_gpu_by_model, t)
¶
Augment per-server per-GPU power to three-phase power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_gpu_by_model
|
dict[str, ndarray]
|
Mapping of model label to per-GPU power
array of shape |
required |
t
|
float
|
Current simulation time (seconds), passed to activation policies. |
required |
Returns:
| Type | Description |
|---|---|
AugmentedPower
|
|
AugmentedPower
|
and per-model active replica counts. |
Source code in openg2g/datacenter/layout.py
openg2g.datacenter.offline
¶
Offline (trace-based) datacenter backend.
Loads power trace CSVs and serves per-timestep OfflineDatacenterState objects via step().
OfflineDatacenterState
dataclass
¶
Bases: LLMDatacenterState
Extended state from the offline (trace-based) backend.
Source code in openg2g/datacenter/offline.py
PowerTrace
dataclass
¶
A single power trace measurement.
Attributes:
| Name | Type | Description |
|---|---|---|
t_s |
ndarray
|
Time vector (seconds), monotonically increasing. |
power_w |
ndarray
|
Total power vector (watts) across all measured GPUs,
same length as |
measured_gpus |
int
|
Number of GPUs used in the measurement. |
Source code in openg2g/datacenter/offline.py
PowerTraceStore
¶
Manages power traces and pre-built per-GPU templates.
Indexed by (model_label, batch_size). Provides:
- load(manifest): load traces discovered via a manifest CSV
- from_traces(traces): construct from pre-built PowerTrace objects
- build_templates(...): pre-build per-GPU power templates
- template(model_label, batch_size): look up a pre-built template
- trace(model_label, batch_size): access the raw trace
Attributes:
| Name | Type | Description |
|---|---|---|
MANIFEST_COL_MODEL_LABEL |
Column name for model label in the manifest. |
|
MANIFEST_COL_NUM_GPUS |
Column name for measured GPU count in the manifest. |
|
MANIFEST_COL_BATCH_SIZE |
Column name for batch size in the manifest. |
|
MANIFEST_COL_TRACE_FILE |
Column name for trace file path in the manifest. |
|
TRACE_COL_TIME |
Column name for time in trace CSVs. |
|
TRACE_COL_POWER |
Column name for power in trace CSVs. |
Source code in openg2g/datacenter/offline.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
model_labels
property
¶
List of model labels in the store.
load(manifest)
classmethod
¶
Load traces discovered via a manifest CSV.
Trace file paths in the manifest are resolved relative to the manifest file's parent directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
Path
|
Path to the manifest CSV (e.g. |
required |
Source code in openg2g/datacenter/offline.py
from_traces(traces)
classmethod
¶
Construct from pre-built PowerTrace objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
dict[str, dict[int, PowerTrace]]
|
Mapping of |
required |
Source code in openg2g/datacenter/offline.py
trace(model_label, batch_size)
¶
Return the raw power trace for a model and batch size.
Source code in openg2g/datacenter/offline.py
build_templates(*, duration_s, timestep_s, steady_skip_s=0.0)
¶
Pre-build per-GPU power templates for all traces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration_s
|
Fraction | float
|
Total simulation duration (seconds). |
required |
timestep_s
|
Fraction | float
|
Simulation timestep (seconds). |
required |
steady_skip_s
|
float
|
Skip this many seconds from the start of each trace to avoid warm-up transients. |
0.0
|
Source code in openg2g/datacenter/offline.py
template(model_label, batch_size)
¶
Return a pre-built per-GPU power template.
Requires a prior call to build_templates.
Source code in openg2g/datacenter/offline.py
batch_sizes(model_label)
¶
List of batch sizes available for a model.
Source code in openg2g/datacenter/offline.py
OfflineDatacenter
¶
Bases: LLMBatchSizeControlledDatacenter[OfflineDatacenterState]
Trace-based datacenter simulation with step-by-step interface.
Each step() call computes one timestep of power output by indexing
into pre-built per-GPU templates, applying per-server amplitude scaling
and noise, and summing across active servers per phase.
Batch size changes via apply_control() take effect on the next
step() call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_store
|
PowerTraceStore
|
|
required |
models
|
list[LLMInferenceModelSpec]
|
List of model specs describing the served models. |
required |
timestep_s
|
Fraction
|
Simulation timestep (seconds). |
required |
gpus_per_server
|
int
|
Number of GPUs per physical server rack. |
8
|
seed
|
int
|
Random seed for layout generation and noise. |
0
|
amplitude_scale_range
|
tuple[float, float]
|
|
(1.0, 1.0)
|
noise_fraction
|
float
|
Gaussian noise standard deviation as a fraction of per-server power. |
0.0
|
activation_strategy
|
ActivationStrategy | None
|
Controls which servers are active at each
timestep. Subclass |
None
|
base_kw_per_phase
|
float
|
Constant base load per phase (kW). |
0.0
|
training_overlays
|
list[tuple[TrainingOverlayCache, TrainingRun]] | None
|
List of |
None
|
itl_distributions
|
dict[str, dict[int, ITLMixtureModel]] | None
|
Optional per-model ITL mixture distributions:
|
None
|
latency_exact_threshold
|
int
|
Exact-sampling threshold for latency averaging. |
30
|
latency_seed
|
int | None
|
Optional seed for latency RNG. Defaults to |
None
|
Source code in openg2g/datacenter/offline.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
phase_share_by_model
property
¶
Per-model phase share vectors derived from server placement.
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Mapping of model label to a 3-element array |
dict[str, ndarray]
|
representing the fraction of servers on each phase. |
apply_control(command)
¶
Apply a control command. Dispatches on command type.
from_config(datacenter, workload, *, trace_store, timestep_s, seed=0, amplitude_scale_range=(1.0, 1.0), noise_fraction=0.0, itl_distributions=None, latency_seed=None, latency_exact_threshold=30)
classmethod
¶
Create an OfflineDatacenter from config objects.
If workload.server_ramps is set, it is wrapped in a
RampActivationStrategy. For custom activation strategies,
use the direct constructor with activation_strategy=.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datacenter
|
DatacenterConfig
|
Facility configuration (GPUs per server, base load). |
required |
workload
|
WorkloadConfig
|
Workload configuration (inference models, training, ramps). |
required |
trace_store
|
PowerTraceStore
|
Power trace store with templates for all (model, batch). |
required |
timestep_s
|
Fraction
|
Simulation timestep (seconds). |
required |
seed
|
int
|
Random seed for layout generation and noise. |
0
|
amplitude_scale_range
|
tuple[float, float]
|
|
(1.0, 1.0)
|
noise_fraction
|
float
|
Noise std as fraction of per-server power. |
0.0
|
itl_distributions
|
dict[str, dict[int, ITLMixtureModel]] | None
|
Optional per-model ITL mixture distributions. |
None
|
latency_seed
|
int | None
|
Optional seed for latency RNG. |
None
|
latency_exact_threshold
|
int
|
Exact-sampling threshold for latency averaging. |
30
|
Source code in openg2g/datacenter/offline.py
batch_sizes(model_label)
¶
start()
¶
Acquire per-run resources (threads, solver circuits).
Called after reset(), before the simulation loop. Override for
backends that need resource acquisition (e.g., OpenDSSGrid
compiles its DSS circuit here). No-op by default because most
offline components have no resources to acquire.
Source code in openg2g/datacenter/base.py
stop()
¶
Release per-run resources. Simulation state is preserved.
Called after the simulation loop in LIFO order. Override for
backends that acquired resources in start(). No-op by default.
openg2g.datacenter.online
¶
Online (live GPU) datacenter backend with power augmentation.
Connects to real vLLM inference servers for load generation and ITL
measurement, and to zeusd instances for live GPU power monitoring.
Power readings from a small number of real GPUs are augmented to
datacenter scale using the shared PowerAugmenter pipeline from
openg2g.datacenter.layout.
Requires pip install zeus aiohttp.
OnlineDatacenterState
dataclass
¶
Bases: LLMDatacenterState
Extended state from the online (live GPU) backend.
The base power_w field carries the augmented three-phase power
(what the grid sees). This subclass adds the measured (pre-augmentation)
breakdown for post-hoc analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
measured_power_w |
ThreePhase
|
Total measured three-phase power from real GPUs (before augmentation), plus base load. |
measured_power_w_by_model |
dict[str, float]
|
Per-model total measured power from real GPUs (watts). |
augmented_power_w_by_model |
dict[str, float]
|
Per-model augmented power (watts). This is the power fed to the grid for each model after scaling up. |
augmentation_factor_by_model |
dict[str, float]
|
Per-model augmentation multiplier (virtual replicas / real replicas). |
prometheus_metrics_by_model |
dict[str, dict[str, float]]
|
Per-model Prometheus metrics snapshot.
Keys are model labels, values are dicts with metric names like
|
Source code in openg2g/datacenter/online.py
GPUEndpointMapping
dataclass
¶
Maps a zeusd endpoint to specific GPUs on a specific electrical phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Hostname or IP of the zeusd instance. |
required |
port
|
int
|
TCP port of the zeusd instance. |
4938
|
gpu_indices
|
tuple[int, ...]
|
GPU device indices to monitor on this endpoint. |
(0,)
|
phase
|
Phase
|
Electrical phase this endpoint's GPUs are connected to. |
A
|
Source code in openg2g/datacenter/online.py
endpoint_key
property
¶
Return the host:port key used by PowerStreamingClient.
OnlineModelDeployment
dataclass
¶
Deployment of one model on physical hardware.
Pairs a reusable LLMInferenceModelSpec with physical deployment
details. spec.num_replicas is the simulated (augmented) count
for grid simulation. The real replica count is derived from
gpu_endpoints and spec.gpus_per_replica.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
LLMInferenceModelSpec
|
Model specification (shared with offline datacenter). |
required |
vllm_base_url
|
str
|
Base URL of the vLLM server (e.g. |
required |
model_name
|
str
|
OpenAI API model name served by vLLM. |
required |
gpu_endpoints
|
tuple[GPUEndpointMapping, ...]
|
GPU endpoint mappings for power monitoring. |
()
|
Source code in openg2g/datacenter/online.py
LoadGenerationConfig
dataclass
¶
Configuration for the request load generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_output_tokens
|
int
|
Maximum output tokens per request. |
512
|
concurrency_multiplier
|
float
|
Number of concurrent requests per unit
of batch size ( |
3.0
|
itl_window_s
|
float
|
Seconds of ITL history to average over. |
1.0
|
Source code in openg2g/datacenter/online.py
PowerAugmentationConfig
dataclass
¶
Configuration for scaling real GPU power to datacenter level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_kw_per_phase
|
float
|
Constant base load per electrical phase (kW). |
0.0
|
noise_fraction
|
float
|
Gaussian noise standard deviation as a fraction
of per-server power. Applied per-server by the shared
|
0.02
|
stagger_buffer_s
|
float
|
Seconds of power history for temporal staggering.
Also used as the stagger range when building |
10.0
|
gpus_per_server
|
int
|
Number of GPUs per virtual server for layout computation. |
8
|
amplitude_scale_range
|
tuple[float, float]
|
|
(0.9, 1.1)
|
seed
|
int
|
Random seed for layout generation and noise. |
0
|
Source code in openg2g/datacenter/online.py
OnlineDatacenter
¶
Bases: LLMBatchSizeControlledDatacenter[OnlineDatacenterState]
Live GPU datacenter backend with power augmentation.
Dispatches inference load to vLLM servers, streams GPU power from
zeusd, measures ITL from streaming responses, and augments power
readings to datacenter scale using the shared PowerAugmenter
pipeline (same as OfflineDatacenter).
Call start() before the first step() and stop() after the
simulation loop finishes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployments
|
Sequence[OnlineModelDeployment]
|
List of model deployments with physical hardware mapping. |
required |
power_client
|
PowerStreamingClient
|
Zeus |
required |
augmentation
|
PowerAugmentationConfig | None
|
Power augmentation configuration. |
None
|
load_gen
|
LoadGenerationConfig | None
|
Load generation configuration. |
None
|
requests_by_model
|
dict[str, list[dict]]
|
Mapping of model_label -> list of pre-built
OpenAI Chat Completion request dicts (from |
required |
dt_s
|
Fraction
|
Simulation timestep (seconds). |
Fraction(1, 10)
|
activation_strategy
|
ActivationStrategy | None
|
Controls which virtual servers are active at
each timestep. If |
None
|
prometheus_poll_interval_s
|
float
|
How often to poll vLLM /metrics (seconds). Set to 0 to disable Prometheus polling. |
0.5
|
health_check
|
bool
|
If True, run health checks on start(). |
True
|
Source code in openg2g/datacenter/online.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | |
phase_share_by_model
property
¶
Per-model phase share vectors derived from server layout.
start()
¶
Start load generation, warm up servers, and fill the power buffer.
Sequence
- Run health checks on all vLLM servers and zeusd instances.
- Wait for at least one power reading per endpoint (10 s timeout).
- Set initial batch sizes on all vLLM servers.
- Start load generation threads.
- Warm up: poll power into the rolling buffer while waiting for
each model's
num_requests_runningto reach 95% of itsinitial_batch_size. Fails after 60 s if any model does not saturate.
Source code in openg2g/datacenter/online.py
stop()
¶
step(clock)
¶
Read live power, augment to datacenter scale, and return state.
Source code in openg2g/datacenter/online.py
apply_control(command)
¶
Apply a control command. Dispatches on command type.
openg2g.datacenter.training_overlay
¶
Training workload overlay: typed trace data and periodic overlay evaluation.
TrainingTrace
dataclass
¶
A single-GPU training power trace.
Attributes:
| Name | Type | Description |
|---|---|---|
t_s |
ndarray
|
Time vector (seconds), monotonically increasing. |
power_w |
ndarray
|
Power vector (watts) for one GPU, same length as |
Source code in openg2g/datacenter/training_overlay.py
load(csv_path)
classmethod
¶
Load a training trace from CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
Path
|
Path to CSV with columns |
required |
Source code in openg2g/datacenter/training_overlay.py
TrainingOverlayCache
¶
Rescales a training trace and provides periodic overlay evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
TrainingTrace
|
Single-GPU training power trace. |
required |
target_peak_W_per_gpu
|
float
|
The trace is rescaled so its peak equals this value. |
required |
Source code in openg2g/datacenter/training_overlay.py
eval_total_on_grid(t_global_s, *, t_add_start, t_add_end, n_train_gpus)
¶
Evaluate total training power overlay on a time grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_global_s
|
ndarray
|
Global simulation time stamps (seconds). |
required |
t_add_start
|
float
|
Global time when training becomes active. |
required |
t_add_end
|
float
|
Global time when training stops. |
required |
n_train_gpus
|
int
|
Number of GPUs running the training workload. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Total training power (W) at each time step. |