You can use torch.autograd.gradcheck(eval_g, x) with input in double precision to check as well.
Also you have a jacobian function here 11 if you need the full Jacobian.
From a quick look at your code, it seems that there are a lot of things that are not define in the function but captured from other scopes right?
If you can make a small code sample that uses eval_g that reproduce the issue (you can our gradcheck so that we won’t need IPOPT to run this toy example), I can take a look.