Skip to content

Add CodSpeed continuous benchmarking - #19

Open
codspeed-hq[bot] wants to merge 1 commit into
mainfrom
codspeed-wizard-1789079702900
Open

Add CodSpeed continuous benchmarking#19
codspeed-hq[bot] wants to merge 1 commit into
mainfrom
codspeed-wizard-1789079702900

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Sep 10, 2026

Copy link
Copy Markdown

This sets up continuous performance measurement with CodSpeed for the library's core forecasting pipeline.

What was added

Benchmarks (benchmarks/) — 23 benchmarks run with pytest-codspeed. They deliberately avoid downloading or running model weights: the models used (benchmarks/_models.py, a constant forecaster and a seasonal-naive forecaster) are trivial, so what is measured is FoundationForecast's own data plumbing, which is what every model call pays for.

  • test_bench_core_utils.py: input validation, frequency inference, ds/y dtype conversion, seasonality lookup, and both QuantileConverter conversions (levels <-> quantile columns).
  • test_bench_dataset.py: TimeSeriesDataset.from_df (two batch sizes), batch iteration, make_future_dataframe, and the _DataProcessor tensor path (left padding/stacking of variable-length contexts, and missing-value imputation).
  • test_bench_pipelines.py: FoundationForecast.forecast (single model, with prediction levels, four merged models, and on shuffled input that forces sorting and frequency inference), cross_validation with 1 and 4 windows, and detect_anomalies.

Fixtures in benchmarks/conftest.py generate deterministic panels (20 series x 200 rows, 200 series x 500 rows) with utilsforecast.data.generate_series, which is seeded by default so measurements are stable run to run.

pytest testpaths is still ["tests"], so the benchmarks do not run as part of the normal test suite; they are invoked explicitly by path.

CI (.github/workflows/codspeed.yaml) — runs on pushes to main, on pull requests, and via workflow_dispatch (used by CodSpeed for backtests). It mirrors the existing CI job: astral-sh/setup-uv@v6 with caching plus the same disk-cleanup step, since the dependency set (torch, gluonts and the model packages) is large. Benchmarks run through CodSpeedHQ/action@v5 in simulation mode on ubuntu-latest, authenticated with OIDC (id-token: write), so no token secret is required.

Otherpytest-codspeed added to the dev dependency group (lockfile updated), and a CodSpeed badge added to the README.

Verification

The benchmarks were run locally with codspeed run --mode simulation -- uv run pytest benchmarks/ --codspeed; all 23 benchmarks were measured successfully. ruff check, ruff format and mypy (same settings as the pre-commit hooks) pass on the new files, and uv run pytest tests/core still passes.

Next steps

  • Merge to main so CodSpeed records a baseline; subsequent pull requests will then get automatic performance reports.
  • If you later want to track the model inference paths themselves, those benchmarks would need cached weights and would be better suited to a separate, scheduled workflow.

@codspeed-hq

codspeed-hq Bot commented Sep 10, 2026

Copy link
Copy Markdown
Author

Congrats! CodSpeed is installed 🎉

🆕 23 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Open in CodSpeed

@codspeed-hq
codspeed-hq Bot marked this pull request as ready for review September 10, 2026 22:59
@codspeed-hq
codspeed-hq Bot requested a review from AzulGarza September 10, 2026 23:02
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