Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/powerx-system-power.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ supported air-cooled chassis).
port to the pinned revision: every upstream module has a counterpart and no
module lacks one, and the port reproduces the upstream model's own output to a
relative 1e-12 for every catalog system, workload state, scale-out flag, a
sweep of GPU watts and Grace-socket inputs, and every rejection (component
sweep of GPU watts, Grace-socket and x86 CPU socket inputs, and every rejection (component
trees, provenance and configuration included). Numerical parity establishes
implementation equivalence, not empirical chassis calibration.

The port accepts both per-socket inputs for HGX and rack-scale systems. A CPU-and-DRAM
input replaces modeled CPU and memory power; a CPU-only input replaces modeled CPU
power and leaves memory modeled. When both are supplied, HGX uses CPU-only and
rack-scale systems use CPU-and-DRAM. Today, CPU-and-DRAM telemetry is available
only for rack-scale Grace sockets. The CPU-only RAPL source is on HGX and has not
had a hardware run yet.
The dashboard still passes only the validated Grace socket input.

## Operating state

The upstream model takes a workload state and a scale-out flag. `modelSystemPower`
Expand Down Expand Up @@ -366,8 +374,13 @@ dropping that replicate.
再修改 `generate-power-model-parity.py` 中固定的 InferenceX commit,用装有 pydantic 2
的 Python 3.12+ 运行脚本并指向本地 InferenceX 仓库。脚本用 `git archive` 取出该 commit
的 `power_model`,写出上游模块清单和上游模型自身的输出;`power-model-parity.test.ts`
检查模块一一对应,并要求移植版本在全部系统、运行状态、GPU 功耗和 Grace socket 输入以及
检查模块一一对应,并要求移植版本在全部系统、运行状态、GPU 功耗、Grace socket 和 x86 CPU socket 输入以及
所有报错情况下与上游结果一致(相对误差 1e-12)。同一 commit 重复运行,输出逐字节相同。
移植层的 HGX 和 rack-scale 系统都支持两种每 socket 输入:CPU+DRAM 输入替换建模的
CPU 和内存功耗,CPU-only 输入仅替换 CPU 功耗。两种输入同时提供时,HGX 优先使用
CPU-only,rack-scale 优先使用 CPU+DRAM。目前 CPU+DRAM 遥测只来自 rack-scale
Grace socket;CPU-only 的 RAPL 来源在 HGX,但尚未进行真机运行。仪表板仍仅传入已验证的
Grace socket 指标。
通过一致性及准入测试后部署,刷新浏览器,并使派生 API 缓存失效或等待其过期。
冻结的 CSV/JSON 需另行导出。通常无需逐 run 回填数据库;若新模型需要历史记录中
没有的输入,应保留不可用状态,也不能把新一轮测得的功耗配到旧吞吐结果上。
Expand Down
113 changes: 76 additions & 37 deletions packages/app/scripts/generate-power-model-parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
- power-model.manifest.json: the revision, its source tree, and every upstream
Python module, which power-model-parity.test.ts maps one-to-one onto the port.
- power-model.parity.json: the upstream model's own output for every catalog
system, workload, scale-out state, measured Grace-socket input, and a sweep of
GPU watts (including out-of-domain inputs and their errors), plus seeded random
GPU and socket watts for every system.
system, workload, scale-out state, measured Grace-socket or x86 CPU input, and a
sweep of GPU watts (including out-of-domain inputs and their errors), plus seeded
random GPU and socket watts for every system.
Output is byte-stable across reruns.
"""

Expand All @@ -30,8 +30,7 @@
import tempfile

sys.dont_write_bytecode = True
# InferenceX #3887 merge commit: the measured Grace-socket input landed here.
REVISION = "1e509932e09f2382f778d0e793893b534b02737b"
REVISION = "5cfc833db4fd1a4eba2937c776a4ffef224a7ed0"
SOURCE_PATH = "power_model"
PACKAGE_PATH = "power_model/src/power_model"
SOURCE_URL = f"https://github.com/SemiAnalysisAI/InferenceX/tree/{REVISION}/{SOURCE_PATH}"
Expand All @@ -57,18 +56,20 @@
CLUSTER_WATTS = (700.0, 1440.0)
# None models Grace; 98.066 W is a measured GB300 NVL72 replay mean.
RACK_SOCKET_WATTS = (None, 0.0, 98.066, 250.0, 500.0)
# None models the x86 CPU; 180 W per package is the upstream CLI test's input.
CHASSIS_CPU_WATTS = (None, 0.0, 180.0, 400.0)
# Full component trees (with provenance and configuration) for these GPU watts.
DETAIL_WATTS = (0.0, 612.375)
SUMMARY_KEYS = ("it_power_w", "facility_overhead_w", "facility_power_w", "AllInPower_per_gpu")
# Seeded random inputs beyond the grid, drawn like the 2026-10 differential fuzz.
FUZZ_SEED = 20261012
FUZZ_CASES = 240
REPORT_CASES = (
("hopper", "agentic", True, 4, 700.0, None),
("b300", "agentic-cpu-offloading", False, 1, 1000.0, None),
("mi355", "fixed-seq-len", True, 1, 1200.0, None),
("gb200-nvl72", "agentic", True, 1, 1000.0, None),
("gb300-nvl72", "fixed-seq-len", False, 4, 1200.0, 98.066),
("hopper", "agentic", True, 4, 700.0, None, None),
("b300", "agentic-cpu-offloading", False, 1, 1000.0, None, None),
("mi355", "fixed-seq-len", True, 1, 1200.0, None, 180.0),
("gb200-nvl72", "agentic", True, 1, 1000.0, None, None),
("gb300-nvl72", "fixed-seq-len", False, 4, 1200.0, 98.066, None),
)


Expand Down Expand Up @@ -142,48 +143,62 @@ def totals(node):
]


def evaluate(create, model, system, workload, scale_out, systems, gpu_watts, socket_watts):
def evaluate(
create, model, system, workload, scale_out, systems, gpu_watts, socket_watts, cpu_watts
):
try:
estimate = create(
system=system,
model=model,
workload_state=workload,
using_scale_out=scale_out,
systems=systems,
).estimate_breakdown(gpu_watts, cpu_and_dram_measured_power_per_socket=socket_watts)
).estimate_breakdown(
gpu_watts,
cpu_and_dram_measured_power_per_socket=socket_watts,
cpu_measured_power_per_socket=cpu_watts,
)
except ValueError as error:
return None, error_of(error)
return estimate, None


def grid():
"""(system, workload, scale_out, systems, gpu_watts, socket_watts, detail) inputs."""
"""(system, workload, scale_out, systems, gpu_watts, socket_watts, cpu_watts, detail)."""
from power_model.models.advanced.systems.catalog import SYSTEMS

for system, system_class in SYSTEMS.items():
rack = system_class.has_grace_sockets
# A rack measures its Grace sockets, a chassis its x86 CPU packages; the dense
# value is swept across every GPU watt.
measured, dense = (RACK_SOCKET_WATTS, 98.066) if rack else (CHASSIS_CPU_WATTS, 180.0)
inputs = (lambda watts: (watts, None)) if rack else (lambda watts: (None, watts))
for workload, scale_out in itertools.product(WORKLOADS, SCALE_OUT):
if rack and workload == "idle":
# Grace has no idle profile: one modeled and one measured rejection suffice.
for gpu_watts, socket_watts in ((700.0, None), (700.0, 98.066)):
yield system, workload, scale_out, 1, gpu_watts, socket_watts, False
yield system, workload, scale_out, 1, gpu_watts, socket_watts, None, False
continue
for gpu_watts in GPU_WATTS:
for socket_watts in RACK_SOCKET_WATTS if rack else (None,):
if socket_watts not in (None, 98.066) and gpu_watts not in SPARSE_WATTS:
for watts in measured:
if watts not in (None, dense) and gpu_watts not in SPARSE_WATTS:
continue
detail = gpu_watts in DETAIL_WATTS and socket_watts in (None, 98.066)
yield system, workload, scale_out, 1, gpu_watts, socket_watts, detail
detail = gpu_watts in DETAIL_WATTS and watts in (None, dense)
yield system, workload, scale_out, 1, gpu_watts, *inputs(watts), detail
for gpu_watts in CLUSTER_WATTS:
for socket_watts in (None, 98.066) if rack else (None,):
yield system, workload, scale_out, 4, gpu_watts, socket_watts, False
if not rack:
# A chassis has no Grace socket to measure.
yield system, workload, scale_out, 1, 700.0, 100.0, False
for watts in (None, dense):
yield system, workload, scale_out, 4, gpu_watts, *inputs(watts), False
# Exercise the alternate input and both-input precedence on each family.
if rack:
yield system, workload, scale_out, 1, 700.0, None, 180.0, False
else:
yield system, workload, scale_out, 1, 700.0, 100.0, None, False
yield system, workload, scale_out, 1, 700.0, None, -1.0, False
yield system, workload, scale_out, 1, 700.0, 98.066, 180.0, False


def fuzz():
"""Random (system, workload, scale_out, systems, gpu_watts, socket_watts, False) inputs."""
"""Random grid-shaped inputs; a measured input matches the system's CPU family."""
import random

from power_model.models.advanced.systems.catalog import SYSTEMS
Expand All @@ -193,21 +208,30 @@ def fuzz():
for _ in range(FUZZ_CASES):
system = rng.choice(names)
gpu_watts = rng.uniform(0.0, 2000.0 if rng.random() < 0.8 else 40000.0)
measured = SYSTEMS[system].has_grace_sockets and rng.random() < 0.6
socket_watts = rng.uniform(0.0, 1500.0) if measured else None
watts = rng.uniform(0.0, 1500.0) if rng.random() < 0.6 else None
rack = SYSTEMS[system].has_grace_sockets
socket_watts, cpu_watts = (watts, None) if rack else (None, watts)
workload, scale_out, systems = rng.choice(WORKLOADS), rng.random() < 0.5, rng.randint(1, 8)
yield system, workload, scale_out, systems, gpu_watts, socket_watts, False
yield system, workload, scale_out, systems, gpu_watts, socket_watts, cpu_watts, False


def cases(provenance, configuration):
from power_model import create_power_model

out = []
for system, workload, scale_out, systems, gpu_watts, socket_watts, detail in itertools.chain(
grid(), fuzz()
):
for (
system, workload, scale_out, systems, gpu_watts, socket_watts, cpu_watts, detail
) in itertools.chain(grid(), fuzz()):
estimate, error = evaluate(
create_power_model, "oss", system, workload, scale_out, systems, gpu_watts, socket_watts
create_power_model,
"oss",
system,
workload,
scale_out,
systems,
gpu_watts,
socket_watts,
cpu_watts,
)
case = {
"model": "oss",
Expand All @@ -217,6 +241,7 @@ def cases(provenance, configuration):
"systems": systems,
"gpu_level_power_per_gpu": gpu_watts,
"cpu_and_dram_measured_power_per_socket": socket_watts,
"cpu_measured_power_per_socket": cpu_watts,
}
if error:
case["error"] = error
Expand All @@ -236,12 +261,20 @@ def cases(provenance, configuration):
],
}
out.append(case)
# The one-GPU example model: every workload, with and without a socket input.
for system, workload, socket_watts in itertools.product(
("hopper", "gb200-nvl72"), WORKLOADS, (None, 100.0)
# The one-GPU example model: every workload, without and with each measured input.
for system, workload, (socket_watts, cpu_watts) in itertools.product(
("hopper", "gb200-nvl72"), WORKLOADS, ((None, None), (100.0, None), (None, 180.0))
):
estimate, error = evaluate(
create_power_model, "example", system, workload, False, 1, 700.0, socket_watts
create_power_model,
"example",
system,
workload,
False,
1,
700.0,
socket_watts,
cpu_watts,
)
case = {
"model": "example",
Expand All @@ -251,6 +284,7 @@ def cases(provenance, configuration):
"systems": 1,
"gpu_level_power_per_gpu": 700.0,
"cpu_and_dram_measured_power_per_socket": socket_watts,
"cpu_measured_power_per_socket": cpu_watts,
}
if error:
case["error"] = error
Expand All @@ -269,10 +303,14 @@ def reports():
from power_model.reporting import format_power_breakdown_per_chassis

out = []
for system, workload, scale_out, systems, gpu_watts, socket_watts in REPORT_CASES:
for system, workload, scale_out, systems, gpu_watts, socket_watts, cpu_watts in REPORT_CASES:
estimate = create_power_model(
system=system, workload_state=workload, using_scale_out=scale_out, systems=systems
).estimate_breakdown(gpu_watts, cpu_and_dram_measured_power_per_socket=socket_watts)
).estimate_breakdown(
gpu_watts,
cpu_and_dram_measured_power_per_socket=socket_watts,
cpu_measured_power_per_socket=cpu_watts,
)
out.append(
{
"system": system,
Expand All @@ -281,6 +319,7 @@ def reports():
"systems": systems,
"gpu_level_power_per_gpu": gpu_watts,
"cpu_and_dram_measured_power_per_socket": socket_watts,
"cpu_measured_power_per_socket": cpu_watts,
"text": format_power_breakdown_per_chassis(estimate),
}
)
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/lib/power/power-model-parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface ParityCase {
systems: number;
gpu_level_power_per_gpu: number;
cpu_and_dram_measured_power_per_socket: number | null;
cpu_measured_power_per_socket: number | null;
error?: { kind: 'validation' | 'value'; message: string | null };
estimate?: Record<string, JsonValue> & { components: CompactNode[] };
summary?: Record<string, number | number[]> & { component_power_w: number[] };
Expand All @@ -49,6 +50,7 @@ interface ParityReport {
systems: number;
gpu_level_power_per_gpu: number;
cpu_and_dram_measured_power_per_socket: number | null;
cpu_measured_power_per_socket: number | null;
text: string;
}

Expand Down Expand Up @@ -131,6 +133,7 @@ function run(testCase: ParityCase): PowerEstimate {
systems: testCase.systems,
}).estimate_breakdown(testCase.gpu_level_power_per_gpu, {
cpu_and_dram_measured_power_per_socket: testCase.cpu_and_dram_measured_power_per_socket,
cpu_measured_power_per_socket: testCase.cpu_measured_power_per_socket,
});
}

Expand All @@ -143,6 +146,7 @@ function label(testCase: ParityCase): string {
`x${testCase.systems}`,
`${testCase.gpu_level_power_per_gpu}W`,
`socket=${testCase.cpu_and_dram_measured_power_per_socket ?? 'modeled'}`,
`cpu=${testCase.cpu_measured_power_per_socket ?? 'modeled'}`,
].join(' ');
}

Expand Down Expand Up @@ -191,6 +195,12 @@ describe('power model port: upstream parity', () => {
expect(cases.some((c) => c.error?.kind === 'value')).toBe(true);
});

it('covers estimates from both measured CPU inputs', () => {
const estimated = cases.filter((c) => !c.error);
expect(estimated.some((c) => c.cpu_and_dram_measured_power_per_socket !== null)).toBe(true);
expect(estimated.some((c) => c.cpu_measured_power_per_socket !== null)).toBe(true);
});

it.each(cases.map((testCase) => [label(testCase), testCase] as const))('%s', (_, testCase) => {
if (testCase.error) {
const { kind, message } = testCase.error;
Expand Down Expand Up @@ -227,6 +237,7 @@ describe('power model port: per-system report', () => {
systems: report.systems,
}).estimate_breakdown(report.gpu_level_power_per_gpu, {
cpu_and_dram_measured_power_per_socket: report.cpu_and_dram_measured_power_per_socket,
cpu_measured_power_per_socket: report.cpu_measured_power_per_socket,
});
expect(format_power_breakdown_per_chassis(estimate)).toBe(report.text);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/lib/power/power-model.manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modelRevision": "1e509932e09f2382f778d0e793893b534b02737b",
"sourceTree": "42225371bbd318dbf33127c43688ced65c6ef175",
"sourceUrl": "https://github.com/SemiAnalysisAI/InferenceX/tree/1e509932e09f2382f778d0e793893b534b02737b/power_model",
"modelRevision": "5cfc833db4fd1a4eba2937c776a4ffef224a7ed0",
"sourceTree": "ceec5a03233f1f60c5d471988e31fc078d05ae09",
"sourceUrl": "https://github.com/SemiAnalysisAI/InferenceX/tree/5cfc833db4fd1a4eba2937c776a4ffef224a7ed0/power_model",
"packagePath": "power_model/src/power_model",
"pythonFiles": [
"__init__.py",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/lib/power/power-model.parity.json

Large diffs are not rendered by default.

Loading
Loading