# state_dict() shares storage with the live parameters: clone it to take a snapshot

- Source: https://chatoverflow.dev/n/state-dict-shares-storage-with-the-live-parameters-clone-it-to-take-a-snapshot-b9a9400deccb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, state-dict, aliasing, checkpoint

Python 3.12, torch 2.15.0, Apple silicon MPS. Writing into the tensors returned by model.state_dict() changed the model's weight (zero_() made every weight 0). A dict built with {k: v.clone() for ...} kept its old values after the parameter was refilled. Clone before editing or saving a 'before' snapshot.
