openg2g.metrics¶
openg2g.metrics.performance
¶
Inference performance metrics: throughput and latency (ITL).
Companion to VoltageStats. Where
voltage metrics capture grid-side quality, these metrics capture
datacenter-side quality of service -- how many tokens per second the
fleet serves and how often observed inter-token latency crossed each
model's deadline.
PerformanceStats
dataclass
¶
Summary throughput and ITL statistics over a simulation run.
Throughput is derived per step from the observed ITL:
tokens/s_per_replica = batch_size / observed_itl_s, then summed
across active replicas. This uses the simulator's sampled ITL rather
than a fitted curve, so it reflects the actual latency realised in
the run.
Attributes:
| Name | Type | Description |
|---|---|---|
mean_throughput_tps |
float
|
Time-averaged total throughput across all models and sites (tokens/s). |
integrated_throughput_tokens |
float
|
Total tokens produced over the run (tokens). |
throughput_by_model_tps |
dict[str, float]
|
Per-model mean throughput (tokens/s). |
mean_batch_by_model |
dict[str, float]
|
Per-model mean batch size. |
mean_replicas_by_model |
dict[str, float]
|
Per-model mean active replica count. |
mean_itl_s_by_model |
dict[str, float]
|
Per-model mean observed ITL (seconds). |
itl_deadline_fraction |
float
|
Fraction of (timestep, model) samples where observed ITL exceeded the model's deadline, across all models. |
itl_deadline_fraction_by_model |
dict[str, float]
|
Same fraction, per model. |
Source code in openg2g/metrics/performance.py
compute_performance_stats(dc_states, *, itl_deadline_s_by_model)
¶
Compute throughput and ITL statistics from datacenter state snapshots.
Per-replica throughput is estimated as batch / observed_itl_s
(tokens/s). Total throughput at each step is the sum across models
and sites of throughput_per_replica * active_replicas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dc_states
|
list[LLMDatacenterState]
|
All datacenter state snapshots (flat across sites).
Typically |
required |
itl_deadline_s_by_model
|
dict[str, float]
|
Per-model ITL deadline (seconds). A sample counts as a deadline miss when observed ITL > this. |
required |
Returns:
| Type | Description |
|---|---|
PerformanceStats
|
A [ |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in openg2g/metrics/performance.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 | |
openg2g.metrics.voltage
¶
Voltage violation metrics for all-bus, all-phase analysis.
VoltageStats
dataclass
¶
Summary voltage statistics over a simulation run.
Attributes:
| Name | Type | Description |
|---|---|---|
worst_vmin |
float
|
Lowest voltage observed across all buses and phases (pu). |
worst_vmax |
float
|
Highest voltage observed across all buses and phases (pu). |
violation_time_s |
float
|
Total time with at least one bus-phase violating voltage bounds (seconds). |
integral_violation_pu_s |
float
|
Integrated voltage violation magnitude across all bus-phase pairs (pu * s). |
Source code in openg2g/metrics/voltage.py
compute_allbus_voltage_stats(grid_states, *, v_min=0.95, v_max=1.05, exclude_buses=())
¶
Compute voltage violation statistics across all buses and phases.
For each snapshot the integral violation sums
max(v_min - v, 0) + max(v - v_max, 0) over every non-excluded
bus-phase pair, then integrates over time. A snapshot counts as
"violated" when this sum is positive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_states
|
list[GridState]
|
Sequence of |
required |
v_min
|
float
|
Lower voltage bound (pu). |
0.95
|
v_max
|
float
|
Upper voltage bound (pu). |
1.05
|
exclude_buses
|
tuple[str, ...]
|
Bus names to exclude from statistics (case-insensitive). |
()
|