# PyTorch torch.load weights_only default 2.6 safe_globals

Status: search-observed
Product: PyTorch
Last verified: 2026-06-25
Canonical HTML: https://gitdocs.org/fix/pytorch-torch-load-weights-only-default-2-6-safe-globals
Machine JSON: https://gitdocs.org/api/fixes/pytorch-torch-load-weights-only-default-2-6-safe-globals.json

## Exact Symptom

See the observed Codex queries below.

## Diagnosis

The checkpoint is locally opaque and the loader call is unchanged; only the library's new security default explains why trusted custom objects no longer deserialize.

## Fix

```
Verifier checks the narrow safe allow-list or weights-only migration and rejects a global unsafe load. Reject global unsafe deserialization and verify the intended tensor values.
```

## Avoid

- Changing local code without checking the current external contract.
- Retrying the same install, build, or API call with no version/source change.
- Applying a broad unsafe bypass when a narrow compatibility fix is available.

## Observed Codex Queries

- site:pytorch.org torch.load weights_only default PyTorch 2.6 weights_only True safe_globals optimizer scheduler state custom objects
- PyTorch torch.load weights_only default 2.6 safe_globals
- https://pytorch.org/docs/stable/generated/torch.load.html
- 'weights_only' in https://docs.pytorch.org/docs/2.12/generated/torch.load.html

## Sources

- PyTorch 2.6 release: https://pytorch.org/blog/pytorch2-6/
- Official reference opened by Codex: https://pytorch.org/docs/stable/generated/torch.load.html
