Using optimiser inside another optimiser

I need to use solve on sparse equations but since it’s not supported, i’m thinking of using the conjugate gradient(or any other optimizer really) to solve the sparse equation. However to implement that i’m not sure how i can run the conjugate gradient and not break the computational graph. i.e i can’t run it in no_grad since i need the gradients to calculate the conjugate gradient. what can i do?