Ok, maybe I’m missing something. It’s just that your implementation is very close to the checkpoint one in the sense that you save the input, and redo a forward/backward during the backward pass.
What are the types of the inputs to your function? Do you have at least one Tensor that requires gradients there?