Hi,
Sorry for the delay in the answer, that thread dropped out of my unread list…

How does one detach so that it modifies the original Tensor as well and not just the view?

The detach/not detach is a property of a Tensor. So if you don’t call it on the original Tensor, it will have no effect.
You can check the thread I linked above that show how to do it.
Also note that this is not retro-active: you need to detach() (or detach_() which is just a shorthand for x = x.detach()) before using the Tensor, otherwise it won’t have any effect.

But I do need to retain the derivatives, right? I need derivatives up to k steps in the ‘past’.

If you plan to backprop in that same graph again, then yes!
But in your current code it is not clear if you were planning to do that or not so I just mentioned it as it is a common error people do.