Skip to content

Commit 9c38df9

Browse files
authored
Relabel non-drafting AgentX points as spec none / 将未实际草稿生成的 AgentX 点位标为无投机解码 (#1659)
* fix(db): relabel non-drafting AgentX points to spec none Add set.specMethod to benchmark point backfills and register the 35 Kimi-K3 and MiniMax-M3 AgentX points that were labeled mtp although their servers never drafted. Ingest moves matching points to the spec-none config; apply-overrides moves stored rows and their availability. * fix(db): backfill required-power points before retention checks
1 parent 90c5b1a commit 9c38df9

10 files changed

Lines changed: 422 additions & 23 deletions

‎docs/data-pipeline.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ Benchmark point backfills use the same complete point selector as audited point
242242
`metricsMerge`, top-level `metricsRemove`, and `offloadMode`. Setting `offloadMode`
243243
updates both the first-class column and `metrics.offload_mode`; for example, a missed CPU
244244
KV offload annotation can set `offloadMode: 'on'` and merge `kv_offloading` plus backend
245-
metadata in one correction. Unrelated metrics remain unchanged.
245+
metadata in one correction. Unrelated metrics remain unchanged. Setting `specMethod`
246+
moves the point to the config that differs only in its speculative decoding method and
247+
adds that method's availability row, dropping the old method's row once no point uses
248+
it. `SPEC_METHOD_BACKFILLS` (`spec-method-backfills.ts`) uses it for AgentX points the
249+
matrix labeled `mtp` whose server never drafted.
246250

247251
When extending an already-applied identity-changing correction, record its old
248252
`set` as `previousSet`. The recovery command accepts that declared prior patch

‎packages/db/src/apply-overrides.ts‎

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { isDeepStrictEqual } from 'node:util';
22

33
import { confirm, hasNoSslFlag, hasYesFlag } from './cli-utils.js';
4-
import { configCacheKey } from './etl/config-cache.js';
4+
import { bulkUpsertAvailability } from './etl/benchmark-ingest.js';
5+
import { configCacheKey, createConfigCache } from './etl/config-cache.js';
56
import { type Sql, createAdminSql } from './etl/db-utils.js';
67
import { jsonbParam } from './lib/backfill-runner.js';
78
import { planBenchmarkPointBackfill } from './lib/benchmark-point-backfill.js';
@@ -10,6 +11,7 @@ import {
1011
type BenchmarkPointBackfill,
1112
type ChangelogBackfill,
1213
type PurgedBenchmarkPoint,
14+
backfillDesiredConfig,
1315
validateRunBackfills,
1416
} from './etl/run-overrides.js';
1517

@@ -168,6 +170,8 @@ interface BenchmarkPointBackfillTarget {
168170
backfill: BenchmarkPointBackfill;
169171
resultId: number;
170172
metrics: Record<string, unknown>;
173+
sourceSpecMethod: string;
174+
date: string;
171175
}
172176

173177
function benchmarkPointDescription(backfill: BenchmarkPointBackfill): string {
@@ -192,8 +196,12 @@ async function previewBenchmarkPointBackfill(
192196
const sourceRecipeFingerprint = backfill.recipeFingerprint ?? null;
193197
const desiredRecipeFingerprint = backfill.set.recipeFingerprint ?? sourceRecipeFingerprint;
194198
const { config } = backfill;
199+
const specMethods = [
200+
...new Set([config.specMethod, backfill.set.specMethod ?? config.specMethod]),
201+
];
195202
const rows = await sql`
196-
SELECT br.id, br.offload_mode, br.recipe_fingerprint, br.metrics
203+
SELECT br.id, br.offload_mode, br.recipe_fingerprint, br.metrics, br.date::text AS date,
204+
c.spec_method
197205
FROM benchmark_results br
198206
JOIN workflow_runs wr ON wr.id = br.workflow_run_id
199207
JOIN configs c ON c.id = br.config_id
@@ -203,7 +211,7 @@ async function previewBenchmarkPointBackfill(
203211
AND c.framework = ${config.framework}
204212
AND c.model = ${config.model}
205213
AND c.precision = ${config.precision}
206-
AND c.spec_method = ${config.specMethod}
214+
AND c.spec_method = ANY(${specMethods})
207215
AND c.disagg = ${config.disagg}
208216
AND c.is_multinode = ${config.isMultinode}
209217
AND c.prefill_tp = ${config.prefillTp}
@@ -239,6 +247,7 @@ async function previewBenchmarkPointBackfill(
239247
{
240248
offload_mode: row.offload_mode,
241249
recipe_fingerprint: row.recipe_fingerprint,
250+
spec_method: row.spec_method,
242251
metrics: row.metrics,
243252
},
244253
backfill,
@@ -256,25 +265,55 @@ async function previewBenchmarkPointBackfill(
256265
backfill,
257266
resultId: row.id as number,
258267
metrics,
268+
sourceSpecMethod: row.spec_method as string,
269+
date: row.date as string,
259270
};
260271
}
261272

262273
async function applyBenchmarkPointBackfillToDatabase(
263274
target: BenchmarkPointBackfillTarget,
264275
): Promise<void> {
265-
const { backfill, resultId, metrics } = target;
276+
const { backfill, resultId, metrics, sourceSpecMethod, date } = target;
266277
const desiredOffloadMode = backfill.set.offloadMode ?? backfill.offloadMode;
267278
const desiredRecipeFingerprint =
268279
backfill.set.recipeFingerprint ?? backfill.recipeFingerprint ?? null;
269-
const [updated] = await sql`
270-
UPDATE benchmark_results
271-
SET offload_mode = ${desiredOffloadMode},
272-
recipe_fingerprint = ${desiredRecipeFingerprint},
273-
metrics = ${jsonbParam(sql, metrics)}
274-
WHERE id = ${resultId}
275-
RETURNING id
276-
`;
277-
if (!updated) throw new Error(`${backfill.id}: benchmark row disappeared before update`);
280+
const desiredConfig = backfillDesiredConfig(backfill);
281+
await sql.begin(async (_tx) => {
282+
const tx = _tx as unknown as Sql;
283+
const configId = await createConfigCache(tx).getOrCreateConfig(desiredConfig);
284+
const [updated] = await tx`
285+
UPDATE benchmark_results
286+
SET config_id = ${configId},
287+
offload_mode = ${desiredOffloadMode},
288+
recipe_fingerprint = ${desiredRecipeFingerprint},
289+
metrics = ${jsonbParam(tx, metrics)}
290+
WHERE id = ${resultId}
291+
RETURNING id
292+
`;
293+
if (!updated) throw new Error(`${backfill.id}: benchmark row disappeared before update`);
294+
if (sourceSpecMethod === desiredConfig.specMethod) return;
295+
const availability = {
296+
model: desiredConfig.model,
297+
isl: backfill.isl,
298+
osl: backfill.osl,
299+
precision: desiredConfig.precision,
300+
hardware: desiredConfig.hardware,
301+
framework: desiredConfig.framework,
302+
disagg: desiredConfig.disagg,
303+
};
304+
await bulkUpsertAvailability(
305+
tx,
306+
[
307+
{
308+
...availability,
309+
specMethod: desiredConfig.specMethod,
310+
benchmarkType: backfill.benchmarkType,
311+
},
312+
],
313+
date,
314+
);
315+
await deleteStaleAvailability(tx, [{ ...availability, spec_method: sourceSpecMethod, date }]);
316+
});
278317
console.log(` ${backfill.id} patched.`);
279318
}
280319

@@ -401,6 +440,13 @@ async function purgeBenchmarkResults(tx: Sql, resultIds: number[]): Promise<void
401440
`;
402441
}
403442

443+
await deleteStaleAvailability(tx, availKeys);
444+
}
445+
446+
async function deleteStaleAvailability(
447+
tx: Sql,
448+
availKeys: readonly Record<string, unknown>[],
449+
): Promise<void> {
404450
if (availKeys.length > 0) {
405451
const models = availKeys.map((r) => r.model as string);
406452
const isls = availKeys.map((r) => r.isl as number | null);

‎packages/db/src/etl/required-power-curve.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
type RequiredPowerScope,
1818
type RequiredPowerSource,
1919
} from './required-power-publication';
20-
import { planBenchmarkPoint } from './run-overrides';
20+
import { backfilledPoints, planBenchmarkPoint } from './run-overrides';
2121

2222
export interface CurvePoint {
2323
identity: Record<string, unknown>;
@@ -176,10 +176,18 @@ export async function preflightRequiredPowerCurves(
176176
backfilled,
177177
);
178178
if (plan.kind === 'purged') continue;
179-
incoming.set(stablePowerPointIdentity(benchmarkPublicationIdentity(plan.point)), plan.point);
179+
const planned =
180+
plan.point.config === mapped.config
181+
? plan.point
182+
: { ...plan.point, configId: configIds.get(configCacheKey(plan.point.config)) ?? -1 };
183+
incoming.set(stablePowerPointIdentity(benchmarkPublicationIdentity(planned)), planned);
180184
}
181185
}
182-
assertRequiredPowerPointsRetained(required.points, [...incoming.values()], 'before_write');
186+
assertRequiredPowerPointsRetained(
187+
backfilledPoints({ githubRunId: source.runId, runAttempt: source.runAttempt }, required.points),
188+
[...incoming.values()],
189+
'before_write',
190+
);
183191
const models = [...new Set([...incoming.values()].map((point) => point.config.model))];
184192
const stored = await loadStoredCurvePoints(sql, models, source.runId);
185193
const attemptRows =

‎packages/db/src/etl/run-overrides.test.ts‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type PurgedBenchmarkPoint,
66
applyBenchmarkPointBackfill,
77
applyChangelogBackfills,
8+
backfilledPoints,
89
BENCHMARK_POINT_BACKFILLS,
910
CHANGELOG_BACKFILLS,
1011
CONCLUSION_OVERRIDES,
@@ -498,6 +499,93 @@ describe('planBenchmarkPoint', () => {
498499
registry.splice(registry.indexOf(backfill), 1);
499500
}
500501
});
502+
503+
it('relabels required-power points the same way ingest relabels retained points', () => {
504+
const required = {
505+
config: {
506+
...EXAMPLE_CONFIG,
507+
hardware: 'b300',
508+
framework: 'vllm',
509+
model: 'kimik3',
510+
disagg: false,
511+
isMultinode: false,
512+
prefillTp: 8,
513+
prefillEp: 1,
514+
prefillDpAttn: false,
515+
prefillNumWorkers: 0,
516+
decodeTp: 8,
517+
decodeEp: 1,
518+
decodeDpAttn: false,
519+
decodeNumWorkers: 0,
520+
},
521+
benchmarkType: 'agentic_traces',
522+
isl: null,
523+
osl: null,
524+
conc: 24,
525+
offloadMode: 'on',
526+
recipeFingerprint: '61ba8917bcdef3e354ba09a889270595338d97885bd465fedd01c9dbe7e9beaa',
527+
metrics: {},
528+
};
529+
const [relabeled] = backfilledPoints({ githubRunId: 31893747354, runAttempt: 2 }, [required]);
530+
expect(relabeled!.config.specMethod).toBe('none');
531+
});
532+
533+
it('moves a non-drafting B300 Kimi-K3 point to the none config and leaves drafting points alone', () => {
534+
const kimiB300 = {
535+
...EXAMPLE_CONFIG,
536+
hardware: 'b300',
537+
framework: 'vllm',
538+
model: 'kimik3',
539+
disagg: false,
540+
isMultinode: false,
541+
prefillTp: 8,
542+
prefillEp: 1,
543+
prefillDpAttn: false,
544+
prefillNumWorkers: 0,
545+
decodeTp: 8,
546+
decodeEp: 1,
547+
decodeDpAttn: false,
548+
decodeNumWorkers: 0,
549+
};
550+
const kimiPoint = (conc: number) => ({
551+
configId: 2182,
552+
config: kimiB300,
553+
benchmarkType: 'agentic_traces',
554+
isl: null,
555+
osl: null,
556+
conc,
557+
offloadMode: 'on',
558+
recipeFingerprint: '61ba8917bcdef3e354ba09a889270595338d97885bd465fedd01c9dbe7e9beaa',
559+
metrics: { median_itl: 0.1 },
560+
});
561+
const run = { githubRunId: 31893747354, runAttempt: 2 };
562+
const seen = new Map<string, string>();
563+
564+
const relabeled = planBenchmarkPoint(run, kimiPoint(24), seen);
565+
expect(relabeled.kind === 'planned' && relabeled.point.config).toEqual({
566+
...kimiB300,
567+
specMethod: 'none',
568+
});
569+
expect(relabeled.kind === 'planned' && relabeled.point.metrics).toEqual({ median_itl: 0.1 });
570+
571+
const drafting = planBenchmarkPoint(run, kimiPoint(16), seen);
572+
expect(drafting).toMatchObject({ kind: 'planned', backfillId: null });
573+
expect(drafting.kind === 'planned' && drafting.point.config.specMethod).toBe('mtp');
574+
575+
expect(() =>
576+
planBenchmarkPoint(
577+
run,
578+
{ ...kimiPoint(24), configId: 2116, config: { ...kimiB300, specMethod: 'none' } },
579+
seen,
580+
),
581+
).toThrow(/collision/u);
582+
});
583+
584+
it('rejects a spec method correction that does not change the config', () => {
585+
expect(() =>
586+
validateRunBackfills([], [examplePointBackfill({ set: { specMethod: 'mtp' } })]),
587+
).toThrow(/specMethod/u);
588+
});
501589
});
502590

503591
describe('CONCLUSION_OVERRIDES', () => {

0 commit comments

Comments
 (0)