aiinfra-tools 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +268 -0
- package/README.md +27 -3
- package/bin/aiinfra.mjs +5 -2
- package/bin/report.mjs +177 -0
- package/fleetops/README.md +33 -1
- package/fleetops/deploy/shadow-gate/argo-analysistemplate.yaml +34 -0
- package/fleetops/deploy/shadow-gate/argo-rollout-example.yaml +38 -0
- package/fleetops/deploy/shadow-gate/flagger-canary.yaml +34 -0
- package/fleetops/deploy/shadow-gate/judge.yaml +51 -0
- package/fleetops/deploy/shadow-gate/llmd-canary-example.yaml +35 -0
- package/fleetops/deploy/shadow-gate/podmonitor-vllm.yaml +20 -0
- package/fleetops/deploy/shadow-live/README.md +41 -0
- package/fleetops/deploy/shadow-live/kit.yaml +123 -0
- package/fleetops/deploy/shadow-live/load-canary.yaml +26 -0
- package/fleetops/deploy/shadow-live/run.sh +53 -0
- package/fleetops/docs/ADMISSION.md +9 -9
- package/fleetops/docs/FABRIC-STORAGE.md +1 -1
- package/fleetops/docs/SERVING.md +11 -1
- package/fleetops/docs/SHADOW.md +250 -0
- package/fleetops/docs/SIGNALS.md +5 -2
- package/fleetops/docs/WORKLOADS.md +1 -1
- package/fleetops/package.json +7 -4
- package/fleetops/src/adapters/fabric.mjs +19 -7
- package/fleetops/src/adapters/live.mjs +38 -5
- package/fleetops/src/adapters/logs.mjs +10 -7
- package/fleetops/src/adapters/nvsentinel.mjs +95 -0
- package/fleetops/src/adapters/topology.mjs +53 -1
- package/fleetops/src/admission.mjs +26 -18
- package/fleetops/src/api.mjs +2 -1
- package/fleetops/src/bundle.mjs +3 -0
- package/fleetops/src/calibrate.mjs +1 -1
- package/fleetops/src/detect.mjs +1 -1
- package/fleetops/src/export.mjs +5 -1
- package/fleetops/src/goodput.mjs +0 -2
- package/fleetops/src/incidents.mjs +1 -2
- package/fleetops/src/ingest.mjs +10 -3
- package/fleetops/src/inject.mjs +2 -2
- package/fleetops/src/live.mjs +2 -1
- package/fleetops/src/llmd.mjs +7 -3
- package/fleetops/src/optimize.mjs +1 -1
- package/fleetops/src/power.mjs +7 -7
- package/fleetops/src/procure.mjs +67 -0
- package/fleetops/src/rca.mjs +1 -1
- package/fleetops/src/rollout.mjs +1 -1
- package/fleetops/src/schema.mjs +3 -2
- package/fleetops/src/security.mjs +1 -1
- package/fleetops/src/serving.mjs +32 -10
- package/fleetops/src/shadow-canary.mjs +74 -0
- package/fleetops/src/shadow-gate.mjs +49 -0
- package/fleetops/src/shadow-prom.mjs +205 -0
- package/fleetops/src/shadow-replay.mjs +147 -0
- package/fleetops/src/shadow.mjs +291 -0
- package/fleetops/src/stats.mjs +14 -0
- package/fleetops/src/traces.mjs +0 -5
- package/fleetops/tests/fixtures/real/README.md +5 -0
- package/fleetops/tools/admit-node.sh +51 -16
- package/fleetops/tools/amd-admit.py +111 -0
- package/fleetops/tools/cmd/calibrate.mjs +61 -0
- package/fleetops/tools/cmd/capacity.mjs +116 -0
- package/fleetops/tools/cmd/common.mjs +32 -0
- package/fleetops/tools/cmd/data.mjs +343 -0
- package/fleetops/tools/cmd/help.mjs +243 -0
- package/fleetops/tools/cmd/incidents.mjs +216 -0
- package/fleetops/tools/cmd/rollout.mjs +122 -0
- package/fleetops/tools/cmd/server.mjs +122 -0
- package/fleetops/tools/cmd/serving.mjs +95 -0
- package/fleetops/tools/cmd/shadow.mjs +204 -0
- package/fleetops/tools/cmd/training.mjs +79 -0
- package/fleetops/tools/collect.sh +6 -1
- package/fleetops/tools/fleetops.mjs +18 -1308
- package/fleetops/tools/loop-demo.mjs +1 -1
- package/fleetops/tools/workload-profile.mjs +0 -1
- package/fleetscope/README.md +5 -1
- package/fleetscope/build.mjs +4 -0
- package/fleetscope/dist/index.html +1013 -28
- package/fleetscope/docs/AGENTIC.md +89 -0
- package/fleetscope/docs/PLANNING.md +4 -2
- package/fleetscope/docs/VALIDATION-AGENTIC.md +37 -0
- package/fleetscope/package.json +4 -3
- package/fleetscope/src/agentic.js +288 -0
- package/fleetscope/src/ask.js +0 -1
- package/fleetscope/src/cluster-ui.js +1 -0
- package/fleetscope/src/engine.js +29 -13
- package/fleetscope/src/index.src.html +15 -5
- package/fleetscope/src/inference-ui.js +1 -0
- package/fleetscope/src/ingest.js +89 -3
- package/fleetscope/src/optimize.js +11 -5
- package/fleetscope/src/plan.js +1 -1
- package/fleetscope/src/training-ui.js +1 -0
- package/fleetscope/tools/agentic.mjs +148 -0
- package/fleetscope/tools/tracelab-data.mjs +27 -0
- package/gpu-health/README.md +13 -2
- package/gpu-health/docs/CONFIG.md +29 -1
- package/gpu-health/package.json +7 -4
- package/gpu-health/src/actions.mjs +16 -3
- package/gpu-health/src/analyze.mjs +3 -0
- package/gpu-health/src/config.mjs +3 -0
- package/gpu-health/src/executors.mjs +9 -4
- package/gpu-health/src/health.mjs +1 -1
- package/gpu-health/src/ingest.mjs +27 -3
- package/gpu-health/src/platforms.mjs +109 -0
- package/gpu-health/src/vendors.mjs +12 -5
- package/gpu-health/tools/gpu-health.mjs +6 -4
- package/gpu-ledger/README.md +3 -1
- package/gpu-ledger/package.json +12 -4
- package/gpu-ledger/src/adapters.mjs +3 -2
- package/gpu-ledger/src/cloud.mjs +104 -0
- package/gpu-ledger/src/core.mjs +12 -10
- package/gpu-ledger/tools/ledger.mjs +8 -2
- package/harness-ledger/README.md +152 -0
- package/harness-ledger/docs/FORMATS.md +114 -0
- package/harness-ledger/docs/METHOD.md +133 -0
- package/harness-ledger/docs/VALIDATION-ECONOMICS.md +59 -0
- package/harness-ledger/docs/VALIDATION-SWEBENCH.md +26 -0
- package/harness-ledger/docs/VALIDATION-TRACELAB.md +56 -0
- package/harness-ledger/package.json +19 -0
- package/harness-ledger/src/demo.mjs +115 -0
- package/harness-ledger/src/economics.mjs +184 -0
- package/harness-ledger/src/gpu.mjs +80 -0
- package/harness-ledger/src/html.mjs +63 -0
- package/harness-ledger/src/importers.mjs +247 -0
- package/harness-ledger/src/ledger.mjs +128 -0
- package/harness-ledger/src/opencost.mjs +55 -0
- package/harness-ledger/src/outcomes.mjs +67 -0
- package/harness-ledger/src/prices.mjs +75 -0
- package/harness-ledger/src/record.mjs +52 -0
- package/harness-ledger/src/waste.mjs +136 -0
- package/harness-ledger/tools/harness-ledger.mjs +199 -0
- package/harness-ledger/tools/validate-economics.mjs +69 -0
- package/harness-ledger/tools/validate-swebench.mjs +57 -0
- package/harness-ledger/tools/validate-tracelab.mjs +74 -0
- package/hybrid-tracing/package.json +4 -3
- package/hybrid-tracing/tools/fix-skew.mjs +1 -1
- package/inference-sizer/README.md +5 -1
- package/inference-sizer/build.mjs +1 -0
- package/inference-sizer/dist/index.html +299 -31
- package/inference-sizer/docs/ACCELERATORS.md +62 -0
- package/inference-sizer/docs/CATALOG.md +71 -0
- package/inference-sizer/docs/METHOD.md +1 -1
- package/inference-sizer/docs/VALIDATION-INFERENCEX.md +37 -0
- package/inference-sizer/package.json +4 -3
- package/inference-sizer/src/accelerators.js +194 -0
- package/inference-sizer/src/catalog.js +55 -22
- package/inference-sizer/src/fit-ui.js +1 -1
- package/inference-sizer/src/index.src.html +3 -0
- package/inference-sizer/src/model.js +45 -7
- package/inference-sizer/src/ui.js +1 -1
- package/inference-sizer/tools/validate-agentx.mjs +116 -0
- package/inference-sizer/tools/validate-inferencex.mjs +132 -0
- package/mcp/README.md +6 -1
- package/mcp/server.mjs +34 -0
- package/package.json +10 -6
- package/schemas/README.md +3 -0
- package/schemas/aiinfra.report.schema.json +474 -0
- package/schemas/commands.mjs +14 -0
- package/schemas/fleetops.shadow.canary.schema.json +96 -0
- package/schemas/fleetops.shadow.compare.schema.json +266 -0
- package/schemas/fleetops.shadow.prom.schema.json +354 -0
- package/schemas/harness-ledger.economics.schema.json +567 -0
- package/schemas/sizer.list.schema.json +15 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// A synthetic day of three harnesses, written in each harness's own log format so the demo runs the real importers:
|
|
2
|
+
// a Claude Code session with a subagent, a Codex CLI session, and a LangGraph-style agent traced with OpenTelemetry
|
|
3
|
+
// that calls a self-hosted model on vLLM (with the engine's request spans, for the GPU join).
|
|
4
|
+
// Every text field is a placeholder: no real prompts, code or tool output.
|
|
5
|
+
const T0 = Date.parse('2026-11-24T16:00:00Z') / 1000;
|
|
6
|
+
function rng(seed) { let s = seed >>> 0; return () => ((s = (s * 1664525 + 1013904223) >>> 0) / 2 ** 32); }
|
|
7
|
+
const iso = t => new Date(t * 1000).toISOString();
|
|
8
|
+
const pad = (n, ch = 'x') => ch.repeat(Math.max(0, Math.round(n))); // n characters of filler ≈ n/4 tokens
|
|
9
|
+
|
|
10
|
+
// ---------- Claude Code ----------
|
|
11
|
+
export function claudeCodeSession({ seed = 7 } = {}) {
|
|
12
|
+
const r = rng(seed), L = [], sid = 'demo-cc-1';
|
|
13
|
+
let t = T0, ctx = 18000, prevCtx = 0, n = 0;
|
|
14
|
+
const assistant = ({ model = 'claude-sonnet-4-5-20250929', side = null, tools = [], read, write, inp = 3, out = 120 + Math.round(r() * 400) }) => {
|
|
15
|
+
n++; const id = `msg_${side ? 's' : 'm'}${n}`;
|
|
16
|
+
L.push({ type: 'assistant', sessionId: sid, isSidechain: !!side, agentId: side || undefined, uuid: `u${n}`, requestId: `req_${n}`, timestamp: iso(t),
|
|
17
|
+
message: { id, model, role: 'assistant', stop_reason: tools.length ? 'tool_use' : 'end_turn',
|
|
18
|
+
content: [{ type: 'text', text: 'placeholder' }, ...tools.map((tl, i) => ({ type: 'tool_use', id: `tu_${n}_${i}`, name: tl.name, input: tl.input }))],
|
|
19
|
+
usage: { input_tokens: inp, cache_creation_input_tokens: write, cache_read_input_tokens: read, output_tokens: out } } });
|
|
20
|
+
for (const [i, tl] of tools.entries()) L.push({ type: 'user', sessionId: sid, isSidechain: !!side, uuid: `r${n}_${i}`, timestamp: iso(t + 2),
|
|
21
|
+
message: { role: 'user', content: [{ type: 'tool_result', tool_use_id: `tu_${n}_${i}`, content: pad(tl.result ?? 1200), is_error: !!tl.error }] } });
|
|
22
|
+
return out;
|
|
23
|
+
};
|
|
24
|
+
const step = (o = {}) => {
|
|
25
|
+
const resultChars = (o.tools || []).reduce((s, x) => s + (x.result ?? 1200), 0);
|
|
26
|
+
const read = o.miss ? 0 : prevCtx, write = Math.max(0, ctx - read);
|
|
27
|
+
const out = assistant({ ...o, read, write });
|
|
28
|
+
prevCtx = ctx; ctx += out + resultChars / 4 + 40; t += o.pause || 6 + r() * 20;
|
|
29
|
+
};
|
|
30
|
+
for (let i = 1; i <= 30; i++) {
|
|
31
|
+
const tools = [];
|
|
32
|
+
if (i === 5) tools.push({ name: 'Read', input: { file_path: 'src/big-generated-file.json' }, result: 160000 });
|
|
33
|
+
else if (i === 8 || i === 15) tools.push({ name: 'Grep', input: { pattern: 'TODO', path: 'src' }, result: 6000 });
|
|
34
|
+
else if (i >= 22 && i <= 25) tools.push({ name: 'Bash', input: { command: 'npm test -- --grep flaky' }, result: 2400, error: true });
|
|
35
|
+
else if (i < 30) tools.push({ name: ['Read', 'Edit', 'Bash', 'Glob'][i % 4], input: { n: i }, result: 800 + r() * 3000 });
|
|
36
|
+
step({ tools, miss: i === 12 || i === 20, pause: i === 19 ? 420 : undefined });
|
|
37
|
+
if (i === 10) { // a one-shot Explore subagent; its last call writes cache nobody reads
|
|
38
|
+
const saved = [t, ctx, prevCtx]; ctx = 9000; prevCtx = 0;
|
|
39
|
+
for (let k = 0; k < 4; k++) { const read = prevCtx, write = ctx - read; const out = assistant({ side: 'agent-explore-1', read, write, tools: k < 3 ? [{ name: 'Grep', input: { k } , result: 3000 }] : [] }); prevCtx = ctx; ctx += out + 800; t += 4; }
|
|
40
|
+
[t, ctx, prevCtx] = [saved[0] + 20, saved[1] + 600, saved[2]];
|
|
41
|
+
}
|
|
42
|
+
if (i === 1 || i === 16) assistant({ model: 'claude-haiku-4-5-20251001', read: 0, write: 0, inp: 600, out: 12 }); // title / summary side calls
|
|
43
|
+
}
|
|
44
|
+
return L.map(x => JSON.stringify(x)).join('\n') + '\n';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ---------- Codex ----------
|
|
48
|
+
export function codexSession({ seed = 11 } = {}) {
|
|
49
|
+
const r = rng(seed), L = [], id = 'demo-codex-1';
|
|
50
|
+
let t = T0 + 3600, ctx = 14000, cached = 0, total = { input_tokens: 0, cached_input_tokens: 0, output_tokens: 0, reasoning_output_tokens: 0, total_tokens: 0 };
|
|
51
|
+
L.push({ timestamp: iso(t), type: 'session_meta', payload: { id, timestamp: iso(t), cwd: '/work/demo', originator: 'codex_cli_rs', cli_version: '0.164.0' } });
|
|
52
|
+
L.push({ timestamp: iso(t), type: 'turn_context', payload: { model: 'gpt-5', cwd: '/work/demo' } });
|
|
53
|
+
for (let i = 1; i <= 20; i++) {
|
|
54
|
+
t += 8 + r() * 25;
|
|
55
|
+
const cmd = i === 6 || i === 13 ? ['cat', 'package-lock.json'] : i === 9 ? ['rg', '--files'] : ['bash', '-lc', `step ${i}`];
|
|
56
|
+
const out = 80 + Math.round(r() * 300), reasoning = Math.round(out * 0.6);
|
|
57
|
+
const last = { input_tokens: ctx, cached_input_tokens: cached, output_tokens: out, reasoning_output_tokens: reasoning, total_tokens: ctx + out };
|
|
58
|
+
for (const k of Object.keys(total)) total[k] += last[k];
|
|
59
|
+
if (i < 20) L.push({ timestamp: iso(t), type: 'response_item', payload: { type: 'function_call', name: 'shell', arguments: JSON.stringify({ command: cmd }), call_id: `call_${i}` } });
|
|
60
|
+
L.push({ timestamp: iso(t), type: 'event_msg', payload: { type: 'token_count', info: { total_token_usage: { ...total }, last_token_usage: last, model_context_window: 272000 } } });
|
|
61
|
+
const resChars = cmd[1] === 'package-lock.json' ? 120000 : i === 9 ? 40000 : 1500 + r() * 4000;
|
|
62
|
+
if (i < 20) L.push({ timestamp: iso(t + 3), type: 'response_item', payload: { type: 'function_call_output', call_id: `call_${i}`, output: JSON.stringify({ output: pad(resChars), metadata: { exit_code: 0 } }) } });
|
|
63
|
+
cached = i === 15 ? 0 : Math.floor(ctx / 64) * 64; // call 16 misses: the harness rewrote its instructions
|
|
64
|
+
ctx += out + resChars / 4 + 30;
|
|
65
|
+
}
|
|
66
|
+
return L.map(x => JSON.stringify(x)).join('\n') + '\n';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------- OTel (LangGraph-style agent → vLLM) ----------
|
|
70
|
+
const TOOLS = ['search_docs', 'get_ticket', 'update_ticket', 'run_sql', 'send_email', 'create_calendar_event', 'translate', 'summarize_pdf', 'web_fetch', 'get_weather', 'lookup_user', 'file_upload'];
|
|
71
|
+
export function otelAgent({ seed = 5, runs = 3 } = {}) {
|
|
72
|
+
const r = rng(seed), spans = [], engine = [];
|
|
73
|
+
const ns = s => String(BigInt(Math.round(s * 1e3)) * 1000000n);
|
|
74
|
+
const kv = o => Object.entries(o).filter(([, v]) => v != null).map(([key, v]) => ({ key, value: typeof v === 'number' ? (Number.isInteger(v) ? { intValue: String(v) } : { doubleValue: v }) : { stringValue: String(v) } }));
|
|
75
|
+
const defs = JSON.stringify(TOOLS.map(name => ({ type: 'function', name, description: pad(160, 'd'), parameters: { type: 'object', properties: { q: { type: 'string', description: pad(80, 'p') } } } })));
|
|
76
|
+
let sp = 0; const id = () => (++sp).toString(16).padStart(16, '0');
|
|
77
|
+
for (let run = 0; run < runs; run++) {
|
|
78
|
+
const traceId = (run + 1).toString(16).padStart(32, 'a'), conv = `support-thread-${run + 1}`, root = id();
|
|
79
|
+
let t = T0 + 7200 + run * 1800, ctx = 2500 + estDefs(defs), prev = 0;
|
|
80
|
+
const steps = 6 + Math.floor(r() * 4), start = t;
|
|
81
|
+
for (let k = 0; k < steps; k++) {
|
|
82
|
+
const chat = id(), out = 60 + Math.round(r() * 200), prefill = ctx / 9000, decode = out / 45, queue = 0.02 + r() * 0.2, e2e = queue + prefill + decode;
|
|
83
|
+
const cachedTok = k === 0 ? 0 : run === 2 && k === 3 ? 0 : Math.floor(prev / 16) * 16;
|
|
84
|
+
spans.push({ traceId, spanId: chat, parentSpanId: root, name: 'chat llama-3.3-70b', kind: 3, startTimeUnixNano: ns(t), endTimeUnixNano: ns(t + e2e + 0.01),
|
|
85
|
+
attributes: kv({ 'gen_ai.operation.name': 'chat', 'gen_ai.provider.name': 'vllm', 'gen_ai.request.model': 'llama-3.3-70b', 'gen_ai.response.model': 'llama-3.3-70b', 'gen_ai.conversation.id': conv,
|
|
86
|
+
'gen_ai.usage.input_tokens': ctx, 'gen_ai.usage.cache_read.input_tokens': cachedTok, 'gen_ai.usage.output_tokens': out, 'gen_ai.tool.definitions': defs }) });
|
|
87
|
+
engine.push({ traceId, spanId: id(), parentSpanId: chat, name: 'llm_request', startTimeUnixNano: ns(t + 0.005), endTimeUnixNano: ns(t + 0.005 + e2e),
|
|
88
|
+
attributes: kv({ 'gen_ai.request.model': 'llama-3.3-70b', 'gen_ai.usage.prompt_tokens': ctx, 'gen_ai.usage.completion_tokens': out, 'gen_ai.latency.time_in_queue': queue,
|
|
89
|
+
'gen_ai.latency.time_to_first_token': queue + prefill, 'gen_ai.latency.e2e': e2e, 'gen_ai.latency.time_in_model_prefill': prefill, 'gen_ai.latency.time_in_model_decode': decode,
|
|
90
|
+
'k8s.pod.name': run % 2 ? 'vllm-llama70b-1' : 'vllm-llama70b-0' }) });
|
|
91
|
+
t += e2e + 0.02;
|
|
92
|
+
if (k < steps - 1) {
|
|
93
|
+
const name = ['search_docs', 'get_ticket', 'update_ticket'][k % 3], big = run === 1 && k === 1, fail = run === 0 && k >= 2 && k <= 5;
|
|
94
|
+
const tool = fail ? 'run_sql' : name, res = big ? 60000 : 1600 + r() * 2000, dur = 0.3 + r() * 1.5;
|
|
95
|
+
spans.push({ traceId, spanId: id(), parentSpanId: root, name: `execute_tool ${tool}`, startTimeUnixNano: ns(t), endTimeUnixNano: ns(t + dur), status: fail ? { code: 2 } : {},
|
|
96
|
+
attributes: kv({ 'gen_ai.operation.name': 'execute_tool', 'gen_ai.tool.name': tool, 'gen_ai.tool.call.id': `tc_${run}_${k}`, 'gen_ai.tool.call.arguments': fail ? '{"q":"select broken"}' : `{"q":"${k}"}`,
|
|
97
|
+
'gen_ai.tool.call.result': pad(res), 'error.type': fail ? 'tool_error' : null }) });
|
|
98
|
+
t += dur; prev = ctx; ctx += out + res / 4 + 20;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
spans.push({ traceId, spanId: root, name: 'invoke_agent support-agent', startTimeUnixNano: ns(start), endTimeUnixNano: ns(t), attributes: kv({ 'gen_ai.operation.name': 'invoke_agent', 'gen_ai.agent.name': 'support-agent', 'gen_ai.conversation.id': conv }) });
|
|
102
|
+
}
|
|
103
|
+
const body = s => ({ resourceSpans: [{ resource: { attributes: kv({ 'service.name': s.svc }) }, scopeSpans: [{ scope: { name: s.scope }, spans: s.spans }] }] });
|
|
104
|
+
return { harness: body({ svc: 'langgraph-support', scope: 'opentelemetry.instrumentation.langchain', spans }), engine: body({ svc: 'vllm', scope: 'vllm', spans: engine }),
|
|
105
|
+
replicas: { 'vllm-llama70b-0': { gpus: 4, gpuType: 'H100', rate: 2.5 }, 'vllm-llama70b-1': { gpus: 4, gpuType: 'H100', rate: 2.5 } },
|
|
106
|
+
outcomes: { 'support-thread-1': 'failure', 'support-thread-2': 'success', 'support-thread-3': 'success' } };
|
|
107
|
+
}
|
|
108
|
+
const estDefs = d => Math.ceil(d.length / 4);
|
|
109
|
+
|
|
110
|
+
export function demoInputs() {
|
|
111
|
+
const o = otelAgent();
|
|
112
|
+
return { files: [{ name: 'claude-code/demo-cc-1.jsonl', text: claudeCodeSession() }, { name: 'codex/rollout-2026-11-24T17-00-00-demo-codex-1.jsonl', text: codexSession() },
|
|
113
|
+
{ name: 'otel/langgraph-support.json', text: JSON.stringify(o.harness) }], engine: o.engine, replicas: o.replicas,
|
|
114
|
+
outcomes: { ...o.outcomes, 'demo-cc-1': 'success', 'demo-codex-1': 'success' } };
|
|
115
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Agent unit economics: what a successful task costs, what each fix is worth per successful task, and where hosting an
|
|
2
|
+
// open model yourself beats paying an API for the same work.
|
|
3
|
+
//
|
|
4
|
+
// cost per resolved task priced calls (list prices, recorded cost, or GPU time) over sessions with outcomes
|
|
5
|
+
// fixes, ranked each waste cause's avoidable cost, per resolved task, and what a step cap on sessions saves
|
|
6
|
+
// against the successes it costs (exact, from each session's own calls)
|
|
7
|
+
// self-host vs API the same workload (its real arrivals, prompt growth and cache reuse) sized with the
|
|
8
|
+
// Inference Sizer for an open model on a GPU, through FleetScope's agentic profile path
|
|
9
|
+
// (compute and the KV working set), against the API bill for it; or measured self-host
|
|
10
|
+
// prices per million tokens (OpenCost's llm_cost_per_million_tokens) instead of sizing.
|
|
11
|
+
// tokenScale: the open model needs k× the calls per task (e.g. SWE-bench's calls ratio).
|
|
12
|
+
// The answer is a break-even: the GPU-hour price under which self-hosting is cheaper per
|
|
13
|
+
// resolved task, and the volume at which it becomes cheaper at a given GPU-hour price.
|
|
14
|
+
//
|
|
15
|
+
// Everything here is a model. The self-host side is provisioned for the busiest day's peak, kept on all month
|
|
16
|
+
// (allocation-based cost), and assumes the open model needs as many calls per task as the API one unless told otherwise.
|
|
17
|
+
import { createRequire } from 'node:module';
|
|
18
|
+
import { sessionsOf, fresh } from './record.mjs';
|
|
19
|
+
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const A = require('../../fleetscope/src/agentic.js'), C = require('../../inference-sizer/src/catalog.js'), M = require('../../inference-sizer/src/model.js');
|
|
22
|
+
const HOURS_PER_MONTH = 730, DAY = 86400;
|
|
23
|
+
const sum = (xs, f) => xs.reduce((s, x) => s + (f(x) || 0), 0);
|
|
24
|
+
|
|
25
|
+
// ---------- the workload ----------
|
|
26
|
+
export function period(calls, days = null) {
|
|
27
|
+
const ts = calls.map(c => c.t).filter(Number.isFinite); let a = Infinity, b = -Infinity; for (const t of ts) { if (t < a) a = t; if (t > b) b = t; }
|
|
28
|
+
const span = ts.length ? (b - a) / DAY : 0;
|
|
29
|
+
return { from: ts.length ? a : null, to: ts.length ? b : null, days: days || Math.max(1, span), measured: !days, short: !days && span < 1 };
|
|
30
|
+
}
|
|
31
|
+
// llm_call records → FleetScope trace rows (prompt, output, cache hit, session, time)
|
|
32
|
+
export const rowsOf = calls => calls.filter(c => Number.isFinite(c.t) && c.input > 0).map(c => ({ t: c.t, isl: c.input, osl: Math.max(1, c.output || 1), cached: c.cacheRead ?? undefined, session: `${c.harness}|${c.session}`, agent: c.agent && c.agent !== 'main' ? c.agent : undefined, api: c.durS }));
|
|
33
|
+
// calendar days (UTC) by calls: the median active day, for a second sizing beside the busiest
|
|
34
|
+
export function typicalDay(rows) {
|
|
35
|
+
const by = new Map(); for (const r of rows) { const d = Math.floor(r.t / DAY); if (!by.has(d)) by.set(d, []); by.get(d).push(r); }
|
|
36
|
+
const days = [...by.values()].sort((a, b) => a.length - b.length); return days.length ? days[Math.floor((days.length - 1) / 2)] : [];
|
|
37
|
+
}
|
|
38
|
+
// the 24 hours with the most calls: self-hosted capacity is bought for the peak, not the average
|
|
39
|
+
export function busiestDay(rows) {
|
|
40
|
+
const s = [...rows].sort((a, b) => a.t - b.t); let best = [0, 0], j = 0;
|
|
41
|
+
for (let i = 0; i < s.length; i++) { while (s[i].t - s[j].t >= DAY) j++; if (i - j + 1 > best[1] - best[0]) best = [j, i + 1]; }
|
|
42
|
+
return s.slice(best[0], best[1]);
|
|
43
|
+
}
|
|
44
|
+
// a workload x times as large: the same shape, x times the arrivals
|
|
45
|
+
export function scaleStats(st, x) {
|
|
46
|
+
const k = (o, f) => (o ? Object.fromEntries(Object.entries(o).map(([a, v]) => [a, typeof v === 'number' ? f(v) : v])) : o);
|
|
47
|
+
return Object.assign({}, st, { rps: k(st.rps, v => v * x), prefillTps: k(st.prefillTps, v => v * x), decodeTps: k(st.decodeTps, v => v * x), kvTokens: k(st.kvTokens, v => v * x), inflight: k(st.inflight, v => Math.max(1, Math.round(v * x))) });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------- self-hosting: GPUs from the Inference Sizer ----------
|
|
51
|
+
// The sizer's production defaults: whole nodes, plus one spare node (spare: false drops it)
|
|
52
|
+
// calibration: a sizer profile ({ sizer: { "<gpu>|<model>": { effPrefill, effDecodeBW, effDecodeComp } } }) from fleetops
|
|
53
|
+
// calibrate or a promoted shadow upgrade: measured engine efficiencies instead of spec-sheet defaults
|
|
54
|
+
export function sizerSettings({ model = 'deepseek-v3', gpu = 'H200', ttft = 2000, tpot = 50, spare = true, calibration = null } = {}) {
|
|
55
|
+
const m = C.MODELS.find(x => x.id === model), g = C.GPUS.find(x => x.id === gpu);
|
|
56
|
+
if (!m) throw new Error(`unknown model ${model}: one of ${C.MODELS.map(x => x.id).join(', ')}`);
|
|
57
|
+
if (!g) throw new Error(`unknown GPU ${gpu}: one of ${C.GPUS.map(x => x.id).join(', ')}`);
|
|
58
|
+
const cal = calibration && calibration.sizer && (calibration.sizer[`${g.id}|${m.id}`] || calibration.sizer[`${g.id}|*`]);
|
|
59
|
+
const eff = cal ? Object.fromEntries(['effPrefill', 'effDecodeBW', 'effDecodeComp', 'stepMs'].filter(k => typeof cal[k] === 'number').map(k => [k, cal[k]])) : {};
|
|
60
|
+
return Object.assign({}, M.SETTINGS, m, g, eff, { ttft: +ttft, tpot: +tpot, ctx: m.maxCtx || M.SETTINGS.ctx, modelId: m.id, gpuId: g.id, nPlus1: spare !== false, calibrated: cal ? (cal.fitOn || 'calibration profile') : null });
|
|
61
|
+
}
|
|
62
|
+
// calls longer than the open model's context are capped to it (and counted: the open model can't serve them as they are)
|
|
63
|
+
export function peakStats(rows, s, { cacheTtlS = 300 } = {}) {
|
|
64
|
+
let over = 0; const fit = rows.map(r => (r.isl + r.osl > s.ctx ? (over++, Object.assign({}, r, { isl: Math.max(1, s.ctx - r.osl), cached: r.cached != null ? Math.min(r.cached, s.ctx - r.osl - 1) : r.cached })) : r));
|
|
65
|
+
const day = busiestDay(fit), typ = typicalDay(fit);
|
|
66
|
+
return { stats: A.workloadStats(day, { cacheTtlS }), typical: typ.length ? A.workloadStats(typ, { cacheTtlS }) : null, overContext: over, calls: rows.length, peakDayCalls: day.length, typicalDayCalls: typ.length };
|
|
67
|
+
}
|
|
68
|
+
// sizeOpts: { kvOffload, offload: { cpuGBPerGpu, pcieGBs } } — contexts that don't fit in HBM held in host memory
|
|
69
|
+
export function gpusFor(stats, s, x = 1, sizeOpts = {}) { return A.sizeFor(scaleStats(stats, x), s, M, sizeOpts); }
|
|
70
|
+
|
|
71
|
+
// ---------- outcomes and fixes ----------
|
|
72
|
+
export function perResolved(report) {
|
|
73
|
+
const o = report.outcomes, t = report.totals, tasks = o.successes + o.failures + o.unknown;
|
|
74
|
+
return { tasks, successes: o.successes, failures: o.failures, unknown: o.unknown, known: o.known, successRate: o.successes + o.failures ? o.successes / (o.successes + o.failures) : null,
|
|
75
|
+
cost: t.cost, costPerTask: tasks ? t.cost / tasks : null, costPerResolved: o.successes ? t.cost / o.successes : null, spentOnFailures: o.costOnFailure, failShare: t.cost ? o.costOnFailure / t.cost : null };
|
|
76
|
+
}
|
|
77
|
+
// Exact step caps: stop each session after `cap` calls. The cost is its first `cap` calls' cost; a success that needed
|
|
78
|
+
// more calls is lost. (outcomes.mjs estimates the same from task totals when there are no per-call records.)
|
|
79
|
+
export function exactCaps(calls, caps = [10, 20, 30, 40, 50, 75, 100, 150, 200, 300]) {
|
|
80
|
+
const sess = [...sessionsOf(calls).values()].map(cs => ({ calls: cs.length, cum: cs.reduce((a, c) => (a.push((a.at(-1) || 0) + (c.cost || 0)), a), []), outcome: (cs.find(c => c.outcome) || {}).outcome }));
|
|
81
|
+
const known = sess.filter(s => s.outcome === 'success' || s.outcome === 'failure'); if (!known.length) return null;
|
|
82
|
+
const cost0 = sum(known, s => s.cum.at(-1)), succ0 = known.filter(s => s.outcome === 'success').length, maxCalls = Math.max(...known.map(s => s.calls));
|
|
83
|
+
return caps.filter(c => c < maxCalls).map(cap => {
|
|
84
|
+
const cost = sum(known, s => s.cum[Math.min(cap, s.calls) - 1]), succ = known.filter(s => s.outcome === 'success' && s.calls <= cap).length;
|
|
85
|
+
return { cap, saved: cost0 ? 1 - cost / cost0 : 0, successesLost: succ0 - succ, rateLossPts: 100 * (succ0 - succ) / known.length, costPerResolved: succ ? cost / succ : null };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export function rankFixes(report, calls, { maxLossPts = 1 } = {}) {
|
|
89
|
+
const t = report.totals, s = report.outcomes.successes || null, per = x => (s ? x / s : null);
|
|
90
|
+
const rows = report.byCause.filter(c => !c.candidate && c.cost > 0).map(c => ({ cause: c.cause, label: c.label, fix: c.fix, saves: c.cost, share: t.cost ? c.cost / t.cost : null, perResolved: per(c.cost), kind: 'waste' }));
|
|
91
|
+
const caps = exactCaps(calls), cap = caps && caps.filter(c => c.rateLossPts <= maxLossPts).sort((a, b) => b.saved - a.saved)[0];
|
|
92
|
+
if (cap && cap.saved > 0) rows.push({ cause: 'step-cap', label: `Stop sessions after ${cap.cap} calls`, fix: `Cap agent loops at ${cap.cap} calls (or a spend limit): ${cap.successesLost} successes lost (${cap.rateLossPts.toFixed(1)} points).`, saves: cap.saved * t.cost, share: cap.saved, perResolved: per(cap.saved * t.cost), kind: 'cap', lostPts: cap.rateLossPts });
|
|
93
|
+
rows.sort((a, b) => b.saves - a.saves);
|
|
94
|
+
// fixes overlap (a capped session's waste is gone too), so the running total is bounded by the spend, and the step cap
|
|
95
|
+
// is not added on top of the waste it would also remove: the cumulative column is an upper bound
|
|
96
|
+
let cum = 0; for (const r of rows) { cum = Math.min(t.cost, cum + r.saves); r.cumulative = cum; r.costPerResolvedAfter = s ? (t.cost - cum) / s : null; }
|
|
97
|
+
const candidates = report.byCause.filter(c => c.candidate && c.cost > 0).map(c => ({ cause: c.cause, label: c.label, saves: c.cost, perResolved: per(c.cost), fix: c.fix }));
|
|
98
|
+
return { rows, candidates, caps };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------- self-host vs API ----------
|
|
102
|
+
// api: { monthly } in the report's currency (or units, with unitPrice $ per unit); self: { gpus, rate? } or
|
|
103
|
+
// { pricePerM: { input, cacheRead?, output } } from measured self-host prices; success rates scale cost per resolved.
|
|
104
|
+
export function breakEven({ apiMonthly, apiRate = null, selfRate = null, gpus = null, gpuRate = null, unit = 1 }) {
|
|
105
|
+
const q = apiRate && selfRate ? selfRate / apiRate : 1; // successes per task, self-host over API: fewer successes make each cost more
|
|
106
|
+
const api$ = apiMonthly * unit;
|
|
107
|
+
const rateStar = gpus ? api$ * q / (gpus * HOURS_PER_MONTH) : null; // the GPU-hour price at which both cost the same per resolved task
|
|
108
|
+
const self$ = gpus && gpuRate != null ? gpus * gpuRate * HOURS_PER_MONTH : null;
|
|
109
|
+
return { apiMonthly: api$, selfMonthly: self$, qualityRatio: q, breakEvenGpuRate: rateStar, cheaper: self$ == null ? null : self$ / q < api$ ? 'self-host' : 'api', perResolvedRatio: self$ == null || !api$ ? null : (self$ / q) / api$ };
|
|
110
|
+
}
|
|
111
|
+
// the volume (× today's) from which self-hosting is cheaper per resolved task at gpuRate: API cost grows with volume,
|
|
112
|
+
// self-hosted cost in steps of GPUs
|
|
113
|
+
export function breakEvenVolume(stats, s, { apiMonthly, gpuRate, q = 1, unit = 1, base = 1, lo = 1 / 64, hi = 256, sizeOpts = {} } = {}) {
|
|
114
|
+
const pts = []; for (let x = lo; x <= hi * 1.0001; x *= Math.SQRT2) pts.push(x);
|
|
115
|
+
const at = x => { const r = gpusFor(stats, s, base * x, sizeOpts); return { x, gpus: r.gpus, api: apiMonthly * unit * x, self: r.gpus == null ? null : r.gpus * gpuRate * HOURS_PER_MONTH / q }; };
|
|
116
|
+
const curve = pts.map(at), first = curve.find(p => p.self != null && p.self < p.api);
|
|
117
|
+
return { curve, from: first ? first.x : null, note: first ? null : `not cheaper anywhere up to ${hi / base >= 1 ? Math.round(hi / base) : hi}× today's volume` };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function economics(calls, report, opt = {}) {
|
|
121
|
+
const P = period(calls, opt.days), scale = opt.tasksPerDay ? opt.tasksPerDay / (report.totals.sessions / P.days) : opt.scale || 1;
|
|
122
|
+
const monthly = report.totals.cost / P.days * 30.4 * scale, units = report.pricing && report.pricing.currency === 'units';
|
|
123
|
+
const tok = k => sum(calls, k) / P.days * 30.4 * scale;
|
|
124
|
+
const volume = { days: P.days, measured: P.measured, short: P.short, scale, sessionsPerDay: report.totals.sessions / P.days * scale, callsPerDay: calls.length / P.days * scale,
|
|
125
|
+
monthTokens: { fresh: tok(fresh), cacheRead: tok(c => c.cacheRead), cacheWrite: tok(c => c.cacheWrite), output: tok(c => c.output) }, apiMonthly: monthly, currency: report.pricing ? report.pricing.currency : 'USD' };
|
|
126
|
+
const out = { volume, perResolved: perResolved(report), fixes: rankFixes(report, calls, opt), selfHost: null };
|
|
127
|
+
const apiRate = opt.apiSuccessRate ?? out.perResolved.successRate ?? null, selfRate = opt.selfSuccessRate ?? apiRate;
|
|
128
|
+
const tokenScale = opt.tokenScale || 1;
|
|
129
|
+
if (opt.selfHostPrice) { // measured self-host prices: no sizing
|
|
130
|
+
const p = opt.selfHostPrice, m = volume.monthTokens, self = tokenScale * ((m.fresh + m.cacheWrite) * p.input + m.cacheRead * (p.cacheRead ?? 0) + m.output * p.output) / 1e6;
|
|
131
|
+
const q = apiRate && selfRate ? selfRate / apiRate : 1, api$ = monthly * (units ? (opt.unitPrice || 1) : 1);
|
|
132
|
+
out.selfHost = { source: p.source || 'measured self-host prices per million tokens', monthly: self, apiMonthly: api$, qualityRatio: q, cheaper: self / q < api$ ? 'self-host' : 'api', perResolvedRatio: api$ ? (self / q) / api$ : null };
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
if (opt.model || opt.gpu) {
|
|
136
|
+
// tokenScale: the open model makes k× the calls per task (same shape), so it serves k× the arrivals for the same work
|
|
137
|
+
const s = sizerSettings(opt), rows = rowsOf(calls), k = scale * tokenScale;
|
|
138
|
+
const sizeOpts = { kvOffload: !!opt.kvOffload, offload: Object.fromEntries([['cpuGBPerGpu', opt.cpuKvGB], ['pcieGBs', opt.pcieGBs]].filter(([, v]) => v != null)) };
|
|
139
|
+
const pk = peakStats(rows, s, opt), sized = gpusFor(pk.stats, s, k, sizeOpts), sizedTyp = pk.typical ? gpusFor(pk.typical, s, k, sizeOpts) : null;
|
|
140
|
+
const unit = units ? (opt.unitPrice || 1) : 1, be = breakEven({ apiMonthly: monthly, apiRate, selfRate, gpus: sized.gpus, gpuRate: opt.gpuRate ?? null, unit });
|
|
141
|
+
out.selfHost = { model: s.modelId, gpu: s.gpuId, ttft: s.ttft, tpot: s.tpot, calibrated: s.calibrated, gpus: sized.gpus, compute: sized.compute, kvGpus: sized.kvGpus, bound: sized.bound, mode: sized.mode, offload: sized.offload, kvOffloadUsed: sized.kvOffloadUsed, power: sized.power,
|
|
142
|
+
peak: { calls: pk.peakDayCalls, rpsP95: pk.stats.rps.p95 * k, cacheHit: pk.stats.cacheHit, kvTokensP95: pk.stats.kvTokens.p95 * k }, overContext: pk.overContext, overContextShare: pk.calls ? pk.overContext / pk.calls : 0, tokenScale, spare: s.nPlus1,
|
|
143
|
+
typicalDay: sizedTyp ? { calls: pk.typicalDayCalls, gpus: sizedTyp.gpus, breakEvenGpuRate: breakEven({ apiMonthly: monthly, apiRate, selfRate, gpus: sizedTyp.gpus, unit: units ? (opt.unitPrice || 1) : 1 }).breakEvenGpuRate } : null,
|
|
144
|
+
successRates: { api: apiRate, self: selfRate, assumed: opt.selfSuccessRate == null }, gpuRate: opt.gpuRate ?? null, unitPrice: units ? unit : null, ...be };
|
|
145
|
+
if (opt.gpuRate != null && sized.gpus) {
|
|
146
|
+
out.selfHost.volume = breakEvenVolume(pk.stats, s, { apiMonthly: monthly, gpuRate: opt.gpuRate, q: be.qualityRatio, unit, base: k, sizeOpts });
|
|
147
|
+
// many teams' bursts don't line up: sized on a typical day's shape, the crossover is an optimistic bound
|
|
148
|
+
if (pk.typical) out.selfHost.volumeTypical = breakEvenVolume(pk.typical, s, { apiMonthly: monthly, gpuRate: opt.gpuRate, q: be.qualityRatio, unit, base: k, sizeOpts });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ---------- text ----------
|
|
155
|
+
const $f = (n, cur) => (n == null || !Number.isFinite(n) ? '–' : cur === 'units' ? (n >= 100 ? n.toFixed(0) : n.toFixed(2)) + ' u' : n >= 1e4 ? '$' + Math.round(n).toLocaleString('en-US') : n >= 100 ? '$' + n.toFixed(0) : n >= 1 ? '$' + n.toFixed(2) : '$' + n.toFixed(3));
|
|
156
|
+
const P = x => (x == null || !Number.isFinite(x) ? '–' : `${(100 * x).toFixed(x < 0.1 ? 1 : 0)}%`);
|
|
157
|
+
const N = n => (n >= 1e9 ? (n / 1e9).toFixed(2) + 'B' : n >= 1e6 ? (n / 1e6).toFixed(1) + 'M' : n >= 1e3 ? (n / 1e3).toFixed(1) + 'k' : String(Math.round(n)));
|
|
158
|
+
export function economicsText(E) {
|
|
159
|
+
const v = E.volume, r = E.perResolved, cur = v.currency, $ = n => $f(n, cur), L = [];
|
|
160
|
+
L.push(`Agent unit economics over ${v.days.toFixed(v.days < 10 ? 1 : 0)} days${v.scale !== 1 ? ` (scaled ×${v.scale.toFixed(2)})` : ''}${v.short ? ' (under a day of timestamps: pass --days or --tasks-per-day for monthly figures)' : ''}`);
|
|
161
|
+
L.push(` ${v.sessionsPerDay.toFixed(1)} sessions and ${N(v.callsPerDay)} calls a day; ${$(v.apiMonthly)} a month at this rate`);
|
|
162
|
+
if (r.known) L.push(` ${r.successes} of ${r.successes + r.failures} tasks succeeded (${P(r.successRate)}): ${$(r.costPerResolved)} per resolved task, ${$(r.costPerTask)} per task; ${P(r.failShare)} of spend went to tasks that failed`);
|
|
163
|
+
else L.push(' no outcomes: pass --outcomes (session → success/failure) for cost per resolved task');
|
|
164
|
+
L.push('', 'Fixes, ranked by what they save' + (r.known ? ' (per resolved task)' : '') + ':');
|
|
165
|
+
for (const f of E.fixes.rows.slice(0, 8)) L.push(` ${$(f.saves).padStart(10)} ${P(f.share).padStart(4)}${r.known ? ` ${$(f.perResolved).padStart(8)}/resolved → ${$(f.costPerResolvedAfter).padStart(8)}` : ''} ${f.label}`);
|
|
166
|
+
if (!E.fixes.rows.length) L.push(' nothing found');
|
|
167
|
+
if (E.fixes.rows.length) L.push(` together at most ${$(E.fixes.rows.at(-1).cumulative)} (${P(E.fixes.rows.at(-1).cumulative / r.cost)}): fixes overlap, so this is an upper bound`);
|
|
168
|
+
for (const c of E.fixes.candidates) L.push(` candidate: ${c.label}, ${$(c.saves)}: check task success before switching`);
|
|
169
|
+
const S = E.selfHost;
|
|
170
|
+
if (S && S.model) {
|
|
171
|
+
L.push('', `Self-hosting ${S.model} on ${S.gpu} (TTFT ${S.ttft} ms, TPOT ${S.tpot} ms${S.calibrated ? `; measured efficiencies: ${S.calibrated}` : '; spec-sheet efficiencies'}) for the busiest day's peak: ${S.gpus ?? 'no layout meets the targets'} GPUs (compute ${S.compute ?? '–'}, KV working set ${S.kvGpus}; bound by ${S.bound}; whole nodes${S.spare ? ', one spare' : ''})`);
|
|
172
|
+
L.push(` peak ${S.peak.rpsP95.toFixed(2)} calls/s (p95 minute of the busiest day, ${N(S.peak.calls)} calls), cache hit ${P(S.peak.cacheHit)}${S.typicalDay ? `; a typical day (${N(S.typicalDay.calls)} calls) needs ${S.typicalDay.gpus ?? '–'}` : ''}`);
|
|
173
|
+
if (S.offload) L.push(` KV offload ${S.kvOffloadUsed ? 'used' : !S.offload.usable ? 'not usable here' : S.offload.gpus < S.gpus ? `would bring it to ${S.offload.gpus} GPUs (--kv-offload)` : 'not needed: compute sets the count'}: with ${S.offload.cpuGBPerGpu} GB of host memory per GPU, ${S.offload.gpus ?? '–'} GPUs (${P(S.offload.offloadedShare)} of the working set in host memory), a returning session reloads in ${S.offload.reloadMs.toFixed(0)} ms, PCIe ${P(S.offload.pcieUtil)} busy`);
|
|
174
|
+
if (S.power && S.power.tokensPerSecPerMW != null) L.push(` ${Math.round(S.power.tokensPerSecPerMW).toLocaleString('en-US')} output tokens/s per MW at the peak minute (${S.power.kw.toFixed(0)} kW provisioned, ${S.power.basis})`);
|
|
175
|
+
if (S.overContext) L.push(` ${P(S.overContextShare)} of calls are longer than ${S.model}'s context: capped here, which flatters self-hosting (the open model would need compaction, or can't do those tasks as they are)`);
|
|
176
|
+
if (S.successRates.api != null) L.push(` success: API ${P(S.successRates.api)}, self-hosted ${P(S.successRates.self)}${S.successRates.assumed ? ' (assumed the same: pass --self-host-success-rate)' : ''}`);
|
|
177
|
+
const r$ = x => (x == null ? '–' : '$' + (x >= 0.1 ? x.toFixed(2) : x.toPrecision(2)));
|
|
178
|
+
if (S.breakEvenGpuRate != null) L.push(` break-even: self-hosting is cheaper per resolved task below ${r$(S.breakEvenGpuRate)} per GPU-hour${S.typicalDay ? ` (${r$(S.typicalDay.breakEvenGpuRate)} if sized for a typical day)` : ''}${cur === 'units' ? `, at $${S.unitPrice} per relative unit (--unit-price)` : ''}`);
|
|
179
|
+
if (S.selfMonthly != null) L.push(` at $${S.gpuRate}/GPU-hour: ${$f(S.selfMonthly, 'USD')} a month self-hosted vs ${$f(S.apiMonthly, 'USD')} on the API → ${S.cheaper === 'self-host' ? 'self-hosting' : 'the API'} is cheaper (${(S.perResolvedRatio).toFixed(2)}× per resolved task)`);
|
|
180
|
+
const xf = v => (v.from == null ? null : `${v.from < 1 ? v.from.toFixed(2) : v.from.toFixed(1)}×`);
|
|
181
|
+
if (S.volume) L.push(` volume where self-hosting becomes cheaper: ${xf(S.volume) ? `about ${xf(S.volume)} this volume with this workload's own bursts` : S.volume.note.replace(/^not cheaper anywhere/, 'never with this workload\'s own bursts,')}${S.volumeTypical ? `; ${xf(S.volumeTypical) ? `about ${xf(S.volumeTypical)}` : 'never'} if peaks were like a typical day (many teams' bursts don't line up)` : ''}`);
|
|
182
|
+
} else if (S) L.push('', `Self-hosted at measured prices (${S.source}): ${$f(S.monthly, 'USD')} a month vs ${$f(S.apiMonthly, 'USD')} on the API → ${S.cheaper === 'self-host' ? 'self-hosting' : 'the API'} is cheaper (${S.perResolvedRatio.toFixed(2)}× per resolved task)`, ' measured prices hold at the utilization they were measured at: a much smaller or larger volume changes them (size it with --self-host-model instead)');
|
|
183
|
+
return L.join('\n') + '\n';
|
|
184
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Self-hosted models: what a harness's call cost in GPU time, from the serving engine's own trace.
|
|
2
|
+
//
|
|
3
|
+
// The join: harness call → engine request → replica → GPUs → $/GPU-hour.
|
|
4
|
+
// 1. Engine request spans. vLLM with --otlp-traces-endpoint writes one span per request (named llm_request) with
|
|
5
|
+
// gen_ai.latency.time_in_queue / time_to_first_token / e2e / time_in_model_prefill / time_in_model_decode and
|
|
6
|
+
// gen_ai.usage.* tokens. Any engine span carrying gen_ai.latency.e2e is read the same way.
|
|
7
|
+
// 2. Matching. When the harness propagates W3C trace context to the engine (OTel HTTP client instrumentation does),
|
|
8
|
+
// the engine span's parent is the harness's chat span: match on that. Otherwise match within the trace by time
|
|
9
|
+
// (the engine request that started closest after the call started).
|
|
10
|
+
// 3. Replicas. --replicas maps a pod or service name to { gpus, gpuType?, rate? ($/GPU-h) }, or gpu-ledger usage
|
|
11
|
+
// records are given; a missing rate comes from gpu-ledger's rate card (--gpu-prices, gpu-ledger's format).
|
|
12
|
+
// 4. Allocation. A replica's GPU cost while it was busy (the union of its requests' intervals) is split across
|
|
13
|
+
// those requests by their time in the model (prefill + decode; e2e when the split is missing). Time the replica
|
|
14
|
+
// was up between requests is idle cost, reported per replica (gpu-ledger's idle class), not charged to a harness.
|
|
15
|
+
// 5. Per-token prices for the waste checks: prefill cost spread over the tokens prefilled (fresh input; prefix-cache
|
|
16
|
+
// hits cost ~nothing), decode cost over the output tokens.
|
|
17
|
+
import { flattenSpans } from './importers.mjs';
|
|
18
|
+
import { num } from './record.mjs';
|
|
19
|
+
import { rateCard, priceOf, gpuKey } from '../../gpu-ledger/src/core.mjs';
|
|
20
|
+
|
|
21
|
+
export function engineRequests(input) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const s of flattenSpans(input)) {
|
|
24
|
+
const a = s.attrs, e2e = num(a['gen_ai.latency.e2e']);
|
|
25
|
+
if (e2e == null && s.name !== 'llm_request') continue;
|
|
26
|
+
out.push({ traceId: s.traceId, spanId: s.spanId, parentSpanId: s.parentSpanId, t: s.t, e2e: e2e ?? (s.end - s.t),
|
|
27
|
+
prefill: num(a['gen_ai.latency.time_in_model_prefill']), decode: num(a['gen_ai.latency.time_in_model_decode']), queue: num(a['gen_ai.latency.time_in_queue']),
|
|
28
|
+
replica: a['k8s.pod.name'] || a['host.name'] || a['server.address'] || s.service || 'engine', model: a['gen_ai.response.model'] || a['gen_ai.request.model'],
|
|
29
|
+
isl: num(a['gen_ai.usage.input_tokens'] ?? a['gen_ai.usage.prompt_tokens']), osl: num(a['gen_ai.usage.output_tokens'] ?? a['gen_ai.usage.completion_tokens']),
|
|
30
|
+
cached: num(a['gen_ai.usage.cache_read.input_tokens']) });
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// replicas: { name: { gpus, gpuType?, rate? } } or gpu-ledger usage records [{ name|id|labels.pod, gpus, gpuType, rate? }]
|
|
36
|
+
export function replicaRates(replicas, gpuPrices = {}) {
|
|
37
|
+
const card = rateCard(gpuPrices), out = new Map();
|
|
38
|
+
const add = (name, r) => {
|
|
39
|
+
const rate = r.rate ?? (r.gpuType ? (priceOf(card, gpuPrices, gpuKey(r.gpuType), r.provider) || {}).rate : null);
|
|
40
|
+
if (name && r.gpus) out.set(String(name), { gpus: Number(r.gpus), gpuType: r.gpuType, rate: rate ?? null });
|
|
41
|
+
};
|
|
42
|
+
if (Array.isArray(replicas)) for (const r of replicas) add(r.name || (r.labels && r.labels.pod) || r.id, r);
|
|
43
|
+
else for (const [k, v] of Object.entries(replicas || {})) add(k, v);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function joinGpu(calls, requests, rates) {
|
|
48
|
+
const bySpan = new Map(requests.filter(r => r.parentSpanId).map(r => [r.parentSpanId, r])), used = new Set(), match = new Map();
|
|
49
|
+
for (const c of calls) { const r = c.spanId && bySpan.get(c.spanId); if (r) { match.set(c, r); used.add(r); } }
|
|
50
|
+
for (const c of calls) {
|
|
51
|
+
if (match.has(c) || !c.traceId) continue;
|
|
52
|
+
const r = requests.filter(x => x.traceId === c.traceId && !used.has(x) && x.t >= c.t - 1).sort((x, y) => x.t - y.t)[0];
|
|
53
|
+
if (r) { match.set(c, r); used.add(r); }
|
|
54
|
+
}
|
|
55
|
+
// Each replica's cost while it was serving (the union of its requests' intervals) is split across those requests by
|
|
56
|
+
// their time in the model; batching makes requests overlap, so they share the busy time. The rest of the window the
|
|
57
|
+
// replica was up but idle: reported per replica, not charged to any harness.
|
|
58
|
+
const byRep = new Map(); for (const r of requests) { if (!byRep.has(r.replica)) byRep.set(r.replica, []); byRep.get(r.replica).push(r); }
|
|
59
|
+
const alloc = new Map(), replicas = [];
|
|
60
|
+
for (const [rep, rs] of byRep) {
|
|
61
|
+
const rr = rates.get(rep), from = Math.min(...rs.map(r => r.t)), to = Math.max(...rs.map(r => r.t + (r.e2e || 0)));
|
|
62
|
+
const iv = rs.map(r => [r.t, r.t + (r.e2e || 0)]).sort((a, b) => a[0] - b[0]); let busyS = 0, cur = null;
|
|
63
|
+
for (const [a, b] of iv) { if (!cur || a > cur[1]) { if (cur) busyS += cur[1] - cur[0]; cur = [a, b]; } else cur[1] = Math.max(cur[1], b); } if (cur) busyS += cur[1] - cur[0];
|
|
64
|
+
const windowS = Math.max(busyS, to - from), w = r => ((r.prefill ?? 0) + (r.decode ?? 0)) || r.e2e || 0, W = rs.reduce((s, r) => s + w(r), 0) || 1;
|
|
65
|
+
const perS = rr && rr.rate != null ? rr.gpus * rr.rate / 3600 : null, busyCost = perS != null ? perS * busyS : null;
|
|
66
|
+
replicas.push({ replica: rep, gpus: rr ? rr.gpus : null, gpuType: rr && rr.gpuType, rate: rr && rr.rate, windowS, busyS, busyShare: windowS > 0 ? busyS / windowS : null,
|
|
67
|
+
requests: rs.length, busyCost, idleCost: perS != null ? perS * (windowS - busyS) : null, priced: perS != null });
|
|
68
|
+
for (const r of rs) alloc.set(r, { cost: busyCost != null ? busyCost * w(r) / W : null, gpuS: rr ? rr.gpus * busyS * w(r) / W : null });
|
|
69
|
+
}
|
|
70
|
+
const prices = new Map();
|
|
71
|
+
for (const [c, r] of match) {
|
|
72
|
+
const a = alloc.get(r); c.engine = { replica: r.replica, e2e: r.e2e, prefill: r.prefill, decode: r.decode, queue: r.queue, gpuS: a.gpuS };
|
|
73
|
+
if (a.cost == null) continue;
|
|
74
|
+
const pf = r.prefill != null && r.decode != null && r.prefill + r.decode > 0 ? r.prefill / (r.prefill + r.decode) : 0.5;
|
|
75
|
+
const freshT = Math.max(1, (c.input || 0) - (c.cacheRead || 0)); // prefilled tokens: everything not served from the prefix cache
|
|
76
|
+
const pin = a.cost * pf / freshT, pout = a.cost * (1 - pf) / Math.max(1, c.output || 0);
|
|
77
|
+
prices.set(c, { in: pin, read: 0, write: pin, out: pout, source: `GPU time on ${r.replica}`, total: a.cost });
|
|
78
|
+
}
|
|
79
|
+
return { prices, matched: match.size, requests: requests.length, replicas };
|
|
80
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// One self-contained HTML page: the funnel from tokens to avoidable dollars, causes, harnesses, tools, sessions, and
|
|
2
|
+
// GPU replicas when the engine's trace was joined. Same palette and layout as gpu-ledger's page.
|
|
3
|
+
import { CAUSES, fmtN, pct, moneyFor } from './ledger.mjs';
|
|
4
|
+
|
|
5
|
+
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
6
|
+
const day = t => (t ? new Date(t * 1000).toISOString().slice(0, 16).replace('T', ' ') : '–');
|
|
7
|
+
|
|
8
|
+
export function html(r, { title = 'Harness ledger: where agents waste model resources' } = {}) {
|
|
9
|
+
const t = r.totals, fmt$ = moneyFor(r);
|
|
10
|
+
const fmax = Math.max(1, ...r.funnel.map(f => f.tokens));
|
|
11
|
+
const funnel = r.funnel.map((f, i) => {
|
|
12
|
+
const avoid = /Avoidable/.test(f.stage);
|
|
13
|
+
return `<div class="row" tabindex="0" title="${esc(`${f.stage}: ${f.tokens.toLocaleString('en-US')} tokens`)}"><div class="lab">${esc(f.stage)}</div><div class="track"><span class="seg ${avoid ? 's2' : 's1'}" style="width:${(100 * f.tokens / fmax).toFixed(2)}%"></span></div><div class="val">${fmtN(f.tokens)} tokens${i ? ` · ${pct(f.tokens / fmax)}` : ''}</div></div>`;
|
|
14
|
+
}).join('');
|
|
15
|
+
const real = r.byCause.filter(c => !c.candidate), cmax = Math.max(1e-12, ...real.map(c => c.cost));
|
|
16
|
+
const causes = real.map(c => `<div class="row" tabindex="0" title="${esc(`${c.label}: ${fmt$(c.cost)}, ${c.fullPrice.toLocaleString('en-US')} tokens at full price, ${Math.round(c.tokens - c.fullPrice).toLocaleString('en-US')} re-read from cache, ${c.findings} findings in ${c.sessions} sessions`)}"><div class="lab">${esc(c.label)}</div><div class="track"><span class="seg s2" style="width:${(100 * c.cost / cmax).toFixed(2)}%"></span></div><div class="val">${fmt$(c.cost)} · ${fmtN(c.fullPrice)} full-price · ${c.findings}×</div></div>`).join('');
|
|
17
|
+
const fixes = r.byCause.filter(c => c.cost > 0 || c.tokens > 0).map(c => `<tr><td><b>${esc(c.label)}</b></td><td class="num">${fmt$(c.cost)}</td><td>${esc(c.fix)}</td></tr>`).join('');
|
|
18
|
+
const hmax = Math.max(1e-12, ...r.byHarness.map(h => h.cost || 0));
|
|
19
|
+
const harness = r.byHarness.map(h => {
|
|
20
|
+
const need = Math.max(0, (h.cost || 0) - h.avoidableCost);
|
|
21
|
+
return `<div class="row" tabindex="0" title="${esc(`${h.harness}: ${fmt$(h.cost)} over ${h.sessions} sessions, ${fmt$(h.avoidableCost)} avoidable; cache hit ${pct(h.cacheHit)}; models ${h.models.join(', ')}`)}"><div class="lab">${esc(h.harness)}</div><div class="track"><span class="seg s1" style="width:${(100 * need / hmax).toFixed(2)}%"></span><span class="seg s2" style="width:${(100 * h.avoidableCost / hmax).toFixed(2)}%"></span></div><div class="val">${fmt$(h.cost)} · avoidable ${fmt$(h.avoidableCost)} · cache hit ${pct(h.cacheHit)}${h.costPerSuccess != null ? ` · ${fmt$(h.costPerSuccess)}/success` : ''}</div></div>`;
|
|
22
|
+
}).join('');
|
|
23
|
+
const tools = r.byTool.map(x => `<tr><td>${esc(x.tool)}</td><td>${esc(CAUSES[x.cause] || x.cause)}</td><td class="num">${x.count}</td><td class="num">${fmtN(x.tokens)}</td><td class="num">${fmt$(x.cost)}</td></tr>`).join('');
|
|
24
|
+
const sess = r.sessions.slice(0, 15).map(s => `<tr><td>${esc(s.harness)}</td><td title="${esc(s.session)}">${esc(String(s.session).slice(0, 28))}${s.agent && s.agent !== 'main' ? ` <span class="muted">${esc(s.agent)}</span>` : ''}</td><td>${day(s.from)}</td><td class="num">${s.calls}</td><td class="num">${fmt$(s.cost)}</td><td class="num">${fmt$(s.avoidableCost)}</td><td>${esc(CAUSES[s.topCause] || '–')}</td><td>${esc(s.outcome)}</td></tr>`).join('');
|
|
25
|
+
const top = r.top.slice(0, 15).map(f => `<tr><td class="num">${fmt$(f.cost)}</td><td>${esc(f.label)}</td><td>${esc(f.harness)} · ${esc(String(f.session).slice(0, 20))}</td><td>${esc(f.note)}</td></tr>`).join('');
|
|
26
|
+
const models = r.byModel.slice(0, 12).map(m => `<tr><td>${esc(m.model)}</td><td class="num">${m.calls}</td><td class="num">${fmtN(m.tokens)}</td><td class="num">${m.cost == null ? 'unpriced' : fmt$(m.cost)}</td><td class="num">${pct(m.cacheHit)}</td></tr>`).join('');
|
|
27
|
+
const gpu = r.gpu ? `<h2>Self-hosted: GPU time behind the calls</h2><div class="muted">${r.gpu.matched} of ${r.gpu.requests} engine requests matched to a harness call. Busy time is charged to the calls; idle time between requests is the replica's, not the harness's.</div>
|
|
28
|
+
<table><tr><th>Replica</th><th class="num">GPUs</th><th class="num">Requests</th><th class="num">Busy</th><th class="num">Busy cost</th><th class="num">Idle cost</th></tr>${r.gpu.replicas.map(x => `<tr><td>${esc(x.replica)}</td><td class="num">${x.gpus ?? '–'} ${esc(x.gpuType || '')}</td><td class="num">${x.requests}</td><td class="num">${pct(x.busyShare)}</td><td class="num">${fmt$(x.busyCost)}</td><td class="num">${fmt$(x.idleCost)}</td></tr>`).join('')}</table>` : '';
|
|
29
|
+
const o = r.outcomes;
|
|
30
|
+
return `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(title)}</title>
|
|
31
|
+
<style>
|
|
32
|
+
.viz-root{color-scheme:light;--surface-1:#fcfcfb;--surface-2:#f3f2ef;--text-primary:#0b0b0b;--text-secondary:#52514e;--grid:#e4e3df;--series-1:#2a78d6;--series-2:#eb6834}
|
|
33
|
+
@media (prefers-color-scheme:dark){:root:where(:not([data-theme="light"])) .viz-root{color-scheme:dark;--surface-1:#1a1a19;--surface-2:#242422;--text-primary:#f0efec;--text-secondary:#c3c2b7;--grid:#34342f;--series-1:#3987e5;--series-2:#d95926}}
|
|
34
|
+
:root[data-theme="dark"] .viz-root{color-scheme:dark;--surface-1:#1a1a19;--surface-2:#242422;--text-primary:#f0efec;--text-secondary:#c3c2b7;--grid:#34342f;--series-1:#3987e5;--series-2:#d95926}
|
|
35
|
+
body{margin:0}.viz-root{background:var(--surface-1);color:var(--text-primary);font:14px/1.45 system-ui,-apple-system,Segoe UI,sans-serif;padding:24px;min-height:100vh;box-sizing:border-box}
|
|
36
|
+
h1{font-size:20px;margin:0 0 4px}h2{font-size:15px;margin:28px 0 10px}.muted{color:var(--text-secondary);font-size:12.5px}
|
|
37
|
+
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:18px 0}.tile{background:var(--surface-2);border-radius:10px;padding:12px 14px}.tile .k{color:var(--text-secondary);font-size:12px}.tile .v{font-size:24px;font-weight:600;font-variant-numeric:tabular-nums}
|
|
38
|
+
.legend{display:flex;gap:16px;margin:6px 0 10px;color:var(--text-secondary);font-size:12.5px}.legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px}
|
|
39
|
+
.row{display:grid;grid-template-columns:280px 1fr 330px;gap:10px;align-items:center;padding:3px 0;border-radius:6px}.row:hover,.row:focus{background:var(--surface-2);outline:none}
|
|
40
|
+
.lab{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.val{color:var(--text-secondary);font-size:12.5px;font-variant-numeric:tabular-nums}
|
|
41
|
+
.track{display:flex;gap:2px;height:14px}.seg{display:block;height:100%;min-width:0}.seg:first-child{border-radius:4px 0 0 4px}.seg:last-child{border-radius:0 4px 4px 0}.s1{background:var(--series-1)}.s2{background:var(--series-2)}
|
|
42
|
+
table{border-collapse:collapse;width:100%}th,td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--grid);vertical-align:top}th{color:var(--text-secondary);font-weight:500;font-size:12.5px}.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
43
|
+
@media (max-width:760px){.row{grid-template-columns:1fr}.val{margin-bottom:6px}}
|
|
44
|
+
</style></head><body><div class="viz-root">
|
|
45
|
+
<h1>${esc(title)}</h1><div class="muted">${t.calls} model calls · ${t.sessions} sessions · ${esc(t.harnesses.join(', '))} · prices: ${esc(r.pricing ? `${r.pricing.source}${r.pricing.asOf ? ', as of ' + r.pricing.asOf : ''}` : '–')}${t.unpricedCalls ? ` · ${t.unpricedCalls} calls unpriced (${esc(t.unpricedModels.join(', '))})` : ''}</div>
|
|
46
|
+
<div class="tiles">
|
|
47
|
+
<div class="tile"><div class="k">Model cost</div><div class="v">${fmt$(t.cost)}</div></div>
|
|
48
|
+
<div class="tile"><div class="k">Avoidable</div><div class="v">${fmt$(t.avoidableCost)}</div><div class="muted">${pct(t.avoidableShare)} of cost</div></div>
|
|
49
|
+
<div class="tile"><div class="k">Input from cache</div><div class="v">${pct(t.input ? t.cacheRead / t.input : null)}</div><div class="muted">${fmtN(t.cacheRead)} of ${fmtN(t.input)}</div></div>
|
|
50
|
+
<div class="tile"><div class="k">Cost per successful task</div><div class="v">${o.known ? fmt$(o.costPerSuccess) : '–'}</div><div class="muted">${o.known ? `${o.successes} succeeded, ${o.failures} failed (${fmt$(o.costOnFailure)})` : 'pass --outcomes to see it'}</div></div>
|
|
51
|
+
</div>
|
|
52
|
+
<h2>From tokens to waste</h2><div class="legend"><span><i style="background:var(--series-1)"></i>processed</span><span><i style="background:var(--series-2)"></i>avoidable</span></div>${funnel}
|
|
53
|
+
<h2>Avoidable cost by cause</h2>${causes || '<div class="muted">Nothing found.</div>'}
|
|
54
|
+
<h2>By harness</h2><div class="legend"><span><i style="background:var(--series-1)"></i>needed</span><span><i style="background:var(--series-2)"></i>avoidable</span></div>${harness}
|
|
55
|
+
<h2>What to change</h2><table><tr><th>Cause</th><th class="num">Cost</th><th>Fix</th></tr>${fixes}</table>
|
|
56
|
+
${tools ? `<h2>Tools behind the waste</h2><table><tr><th>Tool</th><th>Cause</th><th class="num">Count</th><th class="num">Tokens</th><th class="num">Cost</th></tr>${tools}</table>` : ''}
|
|
57
|
+
<h2>Largest findings</h2><table><tr><th class="num">Cost</th><th>Cause</th><th>Where</th><th>Evidence</th></tr>${top}</table>
|
|
58
|
+
<h2>Sessions with the most waste</h2><table><tr><th>Harness</th><th>Session</th><th>Started (UTC)</th><th class="num">Calls</th><th class="num">Cost</th><th class="num">Avoidable</th><th>Top cause</th><th>Outcome</th></tr>${sess}</table>
|
|
59
|
+
<h2>Models</h2><table><tr><th>Model</th><th class="num">Calls</th><th class="num">Tokens</th><th class="num">Cost</th><th class="num">Cache hit</th></tr>${models}</table>
|
|
60
|
+
${gpu}
|
|
61
|
+
<p class="muted">Counts, tool names and hashes only: no prompt, completion, argument or tool-output text is in this report. Tool output sizes are estimated at 4 characters per token. Method: harness-ledger/docs/METHOD.md.</p>
|
|
62
|
+
</div></body></html>`;
|
|
63
|
+
}
|