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

TimeLLM takes a long time to setup training. #950

Closed
hxuaj opened this issue Apr 1, 2024 · 7 comments
Closed

TimeLLM takes a long time to setup training. #950

hxuaj opened this issue Apr 1, 2024 · 7 comments
Assignees
Labels

Comments

@hxuaj
Copy link

hxuaj commented Apr 1, 2024

What happened + What you expected to happen

Hi,
I was tring to run the example code of the TimeLLM model https://nixtlaverse.nixtla.io/neuralforecast/models.timellm.html#timellm
It took almost 1 hour before actual training. In the terminal, it only shows "Seed set to 1". I checked the GPU, where there is no GPU usage and only memory being taken about 500MB(~gpt2 size). Then the training began, it took only ~10s. In the training, there was usual GPU usage. Last, it also took ~1 hour to wrap up(predict time?).
I was wondering if it's a normal situation for TimeLLM since the model is new. If it's a problem, where the bottleneck could possibly be?
To exclude the network issue, I used local files to load GPT2:

gpt2_config = GPT2Config.from_pretrained(gpt2_local_path, local_files_only=True)
gpt2 = GPT2Model.from_pretrained(gpt2_local_path, config=gpt2_config, local_files_only=True)
gpt2_tokenizer = GPT2Tokenizer.from_pretrained(gpt2_local_path, local_files_only=True)

Hardware: NVIDIA T4 (only tried it on one of my GPUs due to #937)
OS: Linux

Versions / Dependencies

Python 3.9
neuralforecast 1.7.0

Reproduction script

https://nixtlaverse.nixtla.io/neuralforecast/models.timellm.html#timellm

Issue Severity

None

@hxuaj hxuaj added the bug label Apr 1, 2024
@JKYtydt
Copy link

JKYtydt commented Apr 8, 2024

发生了什么 + 你期望发生什么

你好, 我试图运行 TimeLLM 模型的示例代码https://nixtlaverse.nixtla.io/neuralforecast/models.timellm.html#timellm 在实际训练之前花了将近 1 小时。在终端中,它只显示“Seed set to 1”。我检查了 GPU,没有 GPU 使用情况,仅占用了大约 500MB(gpt2 大小)的内存。然后训练开始,只花了10s。在训练中,GPU 使用情况很常见。最后,也花了大约 1 个小时来结束(预测时间?)。 我想知道这是否是 TimeLLM 的正常情况,因为该模型是新的。如果有问题,瓶颈可能在哪里? 为了排除网络问题,我使用本地文件加载GPT2:

gpt2_config = GPT2Config.from_pretrained(gpt2_local_path, local_files_only=True)
gpt2 = GPT2Model.from_pretrained(gpt2_local_path, config=gpt2_config, local_files_only=True)
gpt2_tokenizer = GPT2Tokenizer.from_pretrained(gpt2_local_path, local_files_only=True)

硬件:NVIDIA T4(由于#937,仅在我的一个 GPU 上尝试过) 操作系统:Linux

版本/依赖项

Python 3.9 神经预测 1.7.0

复制脚本

https://nixtlaverse.nixtla.io/neuralforecast/models.timellm.html#timellm

问题严重性

没有任何

您好,我和您遇到了同样的问题,我把训练完的模型保存下来,再去做推理预测,依旧很慢,您这边是否解决了呢

@elephaint
Copy link
Contributor

Thanks - I can reproduce the issue (very long time to setup the training). We'll look into it.

@elephaint elephaint self-assigned this Apr 17, 2024
@JKYtydt
Copy link

JKYtydt commented Apr 23, 2024

谢谢 - 我可以重现这个问题(设置培训的时间很长)。我们会调查一下。

谢谢,期待您的回复

@elephaint
Copy link
Contributor

elephaint commented Apr 29, 2024

I can't seem to find a solution for this, unfortunately. TimeLLM with the current model also seems slow on my machine. Maybe you could try a different LLM from the Transformers library?

@hxuaj
Copy link
Author

hxuaj commented Apr 30, 2024

I can't seem to find a solution for this, unfortunately. TimeLLM with the current model also seems slow on my machine. Maybe you could try a different LLM from the Transformers library?

Thank you for the reply.
Do you mean apply LLMs other than gpt2 to TimeLLM? Since this issue, I switched to other models like nhits and timesnet already. Thanks again.

@elephaint
Copy link
Contributor

I can't seem to find a solution for this, unfortunately. TimeLLM with the current model also seems slow on my machine. Maybe you could try a different LLM from the Transformers library?

Thank you for the reply. Do you mean apply LLMs other than gpt2 to TimeLLM? Since this issue, I switched to other models like nhits and timesnet already. Thanks again.

Yes, indeed, that's what I'd try. But I haven't tried myself different models yet, so can't recommend one, I'm sorry.

@jexterliangsufe
Copy link

So what causes this problem? I am facing the same problem as you did.

ive2go added a commit to ive2go/neuralforecast that referenced this issue Jul 19, 2024
marcopeix added a commit that referenced this issue Sep 13, 2024
* Fix issue #950: Reduce TimeLLM setup time for training

* Restore changes on the examples

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* clear output

* modify test code

* Optimize model loading and add deprecation warning

- Simplify model loading logic
- Add constant for default model name
- Improve error handling for model loading
- Add success messages for model loading
- Implement deprecation warning for 'llm_config' and 'llm_tokenizer' parameters
- Update print messages for clarity
- Remove redundant code

This commit improves code readability, maintainability, and user experience
by providing clearer feedback and warnings about deprecated parameters.

* Resolved conflict in nbs/models.timellm.ipynb

---------

Co-authored-by: ive2go <[email protected]>
Co-authored-by: Olivier Sprangers <[email protected]>
marcopeix added a commit that referenced this issue Sep 13, 2024
* Fix issue #950: Reduce TimeLLM setup time for training

* Restore changes on the examples

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* clear output

* modify test code

* Optimize model loading and add deprecation warning

- Simplify model loading logic
- Add constant for default model name
- Improve error handling for model loading
- Add success messages for model loading
- Implement deprecation warning for 'llm_config' and 'llm_tokenizer' parameters
- Update print messages for clarity
- Remove redundant code

This commit improves code readability, maintainability, and user experience
by providing clearer feedback and warnings about deprecated parameters.

* Resolved conflict in nbs/models.timellm.ipynb

---------

Co-authored-by: ive2go <[email protected]>
Co-authored-by: Olivier Sprangers <[email protected]>
marcopeix added a commit that referenced this issue Sep 16, 2024
* Use math.ceil to prevent shape mismatch

* Show exog support for KAN in doc

* FEAT: TimeLLM is faster and supports more LLMs (#1139)

* Fix issue #950: Reduce TimeLLM setup time for training

* Restore changes on the examples

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* clear output

* modify test code

* Optimize model loading and add deprecation warning

- Simplify model loading logic
- Add constant for default model name
- Improve error handling for model loading
- Add success messages for model loading
- Implement deprecation warning for 'llm_config' and 'llm_tokenizer' parameters
- Update print messages for clarity
- Remove redundant code

This commit improves code readability, maintainability, and user experience
by providing clearer feedback and warnings about deprecated parameters.

* Resolved conflict in nbs/models.timellm.ipynb

---------

Co-authored-by: ive2go <[email protected]>
Co-authored-by: Olivier Sprangers <[email protected]>

* Consistency with math.ceil

---------

Co-authored-by: Olivier Sprangers <[email protected]>
Co-authored-by: ive2go <[email protected]>
marcopeix added a commit that referenced this issue Sep 16, 2024
* Use math.ceil to prevent shape mismatch

* Show exog support for KAN in doc

* FEAT: TimeLLM is faster and supports more LLMs (#1139)

* Fix issue #950: Reduce TimeLLM setup time for training

* Restore changes on the examples

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* clear output

* modify test code

* Optimize model loading and add deprecation warning

- Simplify model loading logic
- Add constant for default model name
- Improve error handling for model loading
- Add success messages for model loading
- Implement deprecation warning for 'llm_config' and 'llm_tokenizer' parameters
- Update print messages for clarity
- Remove redundant code

This commit improves code readability, maintainability, and user experience
by providing clearer feedback and warnings about deprecated parameters.

* Resolved conflict in nbs/models.timellm.ipynb

---------

Co-authored-by: ive2go <[email protected]>
Co-authored-by: Olivier Sprangers <[email protected]>

* Consistency with math.ceil

---------

Co-authored-by: Olivier Sprangers <[email protected]>
Co-authored-by: ive2go <[email protected]>
marcopeix added a commit that referenced this issue Sep 18, 2024
* WIP - Add reversible mixture of kan

* WIP - Allows import of RMoK

* AutoRMoK, add it to doc, add parameters

* Fix tests

* Get default config of AutoRMoK

* FIX: timemixer shapes mismatch and doc update (#1138)

* Use math.ceil to prevent shape mismatch

* Show exog support for KAN in doc

* FEAT: TimeLLM is faster and supports more LLMs (#1139)

* Fix issue #950: Reduce TimeLLM setup time for training

* Restore changes on the examples

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Revert changes to nbs/models.ipynb, nbs/models.softs.ipynb and neuralforecast/_modidx.py

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* Refactor code to dynamically load models with AutoModel, AutoTokenizer, and AutoConfig

- Updated load_model_and_tokenizer function to use AutoModel, AutoTokenizer, and AutoConfig for flexible model loading.
- Included default model(gpt2) for cases where the specified model fails to load.
- Kept llm, llm_config, and llm_tokenizer arguments to minimize changes.
- Changed llm from storing pretrained weights to accepting pretrained model path to reduce necessary modifications.

This update enhances the flexibility and reliability of model loading based on received feedback while minimizing necessary changes.

* clear output

* modify test code

* Optimize model loading and add deprecation warning

- Simplify model loading logic
- Add constant for default model name
- Improve error handling for model loading
- Add success messages for model loading
- Implement deprecation warning for 'llm_config' and 'llm_tokenizer' parameters
- Update print messages for clarity
- Remove redundant code

This commit improves code readability, maintainability, and user experience
by providing clearer feedback and warnings about deprecated parameters.

* Resolved conflict in nbs/models.timellm.ipynb

---------

Co-authored-by: ive2go <[email protected]>
Co-authored-by: Olivier Sprangers <[email protected]>

* Consistency with math.ceil

---------

Co-authored-by: Olivier Sprangers <[email protected]>
Co-authored-by: ive2go <[email protected]>

* Add image, docstring, fix typo in comment

---------

Co-authored-by: Olivier Sprangers <[email protected]>
Co-authored-by: ive2go <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants