Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GBRForest implementation added in RecoJets/JetProducers PileupJetIdAl… #15907

Merged
merged 4 commits into from Sep 28, 2016

Conversation

romeof
Copy link
Contributor

@romeof romeof commented Sep 19, 2016

GBRForest implementation has been added in the PileupJetIdAlgo class of the package RecoJets/JetProducers. This method is used to book the reader for the mva pileup jet id discriminator.

@slava77
Copy link
Contributor

slava77 commented Sep 19, 2016

@cmsbuild please test

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @romeof for CMSSW_8_1_X.

It involves the following packages:

RecoJets/JetProducers

@cvuosalo, @slava77, @davidlange6 can you please review it and eventually sign? Thanks.
@TaiSakuma, @jdolen, @ahinzmann, @rappoccio, @yslai, @nhanvtran, @gkasieczka, @schoef, @mariadalfonso this is something you requested to watch as well.
@slava77, @smuzaffar you are the release manager for this.

cms-bot commands are list here #13028

@ahinzmann
Copy link
Contributor

adding @lgray since he knows on the egamma GBR forst that we started from

@slava77
Copy link
Contributor

slava77 commented Sep 19, 2016

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 19, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/15274/console

@cmsbuild
Copy link
Contributor

}
tmpTMVAReader.AddSpectator( *it, variables_[ tmvaNames_[*it] ].first );
}
reco::details::loadTMVAWeights(&tmpTMVAReader, tmvaMethod_.c_str(), tmvaEtaWeights_.at(v).c_str() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to wrap this call in a std::unique_ptrTMVA::IMethod, otherwise it will leak memory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like in this line:

mIMethod = std::unique_ptr<TMVA::IMethod>( reco::details::loadTMVAWeights(mReader.get(), mMethod.c_str(), weightFile.c_str()) );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Lindsey,
I have implemented std::unique_ptrTMVA::IMethod syntax. I can see it from
https://github.com/romeof/cmssw/blob/PileupJetID_GBRForest/RecoJets/JetProducers/src/PileupJetIdAlgo.cc

Is this ok?

tmpTMVAReader.AddSpectator( *it, variables_[ tmvaNames_[*it] ].first );
}
reco::details::loadTMVAWeights(&tmpTMVAReader, tmvaMethod_.c_str(), tmvaEtaWeights_.at(v).c_str() );
etaReader_.push_back(std::unique_ptr<const GBRForest> ( new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(tmvaMethod_.c_str()) ) ) ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, here and below it would be a good idea (if possible) to move all of this into a cache that is common across threads like I do for the EGM code. This would reduce the number of times you have to read in the configuration file and thus improve CMSSW startup time in multithreaded mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgray could you point us to the relevant line in the EGM code that make this cache?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Lindsey,
do you have another example that may be more clear (to me)?
So far, I have used as a reference
https://github.com/cms-sw/cmssw/blob/CMSSW_7_6_X/RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring15NonTrig.cc#L151
but the new code seems more complicated (to me).
I would be glad if there is an implementation similar to what you mention in a file related to
https://github.com/cms-sw/cmssw/blob/CMSSW_7_6_X/RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring15NonTrig.cc#L151
If so, I can try to implement it.

Copy link
Contributor

@lgray lgray Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romeof: What is being done about using a global cache for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to study this syntax before. It is completely new to me and I am not a guru of programming :-( This may take sometime, not sure how much yet.

@lgray: For me to understand, could you comment further on what you mean by "This would reduce the number of times you have to read in the configuration file"? It assumes that there are different MVA configurations or it is for the same MVA configuration for different events? By "thread" do you mean a call to an MVA configuration? Thanks and sorry for naive questions.

Copy link
Contributor

@lgray lgray Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, since the producer that holds this algorithm is edm::stream it gets replicated for each thread (by thread I mean a thread on a processor) for CMSSW. Therefore if you run with four threads you have to build this algorithm four times. As it is implemented presently that means reading the MVA file and created four instances of the MVA which can blow up memory and start up time.

Using the global cache solves this problem permanently by only ever needing to build the MVAs once and sharing the MVAs among the threads.

@cmsbuild
Copy link
Contributor

@@ -37,6 +37,8 @@ class PileupJetIdAlgo {
float jec, const reco::Vertex *, const reco::VertexCollection &, double rho);

void set(const PileupJetIdentifier &);
std::unique_ptr<const GBRForest> getMVA(std::vector<std::string>, const std::string &);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first parameter should actually be a const reference (I forgot to say so in my original coment) to avoid copying overhead:

std::unique_ptr<const GBRForest> getMVA(const std::vector<std::string> &, const std::string &);

Same for getMVAvars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi cvuosalo,
thanks for your last suggestions, which I implemented in the code.
If it is ok now, I will try to get a look at the global cache implementation.

@cmsbuild
Copy link
Contributor

Pull request #15907 was updated. @cmsbuild, @cvuosalo, @slava77, @davidlange6 can you please check and sign again.

@cvuosalo
Copy link
Contributor

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 27, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/15406/console

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@cvuosalo
Copy link
Contributor

+1

For #15907 c280496

Changing from TMVA to GBRForest in PileupJetIdAlgo. There should be no change in monitored quantities.

The code changes are satisfactory, and Jenkins tests against baseline CMSSW_8_1_X_2016-09-27-1100 show no significant differences, as expected. A test of workflow 136.731_RunSinglePh2016B with 200 events against baseline CMSSW_8_1_X_2016-09-18-0000 also shows no significant differences. Memory usage shows no significant change, for either one or four threads:

One thread:
Baseline
Max VSIZ 3078.3 on evt 187 ; max RSS 2676.09 on evt 187
PR 
Max VSIZ 3065.55 on evt 187 ; max RSS 2610.54 on evt 109

Four threads:
Baseline
Max VSIZ 5257.57 on evt 194 ; max RSS 4390.66 on evt 143
PR
Max VSIZ 5335.07 on evt 191 ; max RSS 4264.74 on evt 143

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_8_1_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @slava77, @davidlange6, @smuzaffar

@ahinzmann
Copy link
Contributor

@cvuosalo Did you happen to also look at the processing time with multiple threads? It would be interesting to know if this change can indeed speed up MiniAOD production.

@lgray
Copy link
Contributor

lgray commented Sep 27, 2016

You'll need to look at the time spent before the first event. That's the
only place where reading in multiple MVAs will cause slow down.

On Tue, Sep 27, 2016 at 4:06 PM, ahinzmann notifications@github.com wrote:

@cvuosalo https://github.com/cvuosalo Did you happen to also look at
the processing time with multiple threads? It would be interesting to know
if this change can indeed speed up MiniAOD production.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#15907 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABBMOemGIopNzqdh4-GD4z54ld6T9OMtks5quYVFgaJpZM4KAl_3
.

@slava77
Copy link
Contributor

slava77 commented Sep 27, 2016

On 9/27/16 1:59 PM, Carl Vuosalo wrote:

+1

For #15907 #15907 c280496
c280496

Changing from TMVA to GBRForest in PileupJetIdAlgo. There should be no
change in monitored quantities.

The code changes are satisfactory, and Jenkins tests against baseline
CMSSW_8_1_X_2016-09-27-1100 show no significant differences, as
expected. A test of workflow 136.731_RunSinglePh2016B with 200 events
against baseline CMSSW_8_1_X_2016-09-18-0000 also shows no significant
differences.

Memory usage shows no significant change, for either one or
four threads:

IIRC, we should see a decrease by using GBR.
This is one of the reasons to switch to it.

both 1-thread and 4-thread tests show decrease in RSS: 1-thread down by 65MB
and 4-thread is down by 126MB.
igprof -mp may give a more convincing evidence.

|One thread: Baseline Max VSIZ 3078.3 on evt 187 ; max RSS 2676.09 on evt
187 PR Max VSIZ 3065.55 on evt 187 ; max RSS 2610.54 on evt 109 Four
threads: Baseline Max VSIZ 5257.57 on evt 194 ; max RSS 4390.66 on evt
143 PR Max VSIZ 5335.07 on evt 191 ; max RSS 4264.74 on evt 143 |


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#15907 (comment), or
mute the thread
https://github.com/notifications/unsubscribe-auth/AEdcbtYfdyiMOehk6d8g0TzR3rvYEG0Uks5quYOsgaJpZM4KAl_3.

@cvuosalo
Copy link
Contributor

@ahinzmann: My measurements don't show any performance improvement, but I'm not sure of the correct technique to specifically measure the improvement provided by using GBRForest.

@davidlange6
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 96be59a into cms-sw:CMSSW_8_1_X Sep 28, 2016
@cvuosalo
Copy link
Contributor

cvuosalo commented Oct 4, 2016

igprof memory profiling shows some improvement. Checking MEM_LIVE between baseline CMSSW_8_1_X_2016-09-18-0000 and this PR shows the MVA-reading memory usage for PileUpJetIdAlgo goes from rank 426 and 1.41% of total memory down to rank 1395 and 0.21%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants