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
11 changes: 11 additions & 0 deletions docs/powerx-permanent-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ link still opens that view for locked visitors.
in the label), with a CSV button (`source` column: official / unofficial) and one example
sentence read from the official points. The views API serves the official rows with
`headroom=true`.
- **Sizing to measured power** (under the headroom table): `PowerXGwSizing` reads each line's
P90 W at one interactivity (`i_szat`, default 150 tok/s/user, presets 25 / 50 / 100 / 150 / 300) through `lib/power/gw-sizing.ts` (`buildHeadroomRows` at that one interactivity, so the
reading matches the table) and sizes a gigawatt of GPU power at P90 × (1 + headroom)
(`i_szhr`, default 10 %, slider 0 to 60 %) against 1 GW ÷ TDP. Left: one bar per line with
the gain and the GPU counts, overlay lines in their run color. Right: the picked line's
GPUs per GW over headroom (`i_szgpu`, click a bar; GB300 NVL72 by default), the rating as a
dashed line and the break-even headroom TDP ÷ P90 − 1 as an open dot. Read at presets no line covers are
disabled; a share-link pick no line covers reads at the nearest covered preset (log scale)
with a note, without rewriting `i_szat`. Lines left out at the Read at are named under the
controls, and the headline counts the lines that gain nothing at the chosen headroom. The views API serves
the official rows with `sizing=true` (`sizingAt`, `sizingHeadroom`).
- **Load swings** (Over Time, PowerX only): `PowerLoadSwings` computes
`lib/power/load-swing-stats.ts` per visible trace (peak, min, idle floor = P5 before the
window, window mean, P5/P95, max Δ1s / Δ5s in W and % TDP, ramp up/down W/s, volatility =
Expand Down
5 changes: 5 additions & 0 deletions docs/state-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ tok/s/user), owned by `PowerXSurfaceProvider` context: read once on mount, writt
`writeUrlParams` on an explicit pick, and moving it clears every pin. See
[PowerX Permanent View](./powerx-permanent-view.md#powerx-layout).

`i_szat`, `i_szhr` and `i_szgpu` (inference scope, default `''`: 150 tok/s/user, 10 %
headroom, GB300 NVL72 or the top row) are the Sizing to measured power panel's Read at,
headroom and picked line, owned by `PowerXGwSizing` component state: read once on mount and
written through `writeUrlParams` on each change.

### Staged-result chart links

The staging workflow reads the successfully ingested run's model, workload,
Expand Down
60 changes: 60 additions & 0 deletions packages/app/src/app/api/v1/views/inference/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,66 @@ describe('GET /api/v1/views/inference', () => {
expect(csv.status).toBe(400);
});

it('sizes a gigawatt to measured P90 power plus headroom and omits lines off the range', async () => {
// B200 covers 150 tok/s/user at 720 W P90; H200 stops at 120.
const sweep = [
{ hardware: 'b200', conc: 64, interactivity: 60, tput: 2400, avg: 800, p90: 880 },
{ hardware: 'b200', conc: 16, interactivity: 150, tput: 1200, avg: 650, p90: 720 },
{ hardware: 'b200', conc: 4, interactivity: 320, tput: 500, avg: 500, p90: 560 },
{ hardware: 'h200', conc: 32, interactivity: 40, tput: 1500, avg: 600, p90: 650 },
{ hardware: 'h200', conc: 8, interactivity: 120, tput: 700, avg: 450, p90: 520 },
];
mockGetLatestBenchmarks.mockResolvedValue(
sweep.map(({ hardware, conc, interactivity, tput, avg, p90 }, index) =>
makeRow({
id: 500 + index,
hardware,
conc,
metrics: {
...makeRow().metrics,
median_intvty: interactivity,
tput_per_gpu: tput,
avg_power_w: avg,
p90_power_w: p90,
avg_total_gpu_power_w: avg * 8,
power_valid: 1,
power_metric_schema_version: 2,
},
}),
),
);
const res = await GET(
request(
'/api/v1/views/inference?model=DeepSeek-R1-0528&metric=measuredPowerPercentTdp&sizing=true&sizingHeadroom=25',
),
);
expect(res.status).toBe(200);
const body = await res.json();
expect(body.params).toMatchObject({ sizing: true, sizingAt: 150, sizingHeadroom: 25 });
expect(body.sizing).toMatchObject({ interactivity: 150, headroomPercent: 25 });
expect(body.sizing.rows).toHaveLength(1);
const [b200] = body.sizing.rows;
expect(b200).toMatchObject({ hwKey: 'b200_trt', tdpWatts: 1000, gpusPerGwAtRating: 1e6 });
expect(b200.p90Watts).toBeCloseTo(720, 6);
expect(b200.gpusPerGw).toBeCloseTo(1e9 / (720 * 1.25), 3);
expect(b200.gainPercent).toBeCloseTo((1000 / 900 - 1) * 100, 6);
expect(b200.breakEvenHeadroomPercent).toBeCloseTo((1000 / 720 - 1) * 100, 6);
const offResponse = await GET(
request('/api/v1/views/inference?model=DeepSeek-R1-0528&metric=tpPerGpu'),
);
const off = await offResponse.json();
expect(off).not.toHaveProperty('sizing');
expect(off.params).toMatchObject({ sizing: false, sizingAt: null, sizingHeadroom: null });
const csv = await GET(
request('/api/v1/views/inference?model=DeepSeek-R1-0528&sizing=true&format=csv'),
);
expect(csv.status).toBe(400);
const bad = await GET(
request('/api/v1/views/inference?model=DeepSeek-R1-0528&sizing=true&sizingHeadroom=-5'),
);
expect(bad.status).toBe(400);
});

it('canonicalizes list params and applies quick filters', async () => {
const res = await GET(
request(
Expand Down
44 changes: 42 additions & 2 deletions packages/app/src/app/api/v1/views/inference/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ import {
PERCENTILE_OPTIONS,
Scenario,
} from '@/lib/catalog/data-mappings';
import {
buildSizingRows,
SIZING_DEFAULT_HEADROOM,
SIZING_DEFAULT_INTERACTIVITY,
} from '@/lib/power/gw-sizing';
import { buildHeadroomRows, HEADROOM_INTERACTIVITIES } from '@/lib/power/headroom';
import { SYSTEM_POWER_MODEL_REVISION } from '@/lib/power/system-power-categories';
import { ViewsApiParamError, runViewsRoute } from '@/lib/views-api/errors';
Expand Down Expand Up @@ -396,17 +401,33 @@ export function GET(request: NextRequest) {
const powerFit = parseBoolParam(search.get('powerFit'), 'powerFit', false);
const powerBreakdown = parseBoolParam(search.get('powerBreakdown'), 'powerBreakdown', false);
const headroom = parseBoolParam(search.get('headroom'), 'headroom', false);
const sizing = parseBoolParam(search.get('sizing'), 'sizing', false);
const sizingAt = parseNumberParam(
search.get('sizingAt'),
'sizingAt',
SIZING_DEFAULT_INTERACTIVITY,
{ min: Number.MIN_VALUE },
);
const sizingHeadroom = parseNumberParam(
search.get('sizingHeadroom'),
'sizingHeadroom',
SIZING_DEFAULT_HEADROOM,
{ min: 0, max: 200 },
);
const requestedServiceBaseline = search.get('serviceBaseline');
const requestedServiceComparator = search.get('serviceComparator');
const serviceTarget = search.has('serviceTarget')
? parseNumberParam(search.get('serviceTarget'), 'serviceTarget', 0, { min: Number.MIN_VALUE })
: null;
if (serviceTarget !== null && serviceTarget <= 0)
throw new ViewsApiParamError('serviceTarget', 'serviceTarget must be positive');
if (format === 'csv' && (serviceCompare || roleShare || powerFit || powerBreakdown || headroom))
if (
format === 'csv' &&
(serviceCompare || roleShare || powerFit || powerBreakdown || headroom || sizing)
)
throw new ViewsApiParamError(
'format',
'Equal-service, role-share, power-fit, power-breakdown and headroom panels require format=json',
'Equal-service, role-share, power-fit, power-breakdown, headroom and sizing panels require format=json',
);
const tcoBasis = parseTcoBasisParam(search.get('tcoBasis'));
const chipBasis = parseChipBasisParam(search.get('chipBasis'));
Expand Down Expand Up @@ -656,6 +677,21 @@ export function GET(request: NextRequest) {
}
: {};

// PowerX sizing to measured power: GPUs per GW at P90 × (1 + headroom) against the rating.
const sizingPanel = sizing
? {
sizing: {
interactivity: sizingAt,
interactivityField: breakdownInteractivity.field,
headroomPercent: sizingHeadroom,
rows: buildSizingRows(observedPoints, {
interactivity: sizingAt,
headroomPercent: sizingHeadroom,
}),
},
}
: {};

const resolvedParams = {
model: displayName,
engine: drafter,
Expand Down Expand Up @@ -696,6 +732,9 @@ export function GET(request: NextRequest) {
powerFit,
powerBreakdown,
headroom,
sizing,
sizingAt: sizing ? sizingAt : null,
sizingHeadroom: sizing ? sizingHeadroom : null,
};

if (format === 'csv') {
Expand Down Expand Up @@ -732,6 +771,7 @@ export function GET(request: NextRequest) {
...fitPanel,
...breakdownPanel,
...headroomPanel,
...sizingPanel,
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { describe, expect, it } from 'bun:test';

import type { SizingRow } from '@/lib/power/gw-sizing';

import {
SIZING_STRINGS,
sizingBarAxis,
sizingCurveMarks,
sizingCurveSpan,
sizingHeadline,
} from './PowerXGwSizing';

const row = (key: string, gainPercent: number, runIndex?: number) =>
({ key, gainPercent, ...(runIndex === undefined ? {} : { runIndex }) }) as SizingRow;

describe('PowerXGwSizing helpers', () => {
it('keeps the bar axis at 0 to +50% and widens it for larger gains or losses', () => {
expect(sizingBarAxis([row('a', 36), row('b', 9)])).toEqual({
min: 0,
max: 50,
ticks: [0, 10, 20, 30, 40, 50],
});
expect(sizingBarAxis([row('a', 32), row('b', -5)])).toMatchObject({ min: -10, max: 50 });
expect(sizingBarAxis([row('a', 120)]).ticks).toEqual([0, 20, 40, 60, 80, 100, 120]);
// A wide span steps by 20 and still labels the negative end.
expect(sizingBarAxis([row('a', 90), row('b', -5)])).toEqual({
min: -20,
max: 100,
ticks: [-20, 0, 20, 40, 60, 80, 100],
});
});

it('runs the curve to 60% headroom, or past a later break-even point', () => {
expect(sizingCurveSpan(43)).toBe(60);
expect(sizingCurveSpan(85)).toBe(100);
expect(sizingCurveSpan(900)).toBe(200);
});

it('marks 0 / 10 / 25 / 50 and the chosen headroom without stacking labels', () => {
expect(sizingCurveMarks(10, 60)).toEqual([0, 10, 25, 50]);
expect(sizingCurveMarks(35, 60)).toEqual([0, 10, 25, 35, 50]);
expect(sizingCurveMarks(23, 60)).toEqual([0, 10, 23, 50]);
});

it('states the gain range, or the best gain and the lines that gain nothing', () => {
const t = SIZING_STRINGS.en;
expect(sizingHeadline([row('a', 36), row('b', 9), row('c', 80, 0)], 10, t)).toBe(
'Sizing to measured power fits 9% to 36% more GPUs into a gigawatt, until headroom eats the gain',
);
expect(sizingHeadline([row('a', 12)], 10, t)).toContain('fits 12% more GPUs');
expect(sizingHeadline([row('a', 40), row('b', 0.3), row('c', -3)], 10, t)).toBe(
'Sizing to measured power fits up to 40% more GPUs into a gigawatt; at 10% headroom, 2 of 3 GPU lines gain nothing',
);
expect(sizingHeadline([row('a', -2)], 50, t)).toBe(
'At 50% headroom, no GPU line fits more GPUs into a gigawatt than sizing at the rating',
);
});
});
Loading
Loading