Hi,

For the empty cache, this function should be available if you include the right headers. You can check how it’s used in pytorch here 54.
If you run with no grad, then no state will be saved. States are only saved if they are required to compute gradients. So if no gradients are needed, no state will ever be saved. You can use the GradMode object for such tasks as done here 22.