fix(inference): derive $/M tok and J/token from throughput instead of splining them / 每 token 成本与能耗改为按吞吐量推导而非直接插值 - #726
Merged
Conversation
… splining them / 每 token 成本与能耗改为按吞吐量推导而非直接插值 Cost per million tokens and joules per token are a per-chip constant divided by a throughput. The interpolation splined them directly, which averages reciprocals; 1/x is convex, so the result diverged from the value implied by the interpolated throughput. /inference settles which is right. It plots these metrics only at measured points (lib/chart-utils.ts:380, roof: false), so its values are the oracle, and they satisfy `metric x throughput = constant` by construction. Holding out each interior frontier knot and predicting its real value: splined metric mean err 162.8% closer on 36 / 144 derived from throughput mean err 42.2% closer on 108 / 144 The splined pair also broke that identity by a median 71.6% and up to 2026% — reporting operating points no real config could occupy. The two agree exactly at all 470 measured knots; the divergence is entirely between them, and the splined read is the higher one 73.6% of the time (max 25.3x on sparsely swept frontiers, where adjacent knots differ ~100x in throughput). Changed: interpolateForGPU, maxInteractivityAtCost and interpolateMetricAtInteractivity now spline the throughput these metrics divide and re-derive. iso_interactivity.py is synced in this commit per AGENTS.md and verified to agree to the last digit (0.44517072882391184 on a shared fixture); that rule now also covers recoverReciprocalNumerator. recoverReciprocalNumerator returns null unless every usable point agrees on the constant, and all call sites then fall back to splining. That guard is load bearing: the measured* energy keys have a numerator measured per point, so they stay splined, and hand-built points whose cost is unrelated to their throughput keep their previous values instead of being silently rewritten. The rate is recovered across all three token types at once — checking one family and falling back to another recovers a rate from output tokens and applies it to total throughput, which the existing maxInteractivityAtCost tests caught. Published numbers move down, since they were the overstated side. Over 555 unclamped reads (dsr1 8k/1k, targets 20-75), two-thirds shift under 10%; the tail is the sparsely swept disaggregated configs, worst case a 25x drop. Note for whoever merges second: the Fleet Lifecycle branch documents this as an open follow-up and derives its break-even to work around it. That prose needs reconciling once both land — the workaround stays correct, it is just no longer a workaround.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Run the bundled Python helper from the existing unit test, return null for missing reciprocal inputs, and remove snapshot-specific impact claims that do not describe the changing live dataset. Correct the documented consistency tolerance to 0.1%. 中文:对齐倒数指标的插值验证。现有单元测试会直接运行随附的 Python helper;缺少倒数吞吐量输入时返回 null;移除无法代表持续变化的线上数据集的快照影响数字,并将一致性容差文档更正为 0.1%。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
$/M tokand spec-sheetJ/tokenare defined as a per-chip constant divided by throughput. Previously, the calculator and historical trends independently splined both throughput and the reciprocal metric, so the two interpolated curves could violate:metric × throughput = constantThis PR now splines throughput and derives the reciprocal metric from it. Measured knots are unchanged; only values between knots can move.
The size and direction of that movement depend on frontier density and change as new benchmark runs land. Earlier snapshot-specific impact figures have therefore been removed rather than presented as permanent results for the live dataset.
Safety
recoverReciprocalNumeratorapplies derivation only when every usable point agrees on the numerator within 0.1%.nullwhen a reciprocal throughput input is missing, matching TypeScript.?unofficialrun=calculator paths share the same interpolation implementation.Validation
bun run lintbun run fmtbun run typecheckbun run test:unit— 3,821 tests passed across workspacesbun run test:e2e— 88 smoke tests passed中文说明
$/M tok与基于规格功耗计算的J/token,其定义都是“单芯片常数 ÷ 吞吐量”。此前 TCO Calculator 与 Historical Trends 会分别对吞吐量和倒数指标做样条插值,导致两条插值曲线之间可能不再满足:指标 × 吞吐量 = 常数本 PR 改为只对吞吐量做样条插值,再由插值后的吞吐量推导倒数指标。所有实测节点保持不变,只有节点之间的估算值可能变化。
变化幅度和方向取决于 Pareto frontier 的密度,也会随着新 benchmark 结果持续变化。因此,本 PR 已移除旧快照中的影响百分比,避免将其误写成线上数据集长期不变的结论。
安全措施
recoverReciprocalNumerator才会启用推导逻辑。null,与 TypeScript 行为一致。?unofficialrun=overlay 共用同一套 calculator 插值实现。验证
bun run lintbun run fmtbun run typecheckbun run test:unit— 各 workspace 共 3,821 项测试通过bun run test:e2e— 88 项 smoke test 通过Note
High Risk
Changes how cost and energy are interpolated across the calculator, fleet cost-cap lookup, trend charts, and blog helper—published numbers will move, often downward. Guarded by a consistency check with extensive unit coverage, but still user-facing TCO math.
Overview
$/M tok and J/token are now derived from interpolated throughput instead of being splined independently. That preserves
metric × throughput = constantbetween measured knots (previously broken by a median ~72%).Adds
recoverReciprocalNumerator/reciprocalMetricAtand wires them throughinterpolateForGPU,maxInteractivityAtCost, andinterpolateMetricAtInteractivity. A 0.1% consistency guard falls back to the old spline when the numerator is not constant (e.g.measured*energy). Cost rates are recovered across all three token types together so inverse lookups stay on the same curve as the bars.Syncs
iso_interactivity.pywith areciprocal_ofoption, documents the method indocs/tco-calculator.md, and adds tests that pin the identity, the Python/TS match, and the fallback path.Reviewed by Cursor Bugbot for commit 4138124. Bugbot is set up for automated code reviews on this repo. Configure here.