feat: Add native implementation of PatchTST for long-term forecasting - #2352
feat: Add native implementation of PatchTST for long-term forecasting#2352nareshmethuku wants to merge 9 commits into
Conversation
5135258 to
294eb2a
Compare
- Implements PatchTST architecture with Channel Independence and patching - Inherits from BaseModelWithCovariates with full support for covariates - Integrates multi-quantile support in FlattenHead for probabilistic loss - Adds full integration and unit tests for the architecture - Updates README to include PatchTST
294eb2a to
e540425
Compare
phoeenniixx
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR and welcome to pytorch-forecasting!
Can you please also implement pkg class for PatchTST? (See DeepAR_pkg, or any other model pkg class for example) This will be used to test the model over a fixed set of test scenarios by the unified test framework.
See the pkg class doc here: https://pytorch-forecasting.readthedocs.io/en/stable/pkg.html
Also can you please move the sub_modules to layers module?
|
A suggestion: Also, it would be greatly appreciated if you could give us some feedback on v2 - try out the tutorials here. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2352 +/- ##
=======================================
Coverage ? 86.95%
=======================================
Files ? 182
Lines ? 10450
Branches ? 0
=======================================
Hits ? 9087
Misses ? 1363
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… (V1 & V2) This PR introduces the PatchTST (A Time Series is Worth 64 Words) architecture to pytorch-forecasting. Changes - Implements PatchTST inheriting from BaseModelWithCovariates with full support for covariates. - Implements PatchTST_pkg integrating the model deeply into the unified test suite. - Extracted and added PatchEmbedding and PatchTSTFlattenHead to the core pytorch_forecasting.layers module as requested. - Provided a full implementation for the upcoming V2 architecture in _patch_tst_v2.py (inheriting from TslibBaseModel) and registered it with _patch_tst_pkg_v2.py.
|
Hi @phoeenniixx, I've addressed all the requested changes, updated the branch, and all checks are passing now. Could you please take another look when you have a chance? Also looping in @fkiraly @benHeid @jdb78 for review if available. Thank you! |
This PR introduces the PatchTST (A Time Series is Worth 64 Words) architecture to
pytorch-forecasting. PatchTST leverages Channel Independence and patching of time series to achieve state-of-the-art performance on long-term forecasting.Changes
PatchTSTand core submodules (PatchEmbedding,FlattenHead).BaseModelWithCovariateswith full support for static, time-varying continuous, and time-varying categorical covariates. Following the principles of Channel Independence, all covariates are mapped into independent channels.QuantileLossvia multi-quantile forecasting in the flattening head.README.mdto list PatchTST as a supported model.Tests
Tested via
pytest tests/test_models/test_patch_tst.pyunder various configurations:test_integration(standard MAE training loop)test_quantile_losstest_multiple_targetstest_no_exogenous_variablesAll tests pass locally with full coverage. Code is formatted via
pre-commit.