Skip to content

feat: reuse shared panel processing across forecasters (refresh of #2) - #18

Open
elmartinj wants to merge 5 commits into
mainfrom
feat/improve-speed-refresh
Open

feat: reuse shared panel processing across forecasters (refresh of #2)#18
elmartinj wants to merge 5 commits into
mainfrom
feat/improve-speed-refresh

Conversation

@elmartinj

Copy link
Copy Markdown
Collaborator

This is a refreshed version of #2 (feat: use common syntaxis and improve speed), rebased onto current main. The original commits by Azul are preserved on this branch; the final commit fixes what was blocking the old PR.

What's in it:

  • Preprocess the input DataFrame once into a shared PanelData and reuse it across model calls instead of every wrapper re-doing sorting, datetime conversion, and dataset construction.
  • Thread the optional panel through the base Forecaster.forecast signature and MultiModelForecasterMixin.forecast, and update every built-in model wrapper (including Tafsut and TimesFM 3.0, which landed on main after the original PR).
  • Fix the test failures from feat: use common syntaxis and improve speed #2's last CI run: quantile columns are now assigned one at a time because utilsforecast.assign_columns rejects list values for multiple columns.
  • Compute the Chronos panel once so dataset construction and finetuning inputs share it.
  • Remove redundant _ = panel statements in the TimesFM 1.0 / 2.5 paths.

Local verification: pre-commit (ruff, ruff-format, mypy, toml-sort) passes and the download-free test suite passes (78 passed, 6 skipped). Full model tests still need a CI run.

Related: #2

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ AzulGarza
❌ elmartinj


elmartinj seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Rebase of the feat/improve-speed branch onto main surfaced several issues:

- assign quantile columns one at a time: utilsforecast only supports
  single-column assignment for list values
- accept a precomputed panel in the base Forecaster, Tafsut, and
  TimesFM 3.0 forecast paths
- thread the optional panel argument through MultiModelForecasterMixin
  so custom models can opt in without breaking the type contract
- compute the Chronos panel once and reuse it for dataset and finetuning
- drop redundant panel assignments in TimesFM 1.0 / 2.5
- normalize string ds columns to datetime when building shared panels,
  matching the existing dataset behavior and the README quick example
- add a download-free regression test for quantile-column assignment
@elmartinj
elmartinj force-pushed the feat/improve-speed-refresh branch from 44c69f1 to a8deacb Compare September 7, 2026 22:47
Resolve timesfm.py import conflict by keeping shared PanelData support
from #18 and maybe_convert_col_to_datetime from main.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×3

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
✅ 7 untouched benchmarks
🆕 6 new benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation test_foundation_forecast_multi_model[5-models] 965.4 ms 173.2 ms ×5.6
Simulation test_foundation_forecast_multi_model[3-models] 578.4 ms 145.8 ms ×4
Simulation test_timeseries_dataset_from_df[small] 10.8 ms 5.2 ms ×2.1
Simulation test_timeseries_dataset_from_df[large] 180.9 ms 107.4 ms +68.4%
🆕 Simulation test_assign_quantile_forecasts N/A 4.6 ms N/A
🆕 Simulation test_process_panel_from_df_string_ds N/A 225.1 ms N/A
🆕 Simulation test_process_panel_from_df[large] N/A 104.5 ms N/A
🆕 Simulation test_process_panel_from_df[small] N/A 4.7 ms N/A
🆕 Simulation test_timeseries_dataset_from_df_with_panel N/A 41.4 µs N/A
🆕 Simulation test_timeseries_dataset_from_panel N/A 34.2 µs N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/improve-speed-refresh (35c8f31) with main (cbc64bc)

Open in CodSpeed

AzulGarza added a commit that referenced this pull request Sep 11, 2026
* feat: add panel and multi-model CodSpeed benchmarks

Add large-panel dataset fixture, parametrize TimeSeriesDataset.from_df
benchmarks, and FoundationForecast multi-model orchestration benchmarks
to measure preprocessing speedups from shared panel processing (PR #18).

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: satisfy mypy list invariance in orchestration benchmark

Annotate models as list[Forecaster] when constructing FoundationForecast.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Merge v0.1.5 weight cache (#22) and panel CodSpeed benchmarks (#24).
Resolve forecaster.py conflict (PanelData + weight cache TypeVar).
Add Phase 2 panel micro-benchmarks in tests/benchmarks/test_panel.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

3 participants