Skip to content

Commit 54d5e09

Browse files
authored
fix(agentic): label KV series by DP rank (#548)
Prefer dp_rank over rank-local engine identifiers and cover both repeated-engine and normal multi-DP exports. 中文:修正 agentic KV 序列的 DP rank 标签。优先使用 dp_rank,并覆盖 engine 标签重复及常规多 DP 导出场景。
1 parent 498c9ce commit 54d5e09

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

packages/db/src/etl/compute-chart-series.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ describe('computeChartSeries', () => {
253253
{ t: 0, value: 0.25 },
254254
{ t: 1, value: 0.5 },
255255
]);
256+
expect(cs!.kvCacheUsageByEngine.map(({ engineLabel }) => engineLabel)).toEqual([
257+
'0',
258+
'1',
259+
'2',
260+
'3',
261+
]);
256262
// prefillTps = Σ rates = 4 × 100 = 400; then 4 × 200 = 800
257263
expect(cs!.prefillTps).toEqual([
258264
{ t: 0, value: 400 },
@@ -264,6 +270,29 @@ describe('computeChartSeries', () => {
264270
]);
265271
});
266272

273+
it('uses dp_rank when engine labels repeat across DEP ranks', async () => {
274+
const engines = [0, 1, 2, 3].map((dpRank) => ({
275+
labels: { engine: '0', dp_rank: String(dpRank) },
276+
timeslices: [{ start_ns: 0, end_ns: 1e9, avg: 0.1 + dpRank * 0.1 }],
277+
}));
278+
const blob = gzipSync(
279+
Buffer.from(
280+
JSON.stringify({
281+
metrics: { 'vllm:kv_cache_usage_perc': { series: engines } },
282+
}),
283+
),
284+
);
285+
286+
const series = await computeChartSeries(blob);
287+
288+
expect(series?.kvCacheUsageByEngine.map(({ engineLabel }) => engineLabel)).toEqual([
289+
'0',
290+
'1',
291+
'2',
292+
'3',
293+
]);
294+
});
295+
267296
it('uses the Dynamo adapter to preserve workers and canonical prefill/decode roles', async () => {
268297
const json = JSON.stringify({
269298
metrics: {

packages/db/src/etl/compute-chart-series.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ import {
6767
* warmup block are unaffected. (v11 was a short-lived, since-reverted attempt to
6868
* carry kvCachePoolTokens in chart_series; that value now lives in
6969
* benchmark_results.metrics, derived from the server log — unrelated to this.)
70+
*
71+
* v13: prefer `dp_rank` over the per-rank-local `engine` label when naming
72+
* KV-cache series. Some DEP exports report engine=0 for every rank, which
73+
* made every legend entry read "DP 0" despite distinct dp_rank labels.
7074
*/
71-
export const CHART_SERIES_VERSION = 12;
75+
export const CHART_SERIES_VERSION = 13;
7276

7377
export interface TimeSeriesPoint {
7478
/** Seconds from benchmark start. */
@@ -348,11 +352,11 @@ function buildSeriesFromMetrics(
348352
// the cluster-average line.
349353
const kvCacheUsageByEngine: { engineLabel: string; points: TimeSeriesPoint[] }[] = [];
350354
if (kvSeries && kvSeries.length > 1) {
351-
// Sort by numeric engine label when present so rank 0..N renders in
352-
// order; fall back to series-array index otherwise.
355+
// Sort by numeric DP rank when present so rank 0..N renders in order;
356+
// fall back to the engine label, then series-array index otherwise.
353357
const decorated = kvSeries.map((s, idx) => {
354358
const raw =
355-
s.labels?.['engine'] ?? s.labels?.['engine_idx'] ?? s.labels?.['dp_rank'] ?? String(idx);
359+
s.labels?.['dp_rank'] ?? s.labels?.['engine'] ?? s.labels?.['engine_idx'] ?? String(idx);
356360
const numeric = Number(raw);
357361
return { series: s, idx, label: raw, sortKey: Number.isFinite(numeric) ? numeric : idx };
358362
});

0 commit comments

Comments
 (0)