Gradient parallelization

I have a pretty standard implementation of a 5-parameter chi2-minimization fit using MINUIT, written in C++ and linking to the ROOT libraries. As I add more data and more complex calculations, the fit takes longer. Of course most of the time is spent calculating the new gradient after each step. If I could submit (say) 20 different chi2 calls at once, I could get a gradient much quicker.

Please note that I am not interested in parallelizing the chi2 calculation itself. I want to break up the gradient calculation which is the real bottleneck.

If there is an example someone could point to, I am happy to take up the challenge. I just need a good starting point. Thanks for any help.

Steve

Hi @sfpate ,

welcome back to the forum. I believe @moneta could point you to a good example.

Cheers,
Marta

Hello @sfpate!

I moved your question from the RooFit topic to the more general ROOT topic. Maybe it will get more attention there. You are not using RooFit, right? Just the regular ROOT libraries with Minuit, not the classes starting with Roo* like RooMinimizer, RooAbsPdf et cetera.

As a starting point to implement the gradient parallelization in Minuit: there is actually a way to do this when compiling Minuit2 standalone outside ROOT, with the minuit2_omp flag described here:
root/math/minuit2/README.md at master · root-project/root · GitHub.

The loop for the gradient will be parallelized when using this option:
root/math/minuit2/src/Numerical2PGradientCalculator.cxx at master · root-project/root · GitHub.

So you can try experimenting with a standalone Minuit2 that is built with this option! But note that the function must be thread safe for this to work.

You can also try to look into RooFit, which tries to optimize the gradient computation by caching many intermediate results, such that when one parameter is changed not everything has to be recomputed. But RooFit is not really made for chi-square fits, more for likelihood fits (although you can find some examples in the RooFit tutorials).

Hello @jonas

Thank you for your good input. Since I made my post, I did find this interesting article concerning the use of Roo* to speed up the gradient calculation.

It is correct that I am not using Roo* currently. I have been using Minuit Classic (haha) for a long time (starting circa 20 B.R.) and it usually serves my purposes. I will have a look at Minuit2 as you have suggested as a first step.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.