Skip to content

Pass weights_only=False to torch.load for PyTorch 2.6+ compatibility#361

Open
netlinux-ai wants to merge 1 commit into
yl4579:mainfrom
netlinux-ai:fix/torch-load-weights-only
Open

Pass weights_only=False to torch.load for PyTorch 2.6+ compatibility#361
netlinux-ai wants to merge 1 commit into
yl4579:mainfrom
netlinux-ai:fix/torch-load-weights-only

Conversation

@netlinux-ai

Copy link
Copy Markdown

Problem

In PyTorch 2.6, the default value of weights_only in torch.load was changed from False to True. The published StyleTTS2 sub-module checkpoints (ASR, JDC, PLBERT) and the LibriTTS pretrained model contain pickled Python objects that the new safe loader rejects, so loading any of them under PyTorch ≥ 2.6 fails with:

_pickle.UnpicklingError: Weights only load failed.
WeightsUnpickler error: Unsupported global: GLOBAL getattr was not an allowed global by default.

This blocks train_finetune.py, train_finetune_accelerate.py, the ASR/JDC/PLBERT loaders, and the load_checkpoint helper.

Reproducer (any of the published artefacts triggers it):

import torch
torch.load("Utils/JDC/bst.t7", map_location="cpu")  # raises on torch ≥ 2.6

Fix

Pass weights_only=False explicitly at every torch.load call site that loads these checkpoints. They come from a trusted source (the repo's own pretrained artefacts), so the new safety guard is a false positive here.

Five call sites total — three in models.py, one in Utils/PLBERT/util.py. (train_*.py files load via these helpers, so no further changes are needed there.)

Tested with

  • PyTorch 2.7.0 + CUDA 12.6
  • Both the LibriTTS pretrained checkpoint and the bundled ASR/JDC/PLBERT modules load cleanly after the patch
  • Full fine-tune training run completed; rendered output matches expected behaviour

PyTorch 2.6 flipped the default value of `weights_only` to `True`, which
rejects the pickled-object format used in the published ASR / JDC / PLBERT
sub-module checkpoints and the LibriTTS pretrained model. Without this
change, train_finetune*.py cannot load any of them under modern torch.

These checkpoints are the project's own published artefacts, so loading
them with weights_only=False is the correct (and trusted) call.
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.

1 participant