Hi,



 bianDe:

Is there a way to reconnect the differentiation graph after .detach() for the bisection search ?


Yes, you would want to write a custom autograd.Function 2. Note that you don’t need to detach the tensor as the forward is implicitly run



 bianDe:

Is there a way to supply the correct gradients (dx/dz)^(-1) for the detached connection ?


Yes, you can use torch.autograd.grad to get dx/dz after computing x with a gradient-requiring copy of z in an torch.enable_grad() block . I would probably do this in the backward.
Best regards
Thomas