Add CodSpeed continuous benchmarking - #19
Open
codspeed-hq[bot] wants to merge 1 commit into
Open
Conversation
Author
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.
This sets up continuous performance measurement with CodSpeed for the library's core forecasting pipeline.
What was added
Benchmarks (
benchmarks/) — 23 benchmarks run withpytest-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/ydtype conversion, seasonality lookup, and bothQuantileConverterconversions (levels <-> quantile columns).test_bench_dataset.py:TimeSeriesDataset.from_df(two batch sizes), batch iteration,make_future_dataframe, and the_DataProcessortensor 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_validationwith 1 and 4 windows, anddetect_anomalies.Fixtures in
benchmarks/conftest.pygenerate deterministic panels (20 series x 200 rows, 200 series x 500 rows) withutilsforecast.data.generate_series, which is seeded by default so measurements are stable run to run.pytesttestpathsis 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 tomain, on pull requests, and viaworkflow_dispatch(used by CodSpeed for backtests). It mirrors the existing CI job:astral-sh/setup-uv@v6with caching plus the same disk-cleanup step, since the dependency set (torch, gluonts and the model packages) is large. Benchmarks run throughCodSpeedHQ/action@v5insimulationmode onubuntu-latest, authenticated with OIDC (id-token: write), so no token secret is required.Other —
pytest-codspeedadded to thedevdependency 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 formatandmypy(same settings as the pre-commit hooks) pass on the new files, anduv run pytest tests/corestill passes.Next steps
mainso CodSpeed records a baseline; subsequent pull requests will then get automatic performance reports.