This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Pickle Serialization Mangles NllLossBackward Objects in Tensor Objects
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: dkostecki, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-12-02 06:23 by dkostecki, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg382294 - (view) Author: Daniel Kostecki (dkostecki) Date: 2020-12-02 06:23
torch.nn.functional.nll_loss returns Tensor objects which contain a loss value as well as a grad_fn object. Pickle does not throw an exception when serializing (dumps) the Tensor object. When loading (loads) the serialized data, the grad_fn object is lost and it becomes a requires_grad object. 

However, if one attempts to serialize the grad_fn object encapsulated in the Tensor object, Pickle then throws a TypeError (TypeError: cannot pickle 'NllLossBackward' object). This behavior seems inconsistent. Perhaps serialization of NllLossBackward objects should be supported or their encapsulating Tensors should also throw a TypeError.

This behavior should be easily reproducible.
msg382295 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-02 06:27
Torch is not the part of the standard Python library. Please file the report on the Torch bug tracker.
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86696
2020-12-02 06:27:14serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg382295

resolution: third party
stage: resolved
2020-12-02 06:23:16dkosteckicreate