Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

PyTorch 2.6 changed torch.load(weights_only=True) as the new default, causing NeuralProphet checkpoint deserialization to fail during LR finder with UnpicklingError: Unsupported global: GLOBAL neuralprophet.configure.ConfigSeasonality.

Changes

  • Register NeuralProphet classes as safe globals for PyTorch checkpoint loading before model initialization
  • Add .gitignore to exclude Python cache artifacts

The fix allowlists NeuralProphet configuration classes (ConfigSeasonality, Season, Trend, ConfigTrain, ConfigAR, ConfigLagged, ConfigEvents, ConfigCountryHolidays) via torch.serialization.add_safe_globals(). Wrapped in try-except for backward compatibility with PyTorch <2.6.

# predai/rootfs/predai.py
try:
    import torch.serialization
    from neuralprophet.configure import (
        ConfigSeasonality, Season, Trend, ConfigTrain,
        ConfigAR, ConfigLagged, ConfigEvents, ConfigCountryHolidays,
    )
    torch.serialization.add_safe_globals([
        ConfigSeasonality, Season, Trend, ConfigTrain,
        ConfigAR, ConfigLagged, ConfigEvents, ConfigCountryHolidays,
    ])
except (ImportError, AttributeError):
    pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Stuck in error loop</issue_title>
<issue_description>Just dipping my toes in the PredAI water.....

It's installed, but when starting it up I end up in a loop - this is the full log which just then repeats continously......


[12:07:03] INFO: PredAI init script running
Running App Process Management
Your API key is: 48715a5c205433598e1597b1b85e1e36647035ac923eda112bab5ff1574a563402d8e4b345fae8aabbed427cf2dffc0d72cdbe4a2e365467
Bootstrap predai
Copy initial python files
Startup
Importing plotly failed. Interactive plots will not work.
Importing plotly failed. Interactive plots will not work.
HA Interface started key 48715a5c205433598e1597b1b85e1e36647035ac923eda112bab5ff1574a563402d8e4b345fae8aabbed427cf2dffc0d72cdbe4a2e365467 url http://supervisor/core
Configuration loaded
Update at time 2025-12-30 12:00:00+00:00 Processing sensor sensor.load_today incrementing True max_increment 0 reset_daily True interval 30 days 14 export_days 14 subtract None
Getting history for sensor sensor.load_today start 2025-12-16T12:00:00+0000 end 2025-12-30T12:00:00+0000
History for sensor sensor.load_today starts at 2025-12-20 04:13:00+00:00 ends at 2025-12-30 11:59:00+00:00
Process dataset for sensor sensor.load_today start 2025-12-20 04:13:00+00:00 end 2025-12-30 11:59:00+00:00 incrementing True reset_low 1.0 reset_high 2.0
ds y
0 2025-12-20 04:00:00+00:00 0.00
1 2025-12-20 04:30:00+00:00 0.10
2 2025-12-20 05:00:00+00:00 0.13
3 2025-12-20 05:30:00+00:00 0.20
4 2025-12-20 06:00:00+00:00 0.19
.. ... ...
491 2025-12-30 09:30:00+00:00 0.31
492 2025-12-30 10:00:00+00:00 0.47
493 2025-12-30 10:30:00+00:00 0.28
494 2025-12-30 11:00:00+00:00 0.23
495 2025-12-30 11:30:00+00:00 1.11
[496 rows x 2 columns]
Create table sensor_load_today
Added 0 rows to database table sensor_load_today
Cleanup table sensor_load_today older than 2024-12-30 12:07:08+0000
Stored dataset in database and retrieved full history from database length 976
WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/neuralprophet/df_utils.py:464: FutureWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass include_groups=False to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.
if df.groupby("ID").apply(lambda x: x.duplicated("ds").any()).any():
WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/neuralprophet/df_utils.py:1152: FutureWarning: Series.view is deprecated and will be removed in a future version. Use astype as an alternative to change the dtype.
converted_ds = pd.to_datetime(ds_col, utc=True).view(dtype=np.int64)
WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/neuralprophet/df_utils.py:1152: FutureWarning: Series.view is deprecated and will be removed in a future version. Use astype as an alternative to change the dtype.
converted_ds = pd.to_datetime(ds_col, utc=True).view(dtype=np.int64)
WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/neuralprophet/df_utils.py:1152: FutureWarning: Series.view is deprecated and will be removed in a future version. Use astype as an alternative to change the dtype.
converted_ds = pd.to_datetime(ds_col, utc=True).view(dtype=np.int64)

Finding best initial lr: 0%| | 0/225 [00:00<?, ?it/s]WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/data.py:79: Trying to infer the batch_size from an ambiguous collection. The batch size we found is 32. To avoid any miscalculations, use self.log(..., batch_size=batch_size).

Finding best initial lr: 0%| | 1/225 [00:00<00:32, 6.80it/s]
Finding best initial lr: 7%|▋ | 16/225 [00:00<00:02, 77.24it/s]WARNING - (py.warnings._showwarnmsg) - /usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/data.py:79: Trying to infer the batch_size from an ambiguous collection. The batch size we found is 16. To avoid any miscalculations, use self.log(..., batch_size=batch_size).

Finding best initial lr: 14%|█▍ | 31/225 [00:00<00:01, 106.23it/s]
Finding best initial lr: 20%|██ | 46/225 [00:00<00:01, 122.09it/s]
Finding best initial lr: 28%|██▊ | 62/225 [00:00<00:01, 132.43it/s]
Finding best initial lr: 34%|███▍ | 77/225 [00:00<00:01, 138.02it/s]
Finding best initial lr: 41%|████▏ | 93/225 [00:00<00:00, 142.27it/s]
Finding best initial lr: 48%|████▊ | 108/225 [00:00<00:00, 141.45it/s]
Finding best initial lr: 55%|█████▍ | 123/225 [00:00<00:00, 142.25it/s]
Finding best initial lr: 61%|██████▏ | 138/225 [00:01<00:00, 144.06it/s]
Finding best ini...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 30, 2025 15:06
Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error loop on startup for PredAI Fix PyTorch 2.6 checkpoint loading incompatibility with NeuralProphet Dec 30, 2025
Copilot AI requested a review from springfall2008 December 30, 2025 15:09
@springfall2008 springfall2008 marked this pull request as ready for review December 30, 2025 15:13
Copilot AI review requested due to automatic review settings December 30, 2025 15:13
@springfall2008 springfall2008 merged commit 609ffb7 into main Dec 30, 2025
4 checks passed
@springfall2008 springfall2008 deleted the copilot/fix-predai-error-loop branch December 30, 2025 15:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical compatibility issue with PyTorch 2.6, which changed the default behavior of torch.load() to weights_only=True, causing NeuralProphet checkpoint deserialization to fail during the learning rate finder phase. The fix registers NeuralProphet configuration classes as safe globals for PyTorch's checkpoint loading mechanism, wrapped in a try-except block for backward compatibility with older PyTorch versions.

  • Registers NeuralProphet configuration classes (ConfigSeasonality, Season, Trend, ConfigTrain, ConfigAR, ConfigLagged, ConfigEvents, ConfigCountryHolidays) as safe globals using torch.serialization.add_safe_globals()
  • Adds comprehensive .gitignore file to exclude Python cache artifacts, virtual environments, IDE files, and OS-specific files

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
predai/rootfs/predai.py Added PyTorch 2.6 compatibility fix by registering NeuralProphet classes as safe globals for checkpoint loading, with backward compatibility exception handling
.gitignore Added comprehensive ignore patterns for Python cache files, virtual environments, IDE configurations, and OS-specific files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Stuck in error loop

2 participants