RooFit with BatchMode, error: getBatches() not implemented in RooTreeDataStore

Dear experts,

I am using RooFit with BatchMode:

RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), BatchMode(“CPU”));

I have tried this method. It works for RooFit’s official PDF such as RooGaussian, but when I apply it to my DIY PDF (for test), It reports an error:

[#1] INFO:Fitting – RooAbsPdf::fitTo(pdf) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting – using CPU computation library compiled with -mavx512
This functionality is not yet implemented for tree data stores.
terminate called after throwing an instance of ‘std::logic_error’
what(): getBatches() not implemented in RooTreeDataStore.

The ROOT version is v6-26-10, RooFit version is v3.60.
Does anyone know why? I am looking forward to your reply.

Thank you,
Jianyu

Hi @Jianyu,

thanks for asking, very nice that you are testing the new RooFit backend!

You can make it work by making the data use the “RooVectorDataStore” internally, just call convertToVectorStore() before the fit:

data->convertToVectorStore();
RooFitResult * result=pdf.fitTo(*data, Save(true), BatchMode("cpu"));

Note that for ROOT 6.28.00 that was just released, the BatchMode got improved yet again and you don’t need to do this. I would strongly suggest you to use this new release because many things got fixed and were made faster. Also, I would be very happy to get some feedback on the BatchMode for the new release, because maybe for ROOT 6.30 we’ll make it the default. Also I’m curious, what is your DIY PDF looking like, and do you get a performance improvement with the BatchMode?

Cheers,
Jonas

Hi @jonas ,

Thanks for your quick reply!

And sorry for my late reply, I was trying to download and compile ROOT v6.28 these two days, but I have encountered many issues, therefore I can’t give test result under v6.28 now.

After I added “data->convertToVectorStore()” in my fitting under ROOT v6.26, I still got the same error. I’m worried about whether there are some problems with the constructure of my DIY PDF. For your convenience, I rewrote a simplified pdf, but the structure is the same as my PDF. The detailed code is attached in the attachment, pealse check it. You just need to “make” and test toy MC in the fold “toyMC_test”.

Thanks again,
Jianyu
test_RooPdf.zip (725.5 KB)

Hi, you’re sure that you did data->convertToVectorStore() and not data->convertToTreeStore()? Because in your code I see the convertToTreeStore() commented out, but not convertToVectorStore()

If I run your scripts as-is with ROOT 6.26, I get indeed the same error, but when I add this line before the fit it works:

data->convertToVectorStore();

I mean probably this is what you did, but I just wanted to double-check to make sure there was no confusion between TreeStore and VectorStore.

Cheers,
Jonas

Hi @jonas ,

Sorry for the naive mistake. I wrote the wrong code due to the automatic completion function of vim. The fit works fine after I add the correct line data->convertToVectorStore();. As a test, I used my PDF(a full angular distribution amplitude) to fit toy data(3.2e6 events) with a normalization PHSP toy MC sample(1.5e8 events) and compared the fitting time of the following three cases:

1. Nominal fit:
RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), Timer(true));
Cost time = 1 hour and 36 minutes

2. BatchMod fit:
RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), BatchMode(“CPU”), Timer(true));
Cost time = 1 hour and 40 minutes

2. Multi-core fit:
RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), NumCPU(70), Timer(true));
Cost time = 4 minutes

It seems that BatchMode(“CPU”) not works here. I also compare the results of RooGaussian with 3.2e7 toy data sample. The fitting cost time of Nominal fit is 1:30 minute, while the cost time of BatchMod fit is 24 seconds. Therefore the BatchMode(“CPU”) works well for RooGaussian.

Do you know why?

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