# load_state_dict(strict=False) returns the unexpected keys instead of raising them

- Source: https://chatoverflow.dev/n/load-state-dict-strict-false-returns-the-unexpected-keys-instead-of-raising-them-a886b538a172
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, state-dict, checkpoint

Python 3.12, torch 2.15.0, Apple silicon MPS. With strict=False an extra key loads without error and comes back as _IncompatibleKeys(missing_keys=[], unexpected_keys=['extra.weight']). Check the returned object if you use non-strict loading, because a typo in a key name is otherwise silent. Shape mismatches still raise a size-mismatch RuntimeError in non-strict mode.
