Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/optimized hfc torch #2013

Merged
merged 20 commits into from
Oct 28, 2023
Merged

Feat/optimized hfc torch #2013

merged 20 commits into from
Oct 28, 2023

Conversation

dennisbader
Copy link
Collaborator

@dennisbader dennisbader commented Sep 29, 2023

Fixes #1543, fixes #2025.

Summary

  • adds optimized historical forecasting for torch models
  • available with all configurations (overlap, last_points_only, autoregression, int/dt index, single/multi series, ...)
  • fixes a bug when using future covariates with historical forecasting, the predictions didn't extend to the expended end time
  • refactored _get_historical_forecastable_time_index() to account for forecast_horizon and overlap_end directly

Other Information

  • last potential performance boost would be to avoid generating the time series in PLForecastingModule.predict_step(). this can be left for the another PR IMO

Benchmarking

Tested different configuration for using NLinearModel using the optimized and on non-optimized historical forecasting (hist fc)

Some parameters explained:

  • multi_series:
    • False computes hist fcs on a single series with a total of roughly 10k iterations.
    • True computes hist fcs on 100 series with a total of roughly 10k iterations.
last_points_only is_autoregressive is_int_idx multi_series time_non_optimized time_optimized boost up [times]
True False False False 105.118 8.034 13.08
True False False True 96.251 7.667 12.55
True False True False 96.185 5.592 17.2
True False True True 86.841 4.933 17.6
True True False False 104.748 7.727 13.56
True True False True 92.924 7.496 12.4
True True True False 91.359 5.302 17.23
True True True True 82.67 4.791 17.26
False False False False 99.843 7.599 13.14
False False False True 92.049 7.093 12.98
False False True False 89.718 5.43 16.52
False False True True 83.32 4.562 18.26
False True False False 99.991 7.927 12.61
False True False True 92.429 7.126 12.97
False True True False 91.653 5.29 17.33
False True True True 81.988 4.874 16.82

@codecov-commenter
Copy link

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
darts/models/forecasting/ensemble_model.py 94.73% <100.00%> (+0.09%) ⬆️
darts/models/forecasting/forecasting_model.py 94.96% <100.00%> (+0.02%) ⬆️
darts/models/forecasting/pl_forecasting_module.py 93.97% <100.00%> (+0.02%) ⬆️
darts/models/forecasting/regression_model.py 96.76% <100.00%> (+0.26%) ⬆️
darts/utils/historical_forecasts/__init__.py 100.00% <100.00%> (ø)
...casts/optimized_historical_forecasts_regression.py 97.56% <100.00%> (ø)
darts/utils/timeseries_generation.py 96.18% <100.00%> (+0.02%) ⬆️
...arts/models/forecasting/torch_forecasting_model.py 90.71% <86.66%> (-0.17%) ⬇️
..._forecasts/optimized_historical_forecasts_torch.py 94.59% <94.59%> (ø)
darts/utils/historical_forecasts/utils.py 92.71% <95.00%> (+0.32%) ⬆️
... and 1 more

... and 5 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Collaborator

@madtoinou madtoinou left a comment

Choose a reason for hiding this comment

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

Really nice job @dennisbader, we should maybe include the "trick" used to optimize each historical forecasts routine in the docstring so that if other contributors want to improve it, they don't have to figure it out themself.

darts/utils/data/inference_dataset.py Outdated Show resolved Hide resolved
darts/utils/data/inference_dataset.py Show resolved Hide resolved
darts/utils/data/inference_dataset.py Show resolved Hide resolved
darts/utils/data/inference_dataset.py Show resolved Hide resolved
darts/utils/data/inference_dataset.py Show resolved Hide resolved
darts/utils/data/inference_dataset.py Show resolved Hide resolved
darts/utils/historical_forecasts/utils.py Outdated Show resolved Hide resolved
@dennisbader dennisbader reopened this Oct 28, 2023
@dennisbader dennisbader merged commit ea37dc9 into master Oct 28, 2023
18 checks passed
@dennisbader dennisbader deleted the feat/optimized_hfc_torch branch October 28, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants