Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add safe_globals to resume training on PyTorch 2.6
Starting from version 2.4 PyTorch introduces a stricter check for the objects which can be loaded with torch.load(). Starting from version 2.6 loading with weights_only=True requires allowlisting of such objects. This commit adds allowlist of some numpy objects used to load model checkpoints. Usage is restricted by context manager. User can still additionall call torch.serialization.add_safe_globals() to add other objects into the safe globals list. Fixes: huggingface#34631 See: pytorch/pytorch#137602 See: https://pytorch.org/docs/stable/notes/serialization.html#torch.serialization.add_safe_globals Signed-off-by: Dmitry Rogozhkin <[email protected]>
- Loading branch information