Skip to content

Commit e543ef8

Browse files
authored
feat: show the speculative algorithm and draft model each AgentX point ran (#1660)
Ingest keeps spec_algorithm and spec_draft_model from InferenceX results, the tooltip shows them instead of the matrix label, and draft_model gets a readable label. db:backfill-spec-algorithm fills stored AgentX points from their server logs.
1 parent 9c38df9 commit e543ef8

15 files changed

Lines changed: 408 additions & 11 deletions

‎docs/data-pipeline.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,22 @@ also unioned back into the window rather than dropped. Only after that volume-we
439439
aggregation is the semantic `[0, 1]` bound applied as a guard against residual counter timing
440440
skew. Older rows without the component rate series retain the stored-ratio fallback.
441441

442+
### Speculative Decoding Algorithm and Draft Model
443+
444+
`configs.spec_method` is the matrix label (`mtp`, `draft_model`, `none`) and says neither
445+
which algorithm a server ran nor what drafted. InferenceX results carry `spec_algorithm`
446+
(`mtp`, `dspark`, `dflash`, `eagle3`, in the golden AL identity vocabulary) and
447+
`spec_draft_model` (the drafter's repo, or `native` when the served checkpoint drafts for
448+
itself). Ingest stores both in `metrics`, and the AgentX tooltip shows them, for example
449+
"DFlash (RadixArk/Muse-Spark-Open-DFlash2)" or "DSpark (native)". Points without them fall
450+
back to the label.
451+
452+
`db:backfill-spec-algorithm` fills both for stored AgentX points from their server logs
453+
(`etl/server-log-speculation.ts`): vLLM's and ATOM's `SpeculativeConfig`, SGLang's
454+
`server_args`, TensorRT-LLM's speculative config, and TileRT's `num_mtp`. Engines often name
455+
the served checkpoint, or a directory inside `/model`, as the draft model, so only a separate
456+
drafter's name (DSpark, DFlash, EAGLE, NextN, MTP or draft) is reported as one.
457+
442458
### Server-Log Artifact Bundles
443459

444460
Server-log artifacts are stored as filename-keyed bundles rather than as a hard-coded list of

‎packages/app/src/components/inference/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export interface AggDataEntry {
141141
kv_p2p_transfer?: string;
142142
router_name?: string;
143143
router_version?: string;
144+
spec_algorithm?: string;
145+
spec_draft_model?: string;
144146
server_gpu_cache_hit_rate?: number;
145147
server_external_cache_hit_rate?: number;
146148
server_cpu_cache_hit_rate?: number;

‎packages/app/src/components/inference/utils/tooltip-utils.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,28 @@ describe('generateTooltipContent', () => {
463463
).not.toContain('data-action="view-logs"');
464464
});
465465

466+
it.each([
467+
[{ spec_decoding: 'draft_model' }, 'Draft Model'],
468+
[
469+
{
470+
spec_decoding: 'draft_model',
471+
spec_algorithm: 'dflash',
472+
spec_draft_model: 'RadixArk/Muse-Spark-Open-DFlash2',
473+
},
474+
'DFlash (RadixArk/Muse-Spark-Open-DFlash2)',
475+
],
476+
[
477+
{ spec_decoding: 'mtp', spec_algorithm: 'dspark', spec_draft_model: 'native' },
478+
'DSpark (native)',
479+
],
480+
[{ spec_decoding: 'none', spec_algorithm: 'dspark', spec_draft_model: 'native' }, 'Off'],
481+
])('labels speculative decoding by what the server ran: %j', (fields, label) => {
482+
const html = generateTooltipContent(
483+
tooltipConfig({ data: pt({ id: 3, benchmark_type: 'agentic_traces', ...fields }) }),
484+
);
485+
expect(html).toContain(`<strong>Speculative Decoding:</strong> ${label}</div>`);
486+
});
487+
466488
it('routes fixed-sequence log actions to the fixed benchmark log viewer', () => {
467489
const html = generateTooltipContent(
468490
tooltipConfig({

‎packages/app/src/components/inference/utils/tooltipUtils.ts‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -514,33 +514,47 @@ const AGENTIC_STRINGS = {
514514
en: {
515515
speculativeDecoding: 'Speculative Decoding',
516516
off: 'Off',
517+
native: 'native',
517518
requests: 'Requests',
518519
promptTokens: 'Prompt Tokens',
519520
generatedTokens: 'Generated Tokens',
520521
},
521522
zh: {
522523
speculativeDecoding: '投机解码',
523524
off: '关闭',
525+
native: '原生',
524526
requests: '请求',
525527
promptTokens: '提示 token',
526528
generatedTokens: '生成 token',
527529
},
528530
} as const;
529531

532+
const SPEC_ALGORITHM_LABELS: Record<string, string> = {
533+
mtp: 'MTP',
534+
dspark: 'DSpark',
535+
dflash: 'DFlash',
536+
eagle: 'EAGLE',
537+
eagle3: 'EAGLE3',
538+
nextn: 'NextN',
539+
};
540+
541+
const speculativeDecodingLabel = (
542+
d: InferenceData,
543+
t: (typeof AGENTIC_STRINGS)[Locale],
544+
): string => {
545+
const specMethod = d.spec_decoding ?? 'none';
546+
if (specMethod === 'none' || specMethod === '') return t.off;
547+
if (!d.spec_algorithm) return specMethodDisplayLabel(d.model, specMethod);
548+
const algorithm = SPEC_ALGORITHM_LABELS[d.spec_algorithm] ?? d.spec_algorithm.toUpperCase();
549+
const draft = d.spec_draft_model;
550+
return `${algorithm} (${!draft || draft === 'native' ? t.native : escapeHtml(draft)})`;
551+
};
552+
530553
const generateAgenticHTML = (d: InferenceData, locale: Locale): string => {
531554
if (d.benchmark_type !== 'agentic_traces') return '';
532555

533556
const t = AGENTIC_STRINGS[locale];
534-
const parts: string[] = [];
535-
const specMethod = d.spec_decoding ?? 'none';
536-
parts.push(
537-
tooltipLine(
538-
t.speculativeDecoding,
539-
specMethod === 'none' || specMethod === ''
540-
? t.off
541-
: specMethodDisplayLabel(d.model, specMethod),
542-
),
543-
);
557+
const parts: string[] = [tooltipLine(t.speculativeDecoding, speculativeDecodingLabel(d, t))];
544558

545559
if (d.num_requests_total !== undefined && d.num_requests_successful !== undefined) {
546560
const successPct =

‎packages/app/src/lib/api/api-route-catalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ export const apiContractSourceDigests = [
14781478
},
14791479
{
14801480
source: 'src/lib/benchmarks/benchmark-transform.ts',
1481-
sourceSha256: '97b97962a9c09df7d7abfe84b6f4cb78d0b0500c9e41bf1fd785d040fcb59ad4',
1481+
sourceSha256: '7ade60009996367fbd6bfcbcfd7ba155fd96e1676dcb0d320ca26821f948ba7a',
14821482
reviewArea: {
14831483
en: 'Raw benchmark means and derived reciprocal mean-TPOT interactivity used by Dashboard and read-only views.',
14841484
zh: '仪表板和只读视图共用的原始 benchmark 均值与 mean TPOT 倒数形式的 interactivity。',

‎packages/app/src/lib/benchmarks/benchmark-transform.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ export function rowToAggDataEntry(
430430
kv_p2p_transfer: stringMetric('kv_p2p_transfer'),
431431
router_name: stringMetric('router_name'),
432432
router_version: stringMetric('router_version'),
433+
spec_algorithm: stringMetric('spec_algorithm'),
434+
spec_draft_model: stringMetric('spec_draft_model'),
433435
server_gpu_cache_hit_rate: m.server_gpu_cache_hit_rate,
434436
server_external_cache_hit_rate: m.server_external_cache_hit_rate,
435437
server_cpu_cache_hit_rate: m.server_cpu_cache_hit_rate,

‎packages/constants/src/framework-aliases.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const FRAMEWORK_LABELS: Record<string, string> = {
4040
]),
4141
),
4242
mtp: 'MTP',
43+
draft_model: 'Draft Model',
4344
aiperf: 'AIPerf',
4445
};
4546

‎packages/db/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"db:backfill-runtime-metadata": "bun --env-file=../../.env src/backfill-runtime-metadata.ts",
4242
"db:backfill-sequence-length-sketches": "bun --env-file=../../.env src/backfill-sequence-length-sketches.ts",
4343
"db:backfill-server-log-files": "bun --env-file=../../.env src/backfill-server-log-files.ts",
44+
"db:backfill-spec-algorithm": "bun --env-file=../../.env src/backfill-spec-algorithm.ts",
4445
"db:compact-server-logs": "bun --env-file=../../.env src/compact-server-logs.ts",
4546
"db:reset": "bun --env-file=../../.env src/reset-db.ts",
4647
"db:sync-public": "bun --env-file=../../.env src/sync-public-db.ts",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { hasNoSslFlag } from './cli-utils.js';
2+
import { createAdminSql } from './etl/db-utils.js';
3+
import { runBackfillMain, runCandidateIdBackfill } from './lib/backfill-runner.js';
4+
import {
5+
backfillSpecAlgorithm,
6+
loadSpecAlgorithmCandidates,
7+
} from './lib/spec-algorithm-backfill.js';
8+
9+
const sql = createAdminSql({ noSsl: hasNoSslFlag(), max: 2, onnotice: () => {} });
10+
11+
async function main(): Promise<void> {
12+
console.log('=== backfill-spec-algorithm ===');
13+
await runCandidateIdBackfill(
14+
() => loadSpecAlgorithmCandidates(sql),
15+
async (id) => {
16+
const speculation = await backfillSpecAlgorithm(sql, id);
17+
if (!speculation) {
18+
console.log(` id=${id}: no speculative config in the server log`);
19+
return 'skipped';
20+
}
21+
console.log(` id=${id}: ${speculation.spec_algorithm} (${speculation.spec_draft_model})`);
22+
return 'ok';
23+
},
24+
);
25+
}
26+
27+
runBackfillMain('backfill-spec-algorithm', sql, main);

‎packages/db/src/etl/benchmark-mapper.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const NON_METRIC_KEYS = new Set([
6464
'kv_offload_backend',
6565
'kv_p2p_transfer',
6666
'router',
67+
'spec_algorithm',
68+
'spec_draft_model',
6769
'request_metrics',
6870
'server_metrics',
6971
'dataset',

0 commit comments

Comments
 (0)