Implement reg:gamma through custom objective function

Hi all,

I have been working with the reg:gamma objective function in my work and to better understand the implementation, I wanted to try use the custom objective function feature to replicate reg:gamma.

I have had a look at the implementation of the negative log-likelyhood of reg:gamma : https://github.com/dmlc/xgboost/blob/7663de956c37eb4dd528132214e68ba2851d9696/src/metric/elementwise_metric.cu#L270-L286

but when I try to implement the gradient and hessian (1st and 2nd order partial derivative of the loss function with the predicted value) for this loss function the results differ completely from reg:gamma. Does anyone know how to correctly Implement reg:gamma through a custom objective function or if it is even possible?

Cheers.

Memory is a little blur now. I think the gamma obj is derived from deviance.