Skip to content

feat(profit): add compare history to /profit-estimator and /profit-estimator-per-gigawatt / 利润估算器:新增对比历史趋势面板 - #1009

Merged
functionstackx merged 6 commits into
masterfrom
feat/profit-estimator-compare-history
Sep 5, 2026
Merged

feat(profit): add compare history to /profit-estimator and /profit-estimator-per-gigawatt / 利润估算器:新增对比历史趋势面板#1009
functionstackx merged 6 commits into
masterfrom
feat/profit-estimator-compare-history

Conversation

@functionstackx

@functionstackx functionstackx commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the /inference Compare history panel to /profit-estimator and /profit-estimator-per-gigawatt, so a chip's revenue and profit at the chosen target can be read against the same chip on an earlier run date, or on one specific run of a day that ran twice.

How /inference does it (what this mirrors)

  • ChartControls.tsx: ControlPanel legend="Compare history" with a MultiSelect (max 4 chips) and, once a chip is picked, a DateRangePicker whose availableDates are the dates those chips have runs on.
  • ChartDisplay.tsxComparisonChangelog.tsx: rendered under the controls as soon as a chip is selected. Fed by useComparisonChangelogs (one workflow-info?date= query per available date, bounded to the range once set). Entries are filtered by model DB key, precision, and configKeyMatchesHwKey; range endpoints and the first available date always show. Single-run dates get Git Commit / Workflow Run links and either "Add to chart", "Remove from chart", or a locked "On chart" (range endpoints). Multi-run dates render one block per run (date~r<runId>, labelled #1, #2, …) with their own notes and add/remove. "Add all to chart" pins every entry not yet on the chart.
  • InferenceContext.tsx: pinned entries live in selectedDates / i_dates (comma list), cleared with the chips or when the range leaves the available dates. ChartDisplay expands a pinned plain date that has several runs into one entry per run, and numbers runs from dataRunsForDate so legend and changelog agree.
  • useChartData.ts: buildComparisonDates = resolveComparisonEntries(selectedDates, range) minus the main run date; a plain date is fetched with benchmarkQueryOptions(model, date, enabled, exact=true), a run entry with (model, '', enabled, false, runId, exactRun=true).
  • GPUGraph.tsx: one series per (chip, entry), lighter shade for older entries, labels ${chip} • ${comparisonEntryLabel(entry)}.

What this PR does

  • "Compare history" ControlPanel under the custom-cost block: Chip Config MultiSelect (maxSelections=4, agentic configs for the current model at the auto-resolved precision) and a Comparison Date Range DateRangePicker shown once a chip is selected. Same i_gpus / i_dstart / i_dend / i_dates params as /inference, so a comparison URL works on both surfaces.
  • Config Changelog: the /inference ComparisonChangelog component, unchanged apart from a new optional analyticsSection prop, rendered under the panel whenever a chip is selected and fed by useComparisonChangelogs(selectedGPUs, range, availableDates, 'agentic_traces'). Same filters, links, lock, add/remove, "Add all", and per-run blocks. Run numbering comes from dataRunsForDate on the changelog's runConfigs; a pinned plain date with several runs expands to per-run entries, as on /inference.
  • useProfitHistory resolves entries with /inference's buildComparisonDates and fetches plain dates as exact-date queries and run entries as runId + exactRun queries (calculator view). Loading is folded into the page flag so bars never render half-populated.
  • buildProfitHistoryResults dedupes runs per chip per entry, builds groups only for the selected chips, and interpolates on the same monotone Hermite spline the current bars use. Result keys are hwKey[__prec]|entry (| because entries carry their own ~r suffix); rows carry date (the entry) and dateLabel (2026-08-10 #2).
  • Chart: today's bars for the compared chips only, plus one bar per entry next to each, ordered chip → entries by comparisonEntrySortValue → today. shadeHistoryColor lightens the chip colour in OKLCH, oldest lightest. X labels, tooltip "Run date", caption (profit-history-note), and the CSV "Run date" column all print the changelog's label for the entry.
  • Pricing inputs are unchanged across entries: same target interactivity, utilization, license fee, price source, and TCO tier (or custom $/GPU/hr).
  • Chip options are every agentic config for the model at the effective precisions, as on /inference. With the default fixtures that includes H200 fp8: the sparse-precision rule keeps fp8 in play when it has a single curve, so H200 is offered even though its curve stops short of the target on the chart.
  • Pinning the run behind a main bar adds no duplicate. The main query is an as-of-date fetch, so each chip's current bar can come from a different run; profitHistoryCurrentRunIds maps each compared chip to the latest run of the current date that covered it (from the changelog's enumeration), dropCurrentRunEntries skips a pinned run only when every compared chip already shows it, and buildProfitHistoryResults skips it per chip. This is the per-chip form of the selectedRunId /inference hands buildComparisonDates.
  • A compared chip that only priced on an earlier entry stays in the legend (profitHistoryLegendKeys), and the caption names it as missing on the current date (profitHistoryMissing) rather than dropping its bars.
  • When a model switch prunes the whole chip selection, the range and pinned entries are cleared with it, as clearing the chips by hand does.

Analytics

profit_history_gpu_selected ({ gpus, count }), profit_history_date_range_changed ({ startDate, endDate }), and via analyticsSection="profit": profit_comparison_changelog_toggled, profit_changelog_add_all_dates, profit_changelog_add_date / remove_date, profit_changelog_add_run / remove_run. /inference keeps its inference_* names (the prop defaults to inference).

Unofficial-run overlays

N/A. The estimator passes no overlay to useThroughputData, and the history bars come from official runs by date or run id, so there is no overlay branch to serve.

/zh

All new estimator strings are in the component STRINGS table (对比历史趋势, 芯片配置, 选择芯片配置进行对比, 对比日期范围, 选择日期范围, 运行日期); the changelog reuses its own zh table (配置变更日志, 添加到图表, 全部添加到图表, 已在图表中, …). Covered by a Cypress case on /zh/profit-estimator-per-gigawatt.

Tests

  • profit-history.test.ts: option filtering and registry ordering; result key parse/format incl. run entries; profitHistoryEntryLabel / profitHistoryEntryDate; row ordering and ranks with same-day runs; fade share and OKLCH shading; buildProfitHistoryResults interpolation, selection filter, and same-day run dedupe; profitHistoryCurrentRunIds / dropCurrentRunEntries (per-chip current run, sparse later run), per-chip skip in buildProfitHistoryResults, profitHistoryLegendKeys (history-only chip kept while comparing), profitHistoryMissing (current date included).
  • ProfitEstimatorChart.test.ts: dated rowLabel, splitHistoryLabel, tooltip run date, xLabelLayout with a date line.
  • profit-estimator.cy.ts: fixtures gain 2026-07-15 (80% throughput, one run), 2026-08-10 (two runs at 85% and 92%, each with a changelog row), and 2026-08-31 (today, one run); interceptProfitData serves ?date=, ?runId=&exactRun=true, and /api/v1/workflow-info?date=. Cases: panel and option list; Max Range on two chips gives four TCO bars in the right order; URL hydration and clearing; Config Changelog lists three dates with notes and links, "Add to chart" pins i_dates and adds a bar, "Remove from chart" clears it; two-run date shows #1 / #2 blocks, adding run chore: bump the all-minor-patch group with 2 updates #1 adds a ~r<runId> entry and a 2026-08-10 #1 bar, "Add all to chart" adds the rest with revenues rising oldest → newest; hydration from ?i_dates=…~r… with range endpoints locked as "On chart"; /zh labels. Assertions are on the UI (trigger text, Add/Remove buttons, range picker, bar counts), not the address bar: url-state.ts keeps share params in memory and strips them from the address bar after load. Panel interactions wait for the first priced bar, since the options depend on the availability rows and the auto-resolved precision.
  • profit-estimator.cy.ts (pre-existing, from feat(app): add MiniMax M3 to the profit estimators with MiniMax list-price defaults / 利润估算器新增 MiniMax M3 并默认采用 MiniMax 官方定价 #1002): the MiniMax → Kimi switch asserted a bare /profit-estimator-per-gigawatt, but modelRoutePathnameRewrite yields /profit-estimator-per-gigawatt/kimi-k3 when leaving a per-model path (the GLM → Kimi case in the same file asserts exactly that). That shard was red on feat(app): add MiniMax M3 to the profit estimators with MiniMax list-price defaults / 利润估算器新增 MiniMax M3 并默认采用 MiniMax 官方定价 #1002's own CI; the expectation now matches the route behaviour.
  • Local: typecheck, lint, fmt, check:typography clean; calculator + inference/ui vitest suites pass; profit-estimator.cy.ts passes locally against the fixture build (Cypress 15.21.1, CI=true E2E_FIXTURES=1).

中文说明

/profit-estimator/profit-estimator-per-gigawatt 增加与 /inference 相同的"对比历史趋势"面板,包括配置变更日志与固定日期/运行。

  • 面板位于自定义成本区块之下:芯片配置多选(最多 4 个,当前模型在自动精度下的 agentic 配置),选中后显示对比日期范围选择器。使用共享的 i_gpus / i_dstart / i_dend / i_dates URL 参数,/inference 上的对比链接可直接在估算器打开。
  • 配置变更日志:复用 /inferenceComparisonChangelog 组件(仅新增可选的 analyticsSection 属性),选中芯片后显示于面板下方,数据来自 useComparisonChangelogs。保留相同的过滤规则、Git Commit / Workflow Run 链接、范围端点的"已在图表中"锁定、添加/移除、"全部添加到图表"以及多运行日期的逐运行区块(chore: bump the all-minor-patch group with 2 updates #1chore: bump anthropics/claude-code-action from 04f907ba2a4c77706a56b4078c682d250716cc0c to cd77b50d2b0808657f8e6774085c8bf54484351c #2…)。运行编号取自 dataRunsForDate;固定的单日日期若有多次运行会展开为逐运行条目。
  • useProfitHistory 通过 buildComparisonDates 解析对比条目:普通日期按 exact=true 查询,运行条目按 runId + exactRun 查询(calculator 视图)。
  • 柱形、提示框、说明文字与 CSV 均使用与变更日志一致的"日期 #n"标签;排序与颜色深浅按 comparisonEntrySortValue
  • 埋点:profit_history_gpu_selectedprofit_history_date_range_changed,以及 profit_changelog_* / profit_comparison_changelog_toggled
  • 非官方运行叠加不适用:估算器未向 useThroughputData 传入叠加数据。
  • 芯片选项为当前模型在有效精度下的全部 agentic 配置(与 /inference 一致);固定主柱形所对应的运行不会产生重复柱形(按芯片记录当前运行 id:profitHistoryCurrentRunIds / dropCurrentRunEntries);仅在历史日期有数据的芯片仍保留在图例中,并在说明文字中标注当日缺失;模型切换清空芯片选择时同时清空日期范围与固定条目。
  • 测试:vitest 覆盖运行条目的键、标签、排序与分级,以及当前运行 id、图例键与缺失说明;Cypress 夹具新增双运行日期(含变更日志行)与 workflow-info 拦截,新增变更日志面板、固定日期、逐运行柱形与"全部添加"、URL 还原与锁定、/zh 镜像用例,断言基于界面而非地址栏。修正 feat(app): add MiniMax M3 to the profit estimators with MiniMax list-price defaults / 利润估算器新增 MiniMax M3 并默认采用 MiniMax 官方定价 #1002 中 MiniMax → Kimi 切换用例的路径期望(/profit-estimator-per-gigawatt/kimi-k3)。本地 typecheck / lint / fmt / typography 与 Cypress 用例通过。

Note

Medium Risk
Large UI and data-layer change to profit estimation and shared comparison URL state, with many edge cases around run deduplication and chart merging, though behavior mirrors an existing /inference pattern and is heavily tested.

Overview
Adds a Compare history flow to the profit estimator (including per-gigawatt), aligned with /inference: up to four agentic chip configs, a date range, and the shared Config Changelog, all driven by i_gpus, i_dstart, i_dend, and i_dates.

When a comparison is active, the chart shows only the selected chips—today’s bar plus one bar per range endpoint or changelog-pinned date/run—repriced with the same target, token prices, and TCO tier. Historical bars use lighter OKLCH shading, dated axis labels and tooltips, caption notes for missing runs, and a Run date CSV column. New profit-history / useProfitHistory modules fetch benchmarks (reusing buildComparisonDates) and interpolate history through the same path as current bars, including per-chip dedupe of the “current” run so pins do not duplicate today’s bar.

ComparisonChangelog gains an optional analyticsSection for profit-specific tracking. Cypress fixtures and e2e cover the panel, changelog pinning, multi-run days, URL hydration, and /zh labels; one model-switch test now expects /profit-estimator-per-gigawatt/kimi-k3 after the per-model route rewrite.

Reviewed by Cursor Bugbot for commit a0ff206. Bugbot is set up for automated code reviews on this repo. Configure here.

…timator-per-gigawatt | 利润估算器:新增对比历史趋势面板

Both profit estimator routes get the Compare history panel from /inference:
a Chip Config multiselect (up to four agentic configs for the current model
at the auto-resolved precision) and, once a chip is chosen, a Comparison
Date Range picker limited to the dates those chips have runs on. The
selection lives in the shared i_gpus / i_dstart / i_dend URL params, so a
comparison built on /inference opens on the estimator and back.

With a range set the chart keeps only the compared chips and adds one bar
per range endpoint (minus today's run date), priced from that date's run
with the same target interactivity, price source, utilization, license
fee, and TCO tier. History bars use a lighter shade of the chip colour
(oldest lightest, the /inference ramp), the x label gains a date line, the
tooltip names the run date, the caption notes the compared dates and any
chip with no run at the target, and the CSV export gains a Run date
column.

Data path: useProfitHistory runs one benchmark query per comparison date
(benchmarkQueryOptions with exact=true, view=calculator, sequence=agentic
traces), dedupeAgenticHistoryRuns keeps one run per chip per day, and
buildProfitHistoryResults interpolates each selected chip on the same
monotone Hermite spline the current bars use.

Analytics: profit_history_gpu_selected, profit_history_date_range_changed.
Unofficial-run overlays do not apply: the estimator passes no overlay to
useThroughputData.

Tests: vitest for the history helpers (option filtering and ordering,
comparison dates, result keys, colour shading, interpolation and per-day
dedupe) and the chart label/tooltip/layout changes; Cypress for the panel,
URL sync and hydration, bar count and ordering against a two-date fixture,
clearing, and the /zh mirror.

中文:两个利润估算器路由新增与 /inference 相同的"对比历史趋势"面板:
芯片配置多选(当前模型在自动精度下最多四个 agentic 配置),选中后出现
仅含这些芯片有运行记录日期的日期范围选择器。选择保存在共享的
i_gpus / i_dstart / i_dend URL 参数中,/inference 上的对比可直接在估算器
打开。设置范围后,图表仅保留所对比的芯片,并为范围的每个端点(去掉当天
运行日期)各增加一根柱,按该日期的运行数据、相同目标交互性、价格来源、
利用率、许可费和 TCO 档位计价。历史柱使用同一芯片颜色的浅色(越早越浅),
x 轴标签增加日期行,提示框显示运行日期,说明文字列出对比日期及在目标点
无运行数据的芯片,CSV 导出增加"运行日期"列。数据路径:useProfitHistory
按对比日期各发一次基准查询(exact=true,calculator 视图,agentic 序列),
dedupeAgenticHistoryRuns 每芯片每日保留一次运行,buildProfitHistoryResults
用与当前柱相同的单调 Hermite 样条插值。埋点:profit_history_gpu_selected、
profit_history_date_range_changed。非官方运行叠加不适用(估算器未向
useThroughputData 传入叠加数据)。测试:vitest 覆盖历史辅助函数与图表
标签/提示/布局改动;Cypress 覆盖面板、URL 同步与还原、双日期夹具下的柱数
与顺序、清除以及 /zh 镜像。
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
inferencemax-app Ready Ready Preview Sep 5, 2026 3:48am UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/app/src/components/calculator/ProfitEstimatorDisplay.tsx
Comment thread packages/app/src/components/calculator/ProfitEstimatorDisplay.tsx
@blacksmith-sh

This comment has been minimized.

… Changelog, pinned dates and runs) | 利润估算器:对比历史与 /inference 对齐(配置变更日志、固定日期与运行)

The first cut only priced the range endpoints. /inference's Compare history
also renders the Config Changelog under the controls and lets the reader pin
individual dates or runs onto the chart, so this ports the rest:

- Config Changelog: reuse `ComparisonChangelog` fed by `useComparisonChangelogs`
  (workflow-info per available date, agentic_traces). Same filters (model db
  key, precision, hw key), Git Commit / Workflow Run links, "Add to chart",
  "Add all to chart", "Remove from chart", and the "On chart" lock for range
  endpoints. New optional `analyticsSection` prop so events track as
  `profit_changelog_*` here and stay `inference_*` on /inference.
- Pinned entries: `selectedDates` state hydrated from `i_dates`, synced back,
  cleared with the chips or when the range leaves the available dates. A
  pinned plain date with several runs expands to one `date~r<runId>` entry
  per run, as `ChartDisplay` does.
- Fetching: `useProfitHistory` now resolves entries with /inference's
  `buildComparisonDates` and fetches run entries with `runId` + `exactRun`
  (calculator view), plain dates as exact-date queries.
- Labels: bars, tooltip, caption, and CSV print `comparisonEntryLabel`
  (`2026-08-10 #2`), numbered from the changelog's `dataRunsForDate` so the
  chart and changelog agree. Ordering and the shade ramp sort by
  `comparisonEntrySortValue`. Result-key separator switched to `|` because
  entries carry their own `~r` suffix.
- Tests: unit coverage for run entries, ordering, ranks, labels; Cypress
  fixtures gain a two-run date with changelog rows and a workflow-info
  intercept; new cases for the changelog panel, pinning a date, per-run
  bars and "Add all", URL hydration with "On chart" locks, and the zh mirror.

中文:首版仅对日期范围两端估价。/inference 的对比历史还会在控件下方显示配置变更日志,
并允许将单个日期或运行固定到图表上,本次补齐这部分:复用 ComparisonChangelog 与
useComparisonChangelogs;新增 i_dates 固定项状态并同步 URL;多运行日期展开为逐运行条目;
运行条目通过 runId + exactRun 获取;柱形、提示框、说明与 CSV 使用与变更日志一致的
"日期 #n" 标签;补充单元测试与 Cypress 用例(含双运行日期夹具与 workflow-info 拦截)。

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/app/src/components/calculator/useProfitHistory.ts Outdated
…ps, stabilise E2E

Hand `buildComparisonDates` the run behind the main bars
(`profitHistoryCurrentRunId`: latest enumerated run of the current date for
the compared chips, else the global run selection) so pinning it from the
Config Changelog adds no duplicate bar. Keep a chip that only priced on an
earlier entry in the legend (`profitHistoryLegendKeys`) and name it as missing
on the current date in the caption (`profitHistoryMissing`). Clear the range
and pinned entries when a model switch prunes the whole chip selection.

Cypress: assert on the UI rather than the address bar (share params live in
memory and are stripped after load), wait for the first priced bar before
opening the chip selector, reopen it per pick, expect the H200 fp8 option
(the sparse-precision rule keeps fp8 in play), and fix the pre-existing
MiniMax → Kimi route expectation to `/profit-estimator-per-gigawatt/kimi-k3`.

中文:将主柱形对应的运行 id 传入 `buildComparisonDates`,固定该运行不再产生重复柱形;仅在历史日期有数据的芯片保留在图例中并在说明文字中标注当日缺失;模型切换清空芯片选择时同时清空日期范围与固定条目。Cypress 用例改为基于界面断言、等待首个柱形后再打开选择器、每次选择后重新打开,并修正 H200 fp8 选项与 MiniMax → Kimi 路径期望。

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/app/src/components/calculator/profit-history.ts
Comment thread packages/app/src/components/calculator/ProfitEstimatorDisplay.tsx
`oxlint` (consistent-function-scoping) rejects helpers that capture nothing
from their `describe` block; move `rc` and the caption label stubs to the top
of the file.

中文:将 profit-history 测试中的 `rc` 与标签辅助函数提升到模块作用域,以通过 oxlint 的 consistent-function-scoping 规则。
…only chips

The main query is an as-of-date fetch with no run id, so each chip's current
bar can come from a different run. `profitHistoryCurrentRunIds` maps each
compared chip to the latest run of the current date that covered it (from the
changelog's enumeration); `dropCurrentRunEntries` skips a pinned run only when
every compared chip already shows it, and `buildProfitHistoryResults` skips
that run per chip. The missing-bar caption labels a chip absent from today's
rows via `getHardwareConfig`, as `rowLabel` does.

中文:主查询按日期取数、不带运行 id,各芯片的当前柱形可能来自不同运行。改为按芯片记录当前运行 id:仅当所有对比芯片都已显示该运行时才跳过固定条目,并在构建历史结果时按芯片跳过;缺失说明对当日无数据的芯片改用注册表标签。

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 37dc6d4. Configure here.

Comment thread packages/app/src/components/calculator/profit-history.ts
…sing

`profitHistoryMissing` takes the per-chip current run ids and skips a pinned
run for the chip whose current bar already is that run, matching the skip in
`buildProfitHistoryResults`.

中文:缺失说明按芯片跳过其当前柱形所对应的固定运行,与历史结果构建时的跳过逻辑一致。
@functionstackx
functionstackx merged commit deb5c8f into master Sep 5, 2026
28 checks passed
@functionstackx
functionstackx deleted the feat/profit-estimator-compare-history branch September 5, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant