Reviving this thread, because I now encounter a problem that I think is related to your last sentence.
Same project, I’m now using a simple python list to store my states and then generate a tensor from it with torch.stack, for following computations.
Now during training I need loads of memory. Current runs with multiple layers and larger states fail on my universities cluster because they run out of memory (251GB are available on one node).
What exactly do you mean by

make sure the list empties out not to leak a lot of tensors

And how do I achieve this?