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

[ENH] Add support for TimesFM #6408

Open
benHeid opened this issue May 11, 2024 · 15 comments
Open

[ENH] Add support for TimesFM #6408

benHeid opened this issue May 11, 2024 · 15 comments
Assignees
Labels
enhancement Adding new functionality interfacing algorithms Interfacing existing algorithms/estimators from third party packages module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting

Comments

@benHeid
Copy link
Contributor

benHeid commented May 11, 2024

Support for TimesFM, the time series foundation model from google research:

@benHeid benHeid added module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting enhancement Adding new functionality labels May 11, 2024
@fkiraly
Copy link
Collaborator

fkiraly commented May 11, 2024

added it to the list here: #6177

One of these days, we should perhaps create our own?

@fkiraly fkiraly added the interfacing algorithms Interfacing existing algorithms/estimators from third party packages label May 11, 2024
@geetu040
Copy link
Contributor

I have a question: What is the right way to implement this interface?

  1. add the package timesfm as a dependency to sktime and create the interface on top of that?
  2. repeat the model implementation using the same libraries and code that is in the actual source? - that will put jax and related libraries as new dependencies in sktime
  3. convert the model code from jax to pytorch and build an interface on top of the pytorch adapter in sktime?

@benHeid
Copy link
Contributor Author

benHeid commented May 24, 2024

I would prefer option 1 if possible. If this is not possible we can discuss in more detailed how to proceed

@julian-fong
Copy link
Contributor

julian-fong commented Jun 1, 2024

@fkiraly @geetu040 @benHeid Just pinging to confirm whether or not this item is picked up yet.

I would like to pick this issue up and create an interface for TimesFM

@geetu040
Copy link
Contributor

geetu040 commented Jun 4, 2024

@julian-fong did you start working on this? I was also planning to do so. If you are busy with something else as well, I can take this up.

@geetu040
Copy link
Contributor

geetu040 commented Jun 5, 2024

@fkiraly There are a few things with TimesFM

  • it also uses freq, should we deal with it the same way we dealt with NeuralForecast in [ENH] NeuralForecastRNN should auto-detect freq #6039
  • it has no training interface - it can only do zero-shot forecasting on a pre-trained model, should we keep it that way?
  • user can provide device as an argument like "cpu", "gpu" or "tpu" - should we give this option as a parameter to this interface as well?

@fkiraly
Copy link
Collaborator

fkiraly commented Jun 5, 2024

it also uses freq, should we deal with it the same way we dealt with NeuralForecast

You mean, as mandatory arg?
Yes, that might be a good idea - if it is the same logic, it might be worth moving it to a common or an adapter module.

it has no training interface - it can only do zero-shot forecasting on a pre-trained model, should we keep it that way?

No context or fine-tuning? That is odd for an FM, but if it is so, then fit is simply empty.

user can provide device as an argument like "cpu", "gpu" or "tpu" - should we give this option as a parameter to this interface as well?

Why not?

@geetu040
Copy link
Contributor

geetu040 commented Jun 6, 2024

Why not?

I have tried this on linux and things are working fine - but I have seen people raise issues and also discussed this with @julian-fong that there can be possible failures on windows and mac, especially when device is set to "gpu"

it might be worth moving it to a common or an adapter module.

sure, I'll look into that

@geetu040
Copy link
Contributor

geetu040 commented Jun 6, 2024

@fkiraly this might be blocking - TimesFM does not work for all python versions, how do we handle that?

@julian-fong
Copy link
Contributor

From my understanding - the package timesfm does not work on windows and mac because the required package lingvo is not available. Threads detailing the errors can be found here google-research/timesfm#1 and google-research/timesfm#24

@geetu040
Copy link
Contributor

geetu040 commented Jun 6, 2024

It works on colab but when I try to debug locally (ubuntu) I run from one error to another


On installation, gives this error if python>=3.11

ERROR: Could not find a version that satisfies the requirement lingvo==0.12.7 (from paxml) (from versions: none)
ERROR: No matching distribution found for lingvo==0.12.7

On python<=3.10 when you try to debug or try creating completely new conda env from .yml file and running the code gives these different errors

1

 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

2

2024-06-06 17:16:08.597909: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
Segmentation fault (core dumped)

3

  File "/home/geetu/miniconda3/envs/310/lib/python3.10/asyncio/locks.py", line 234, in __init__
    raise ValueError("loop argument must agree with lock")
ValueError: loop argument must agree with lock

@fkiraly
Copy link
Collaborator

fkiraly commented Jun 6, 2024

I start wondering whether anyone anywhere has succeeded in getting this to run?

@geetu040
Copy link
Contributor

geetu040 commented Jun 6, 2024

well it works with no error, no warning on google colab - I have tried to mimic the library versions of jax, jaxlib and tf from colab, all in vain. It seems to really depend on the hardware other than just libraries

@fkiraly
Copy link
Collaborator

fkiraly commented Jun 6, 2024

maybe that's just google's way to try getting everyone to use colab 😁

@geetu040
Copy link
Contributor

geetu040 commented Jun 7, 2024

Extending the above comment #6408 (comment)

Once the library is installed on python<=3.10 the stated errors are raised on this simple code snippet from the official documentation.

import timesfm

tfm = timesfm.TimesFm(
    context_len=<context>,
    horizon_len=<horizon>,
    input_patch_len=32,
    output_patch_len=128,
    num_layers=20,
    model_dims=1280,
    backend=<backend>,
)
tfm.load_from_checkpoint(repo_id="google/timesfm-1.0-200m")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality interfacing algorithms Interfacing existing algorithms/estimators from third party packages module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting
Development

No branches or pull requests

4 participants