I am still not sure what the issue is here.
Nothing in PyTorch is holding onto that memory so there isn’t much we can do I think. It is most likely something in python when the exception is handled. So I would look more into that.
The extra memory use from the OS point of view is most likely a side effect of the caching alocator but the actual used memory is most likely the same.
I don’t think opening an issue would be very helpful if we don’t know where it comes from.