-
Notifications
You must be signed in to change notification settings - Fork 650
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
[API] Redesign towards pytorch-forecasting 2.0 #1736
Comments
Having reviewed multiple code bases - The model layer will mostly follow the data layer, given that My suggestions for high-level requirements on data loaders:
Observations of the current API:
The explicit specifications can be reconstructed from usage and docstrings, for convenience listed below:
|
question for @jdb78 - why did you design the Side note: one possible design is to have data loaders that are specific to neural networks, facing a more general API |
|
@geetu040, what I mean is the format of the So, for |
@fkiraly what are your reviews on model initialization in |
The idea is that basically all models can be represented as encoder/decoder. In some cases they are the same. |
Is that really true though for all models out there? And do we need this as See for instance Amazon Chronos: or Google TimesFM: What I think we need for 2.0 is an API design that can cover all torch-based forecasting models. |
I think there is no serious problem with that as ultimately it calls
|
Yup, the interface complication is the main concerning thing considering use-cases like those involving single model. But yes, the positive and negative sides need cost-benefit analysis to decide final. |
Some further thoughts about the design:
I would hence suggest, on the
|
I would like to the following topics to the discussion of redesigning the API:
Specific replies to thoughts from above.
Should the
Why should be the loader model specific. The loader's task is to provide an iterable by combining a Unfortunately, I haven't attended any of the planning sessions, thus the following question might be already answered. Why are we currently aiming for having one |
@benHeid, excellent points! Replies to your raised design angles:
Good idea to introduce a separation here. Question, why do you think we cannot modify the trainer in the current state of More generally, what are architectures you can think of that allow to treat all the abovementioned trainers under one interface?
I think this is more complex than needs be and needs a redesign, but it is not affecting the base API as such, as far as I can see - therefore I would leave it to later, after the base API rework. My approach would be to replace inheritance with tags and/or polymorphism in a lower number of base classes. The model specific ones perhaps need to stay, but the type specific ones could be merged. However, I think it makes sense only after we have reworked the base API, as it will imply how the base classes will look like.
Good question. The idiomatic architecture for As mentioned, the current architecture violates this idiom, since the |
Specific replies to thoughts from above.
I would disagree with the opinion that slicing should be part of the I interpret the architectural intention (which is not very clear in the If we accept this architectural intention as correct, this implies:
My reasoning is, that some but not all models require a loader that has encoder/decoder specifics. Examples are most current models, counterexamples are some models in DSIPTS and the above linked foundation models. If we accept that some models require encoder/decoder batches, while some others do not, and we think that this should be done in a
I think this is a corollary of how you envision the separation of
To clarify, that is not the aim in my design. In my design, there would probably be a small number of We should of course not need to define one The key problem is actually the state you are pointing out as problematic - currently, we have to define one
No problem, we will have a big one with new mentees, @agobbifbk plus team, in the new year (the FBK team will return next week from holiday). @thawn, you are very welcome to attend and participate in planning too. We will align on a date for this in the |
Technical it is possible. However, the user has to change the Trainer in that case. So I think introducing a Trainer with a major version release is more intuitive. And than the user does not have to change it.
I think all architectures can be trained with that trainer. However, there might be features that we would like to implement that are time series specific. E.g., Truncated back propagation through time, which was removed from lightning trainer: #1581 |
With regards to the discussion, where the slicing is located. I am still not convinced that a custom DataLoader should be a solution, and I still think that tasks like slicing are intended to be part of datasets and not of Dataloaders. The reasons why I think this are:
|
I do not completely grasp the context - could you perhaps add two code snippets, current and speculative, for modifying trainer?
Hm, I see how one could make an argument either way. Then, would the implied design be (a) raw time series dataset without slicing e.g., as a To avoid chaining, we can always have an all-in-one delegator. |
Currently, her are importing directly from
Yes |
This PR carries out a clean-up refactor of `TimeSeriesDataSet`. No changes are made to the logic. This is in preparation for major work items impacting the logic, e.g., removal of the `pandas` coupling (see #1685), or a 2.0 rework (see #1736). In general, a clean state would make these easier. Work carried out: * clear, and complete docstrings, in numpydoc format * separating logic, e.g., for parameter checking, data formatting, default handling * reducing cognitive complexity and max indentations, addressing "code smells" * linting
@fkiraly I am back from vacation. I hope you had a relaxing time during the Holidays. Before I get started with figuring out how I can help with the integration ofTime-Series-Library: Have you tried contacting the original developers of that library? I think this is important for two reasons:
|
I think somewhere I pinged them, but you are right - we should also let them know and ask very explicitly, with the current state of discussions. I see multiple options that make technical sense:
Both options will require agreeing on a common framework level API - I still think DSIPTS is closest to what we want, of course comments are much appreciated. FYI @wuhaixu2016, @ZDandsomSP, @GuoKaku, @DigitalLifeYZQiu, @Musongwhk (please feel free to add further pings if I forgot someone) |
Agree, at least credit needs to be given clearly to the authors of time-series-library! A complication is that there is much copy-pasting going on in the neural network area historically, some (but not all) code in time-series-library is even copied from elsewhere afaik. I think we should also come up with a way to fairly assign credit while backtracking the entire copy-merge-modify tree, although that might be a bit of work. A complication is that the people actively maintaining the code may be different from those who wrote parts of it (but no longer maintain it), and all deserve credit! sktime/sktime#6850 The first PR includes handling of |
Regarding the API of Time-Series-Libraryfrom my (limited) grasp of the code, this consists of the following:
My feeling is that adapting this to any more general API will require major work. Using TimesNet in my code required me to write my own dataset and dataloaders as well as model wrapper. Edit: this should not be taken as criticism of Time-Series-Library. I am very grateful to the authors for their code and their papers. Their work helped me a lot for my project. It just shows that the library was written for a specific purpose (benchmarking) and not as a general purpose API like what is planned here. |
A lot of models in DSIPTS are an adaptation of online repositories with the same logic of Time-Series-Library. What I've done so far is to align and standardize these API calls in the DSIPTS data preparation. I also found hard to understand the input parameters sometimes, this is why I leverage on Hydra. |
For discussion on Fri, here is a speculative design for a raw data container. |
outcome from prioritization meeting on Jan 15: data layer - dataset, dataloader 👍👍👍👍👍👍👍 💬 ✔️✔️✔️
model layer - base classes, configs, unified API 👍👍👍👍 ✔️
foundation models, model hubs 👍 👍 👍
documentation👍✔️
benchmarking 👍 👍💬
mlops and scaling (distributed, cluster etc)👍 👍
more learning tasks supported
|
I came up with this https://zarr.readthedocs.io/en/stable/. It is widely used when you have a large dataset that can not fit on RAM/VRAM. The idea is to create the zarr before creating the dataset. It generates chunks of data on a give dimension(s), in hour case temporal dimension, the datasets open the zarr and in the get_item function you retrieve the window you ask for.
PROs:
CONs:
|
+1 from me. We are also using zarr as file backend in our time series project. |
As default data format in our minimal dataset class, I realized that xarray may be a great choice: Xarray natively supports column names (i.e. metadata) as well as n-dimentional columns, which makes it an ideal replacement for both numpy and pandas. Furthermore, it has the advantage of dask support (which handles memory issues very well). By using Dask.array, xarray enables native chunking (ideal for non-overlapping time windows) as well as overlapping chunks (for sliding time windows). |
@agobbifbk, @thawn, I think there are multiple solutions that have a similar feature set - As long as we have consistent |
FYI, a simplified version of the previous design sketch here: #1757 - for discussion |
Desiderata from the DataSet component:
|
Completed a design proposal draft here: sktime/enhancement-proposals#39 Input appreciated! |
Discussion thread for API re-design for
pytorch.forecasting
next 1.X and towards 2.0. Comments appreciated from everyone!Summary of discussion on Dec 20, 2024 and prior, about re-design of
pytorch-forecasting
.FYI @agobbifbk, @thawn, @sktime/core-developers.
High-level directions:
pytorch-forecasting 2.0
. We will need to homogenize interfaces, consolidate design ideas, and ensure downwards compatibility.thuml
project, also see [ENH] neural network libraries in thuml time-series-library sktime#7243.sktime
.High-level features for 2.0 with MoSCoW analysis:
sktime
and DSIPTS, but as closely to thepytorch
level as possible. The API need not cover forecasters in general, onlytorch
based forecasters.skbase
can be used to curate the forecasters as records, with tags, etcthuml
Todos:
0. update documentation on dsipts to signpost the above. README etc.
The text was updated successfully, but these errors were encountered: