Ho ok, in that case you can save Mpre like res. But keep weights in save_for_backward to avoid the memory leak.

for any input or output

Yes I mean input and outputs of the forward() function.
And as you mentionned, it is input or output Tensors only. Other types can be saved in ctx.