fix segfault when no grad is computed but grad_ik is enabled