feat(profit): add compare history to /profit-estimator and /profit-estimator-per-gigawatt / 利润估算器:新增对比历史趋势面板 - #1009
Merged
Conversation
…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 镜像。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This comment has been minimized.
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 拦截)。
…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 路径期望。
`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:仅当所有对比芯片都已显示该运行时才跳过固定条目,并在构建历史结果时按芯片跳过;缺失说明对当日无数据的芯片改用注册表标签。
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.
…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`. 中文:缺失说明按芯片跳过其当前柱形所对应的固定运行,与历史结果构建时的跳过逻辑一致。
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
Adds the
/inferenceCompare history panel to/profit-estimatorand/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
/inferencedoes it (what this mirrors)ChartControls.tsx:ControlPanel legend="Compare history"with aMultiSelect(max 4 chips) and, once a chip is picked, aDateRangePickerwhoseavailableDatesare the dates those chips have runs on.ChartDisplay.tsx→ComparisonChangelog.tsx: rendered under the controls as soon as a chip is selected. Fed byuseComparisonChangelogs(oneworkflow-info?date=query per available date, bounded to the range once set). Entries are filtered by model DB key, precision, andconfigKeyMatchesHwKey; 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 inselectedDates/i_dates(comma list), cleared with the chips or when the range leaves the available dates.ChartDisplayexpands a pinned plain date that has several runs into one entry per run, and numbers runs fromdataRunsForDateso legend and changelog agree.useChartData.ts:buildComparisonDates=resolveComparisonEntries(selectedDates, range)minus the main run date; a plain date is fetched withbenchmarkQueryOptions(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
ControlPanelunder the custom-cost block: Chip ConfigMultiSelect(maxSelections=4, agentic configs for the current model at the auto-resolved precision) and a Comparison Date RangeDateRangePickershown once a chip is selected. Samei_gpus/i_dstart/i_dend/i_datesparams as/inference, so a comparison URL works on both surfaces./inferenceComparisonChangelogcomponent, unchanged apart from a new optionalanalyticsSectionprop, rendered under the panel whenever a chip is selected and fed byuseComparisonChangelogs(selectedGPUs, range, availableDates, 'agentic_traces'). Same filters, links, lock, add/remove, "Add all", and per-run blocks. Run numbering comes fromdataRunsForDateon the changelog'srunConfigs; a pinned plain date with several runs expands to per-run entries, as on/inference.useProfitHistoryresolves entries with/inference'sbuildComparisonDatesand fetches plain dates as exact-date queries and run entries asrunId+exactRunqueries (calculator view). Loading is folded into the page flag so bars never render half-populated.buildProfitHistoryResultsdedupes 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 arehwKey[__prec]|entry(|because entries carry their own~rsuffix); rows carrydate(the entry) anddateLabel(2026-08-10 #2).comparisonEntrySortValue→ today.shadeHistoryColorlightens 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./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.profitHistoryCurrentRunIdsmaps each compared chip to the latest run of the current date that covered it (from the changelog's enumeration),dropCurrentRunEntriesskips a pinned run only when every compared chip already shows it, andbuildProfitHistoryResultsskips it per chip. This is the per-chip form of theselectedRunId/inferencehandsbuildComparisonDates.profitHistoryLegendKeys), and the caption names it as missing on the current date (profitHistoryMissing) rather than dropping its bars.Analytics
profit_history_gpu_selected({ gpus, count }),profit_history_date_range_changed({ startDate, endDate }), and viaanalyticsSection="profit":profit_comparison_changelog_toggled,profit_changelog_add_all_dates,profit_changelog_add_date/remove_date,profit_changelog_add_run/remove_run./inferencekeeps itsinference_*names (the prop defaults toinference).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
STRINGStable (对比历史趋势, 芯片配置, 选择芯片配置进行对比, 对比日期范围, 选择日期范围, 运行日期); 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;buildProfitHistoryResultsinterpolation, selection filter, and same-day run dedupe;profitHistoryCurrentRunIds/dropCurrentRunEntries(per-chip current run, sparse later run), per-chip skip inbuildProfitHistoryResults,profitHistoryLegendKeys(history-only chip kept while comparing),profitHistoryMissing(current date included).ProfitEstimatorChart.test.ts: datedrowLabel,splitHistoryLabel, tooltip run date,xLabelLayoutwith a date line.profit-estimator.cy.ts: fixtures gain2026-07-15(80% throughput, one run),2026-08-10(two runs at 85% and 92%, each with a changelog row), and2026-08-31(today, one run);interceptProfitDataserves?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" pinsi_datesand adds a bar, "Remove from chart" clears it; two-run date shows#1/#2blocks, adding run chore: bump the all-minor-patch group with 2 updates #1 adds a~r<runId>entry and a2026-08-10 #1bar, "Add all to chart" adds the rest with revenues rising oldest → newest; hydration from?i_dates=…~r…with range endpoints locked as "On chart";/zhlabels. Assertions are on the UI (trigger text, Add/Remove buttons, range picker, bar counts), not the address bar:url-state.tskeeps 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, butmodelRoutePathnameRewriteyields/profit-estimator-per-gigawatt/kimi-k3when 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.typecheck,lint,fmt,check:typographyclean; calculator + inference/ui vitest suites pass;profit-estimator.cy.tspasses locally against the fixture build (Cypress 15.21.1,CI=true E2E_FIXTURES=1).中文说明
为
/profit-estimator和/profit-estimator-per-gigawatt增加与/inference相同的"对比历史趋势"面板,包括配置变更日志与固定日期/运行。i_gpus/i_dstart/i_dend/i_datesURL 参数,/inference上的对比链接可直接在估算器打开。/inference的ComparisonChangelog组件(仅新增可选的analyticsSection属性),选中芯片后显示于面板下方,数据来自useComparisonChangelogs。保留相同的过滤规则、Git Commit / Workflow Run 链接、范围端点的"已在图表中"锁定、添加/移除、"全部添加到图表"以及多运行日期的逐运行区块(chore: bump the all-minor-patch group with 2 updates #1、chore: bump anthropics/claude-code-action from 04f907ba2a4c77706a56b4078c682d250716cc0c to cd77b50d2b0808657f8e6774085c8bf54484351c #2…)。运行编号取自dataRunsForDate;固定的单日日期若有多次运行会展开为逐运行条目。useProfitHistory通过buildComparisonDates解析对比条目:普通日期按exact=true查询,运行条目按runId+exactRun查询(calculator 视图)。comparisonEntrySortValue。profit_history_gpu_selected、profit_history_date_range_changed,以及profit_changelog_*/profit_comparison_changelog_toggled。useThroughputData传入叠加数据。/inference一致);固定主柱形所对应的运行不会产生重复柱形(按芯片记录当前运行 id:profitHistoryCurrentRunIds/dropCurrentRunEntries);仅在历史日期有数据的芯片仍保留在图例中,并在说明文字中标注当日缺失;模型切换清空芯片选择时同时清空日期范围与固定条目。/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
/inferencepattern 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 byi_gpus,i_dstart,i_dend, andi_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/useProfitHistorymodules fetch benchmarks (reusingbuildComparisonDates) 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.ComparisonChangeloggains an optionalanalyticsSectionfor profit-specific tracking. Cypress fixtures and e2e cover the panel, changelog pinning, multi-run days, URL hydration, and/zhlabels; one model-switch test now expects/profit-estimator-per-gigawatt/kimi-k3after 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.