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

[Fix] loading model on machine with different accelerator #1509

Merged
merged 4 commits into from
Jan 17, 2024
Merged

[Fix] loading model on machine with different accelerator #1509

merged 4 commits into from
Jan 17, 2024

Conversation

McOffsky
Copy link
Contributor

🔬 Background

During my experiments with NP I've found out, that utils.load() is using trainer config is retrived from model, including accelerator. This caused an error on cpu machine while loading model fitted on GPU.

🔮 Key changes

  • NeuralProphet.restore_trainer() now takes optional argument, accelerator: str = None. If not provided, value stored in model will be used.

  • utils.load() now creates torch.device(map_location) into separate variable, and that variable is used in torch.load(). Orginal value is additionaly passed to NeuralProphet.restore_trainer() as accelerator

📋 Review Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, added docstrings and data types to function definitions.
  • [n/c] I have added pytests to check whether my feature / fix works.

Please make sure to follow our best practices in the Contributing guidelines.

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9493458) 88.33% compared to head (65f3289) 88.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1509      +/-   ##
==========================================
+ Coverage   88.33%   88.41%   +0.08%     
==========================================
  Files          38       38              
  Lines        5099     5103       +4     
==========================================
+ Hits         4504     4512       +8     
+ Misses        595      591       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@ourownstory ourownstory left a comment

Choose a reason for hiding this comment

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

Great addition, thank you!

@ourownstory
Copy link
Owner

Can be merged after passing of tests.

@McOffsky
Copy link
Contributor Author

McOffsky commented Jan 16, 2024

Happy to help (a bit) with such a great library!
I'll fix the issues tomorrow, it'a a bit late in my timezone ;)

@ourownstory
Copy link
Owner

Hi @McOffsky Thank you!
The failed tests are not related to your contribution, we can safely ignore them.

The pyright type checker did want a change of line 2737, I fixed it quickly - save your efforts for a later contribution.
(For your reference you can read about the type logic here: https://stackoverflow.com/questions/51710037/how-should-i-use-the-optional-type-hint)

Best,
Oskar

@ourownstory
Copy link
Owner

Update: waiting for rerun of tests to finish before merge.

@ourownstory ourownstory merged commit 203840f into ourownstory:main Jan 17, 2024
9 of 12 checks passed
Copy link

Model Benchmark

Benchmark Metric main current diff
AirPassengers MAE_val 31.6338 31.6337 -0.0%
AirPassengers RMSE_val 32.6669 32.6669 -0.0%
AirPassengers Loss_val 0.01372 0.01372 -0.0%
AirPassengers MAE 6.24137 6.24136 -0.0%
AirPassengers RMSE 7.82929 7.82928 -0.0%
AirPassengers Loss 0.00063 0.00063 -0.0%
AirPassengers time 10.6782 10.72 0.39%
YosemiteTemps MAE_val 0.64178 0.64178 0.0%
YosemiteTemps RMSE_val 0.92787 0.92787 0.0%
YosemiteTemps Loss_val 0.0005 0.0005 0.0%
YosemiteTemps MAE 1.092 1.092 0.0%
YosemiteTemps RMSE 1.89124 1.89124 0.0%
YosemiteTemps Loss 0.00155 0.00155 0.0%
YosemiteTemps time 59.4511 62.74 5.53% ⚠️
EnergyPriceDaily MAE_val 5.55889 5.55889 -0.0%
EnergyPriceDaily RMSE_val 7.12233 7.12233 -0.0%
EnergyPriceDaily Loss_val 0.02829 0.02829 -0.0%
EnergyPriceDaily MAE 6.37172 6.37172 -0.0%
EnergyPriceDaily RMSE 8.53016 8.53016 -0.0%
EnergyPriceDaily Loss 0.02907 0.02907 0.0%
EnergyPriceDaily time 15.2592 15.59 2.17%
PeytonManning MAE_val 0.3466 0.3466 0.0%
PeytonManning RMSE_val 0.49808 0.49808 0.0%
PeytonManning Loss_val 0.01752 0.01752 0.0%
PeytonManning MAE 0.34735 0.34735 0.0%
PeytonManning RMSE 0.48788 0.48788 0.0%
PeytonManning Loss 0.01457 0.01457 -0.0%
PeytonManning time 20.8968 22.12 5.85% ⚠️
Model training plots

Model Training

PeytonManning

YosemiteTemps

AirPassengers

EnergyPriceDaily

@ourownstory ourownstory changed the title Fix - loading model on machine with diffrent accelerator [Fix] loading model on machine with different accelerator Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants