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

Update RooFit ATLAS benchmarks #287

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ CMakeLists.txt.user

__pycache__/
*.py[cod]

build/
8 changes: 5 additions & 3 deletions root/roofit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Can only be enabled is you have the ATLAS RooFit extensions installed and you
# set unlimited stack size with `ulimit -S -s unlimited`:
# add_subdirectory(atlas-benchmarks)
if(ROOFIT_ATLAS_BENCHMARKS)
# Can only be enabled is you have the ATLAS RooFit extensions installed and you
# set unlimited stack size with `ulimit -S -s unlimited`:
add_subdirectory(atlas-benchmarks)
endif()

add_subdirectory(histfactory)
add_subdirectory(roofit)
32 changes: 16 additions & 16 deletions root/roofit/atlas-benchmarks/roofitAtlasHiggsBenchmark.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BenchmarkData &bmdata()

static void benchCreateNLL(benchmark::State &state)
{
const std::string batchMode = state.range(0) == 2 ? "codegen" : (state.range(0) == 1 ? "cpu" : "off");
const std::string evalBackend = state.range(0) == 2 ? "codegen" : (state.range(0) == 1 ? "cpu" : "legacy");
auto &nllPtr =
state.range(0) == 2 ? bmdata().codegenNll : (state.range(0) == 1 ? bmdata().batchedNll : bmdata().nll);

Expand All @@ -61,8 +61,8 @@ static void benchCreateNLL(benchmark::State &state)
bmdata().data = bmdata().ws->data("toyData");

for (auto _ : state) {
nllPtr = std::unique_ptr<RooAbsReal>{bmdata().pdf->createNLL(*bmdata().data, GlobalObservables(*globObs),
Offset(true), Optimize(2), BatchMode(batchMode))};
nllPtr = std::unique_ptr<RooAbsReal>{bmdata().pdf->createNLL(
*bmdata().data, GlobalObservables(*globObs), Offset(true), Optimize(2), EvalBackend(evalBackend))};
}

double val = nllPtr->getVal();
Expand Down Expand Up @@ -97,7 +97,7 @@ static void benchEvaluateNLL(benchmark::State &state)
static void benchMinimizeNLL(benchmark::State &state)
{
auto &nllPtr =
state.range(1) == 2 ? bmdata().codegenNll : (state.range(1) == 1 ? bmdata().batchedNll : bmdata().nll);
state.range(0) == 2 ? bmdata().codegenNll : (state.range(0) == 1 ? bmdata().batchedNll : bmdata().nll);

RooArgSet parameters;
nllPtr->getParameters(nullptr, parameters);
Expand All @@ -115,23 +115,23 @@ static void benchMinimizeNLL(benchmark::State &state)
parameters.assign(initialParams);
}

BENCHMARK(benchCreateNLL)->Name("createNLL")->Args({0})->Unit(kSecond)->Iterations(1);
BENCHMARK(benchCreateNLL)->Name("createNLL_BatchMode")->Args({1})->Unit(kSecond)->Iterations(1);
// BENCHMARK(benchCreateNLL)->Name("createNLL")->Args({0})->Unit(kSecond)->Iterations(1);
// BENCHMARK(benchCreateNLL)->Name("createNLL_CPU")->Args({1})->Unit(kSecond)->Iterations(1);
BENCHMARK(benchCreateNLL)->Name("createNLL_CodeGenAD")->Args({2})->Unit(kSecond)->Iterations(1);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL")->Args({1, 0})->Unit(kMillisecond);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_BatchMode")->Args({1, 1})->Unit(kMillisecond);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CodeGenAD")->Args({1, 2})->Unit(kMillisecond);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_SingleKick")->Args({0, 0})->Unit(kMillisecond);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_BatchMode_SingleKick")->Args({0, 1})->Unit(kMillisecond);
BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CodeGenAD_SingleKick")->Args({0, 2})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL")->Args({1, 0})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CPU")->Args({1, 1})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CodeGenAD")->Args({1, 2})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_SingleKick")->Args({0, 0})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CPU_SingleKick")->Args({0, 1})->Unit(kMillisecond);
// BENCHMARK(benchEvaluateNLL)->Name("evaluateNLL_CodeGenAD_SingleKick")->Args({0, 2})->Unit(kMillisecond);
// BENCHMARK(benchMinimizeNLL)->Name("minimizeNLL")->Args({0})->Unit(kSecond)->Iterations(1);
// BENCHMARK(benchMinimizeNLL)->Name("minimizeNLL_BatchMode")->Args({1})->Unit(kSecond)->Iterations(1);
// BENCHMARK(benchMinimizeNLL)->Name("minimizeNLL_CPU")->Args({1})->Unit(kSecond)->Iterations(1);
BENCHMARK(benchMinimizeNLL)->Name("minimizeNLL_CodeGenAD")->Args({2})->Unit(kSecond)->Iterations(1);

// The channels 221 to 231 inclusive of the full combination workspace are
// unfortunately corrupt. They contain RooAddPdfs that are affected by the
// notorious server-proxy-desyncing that can happen if the RooFit frameworks do
// the wrong thing. Th new the BatchMode uses the client-server links to build
// the wrong thing. Th new the EvalBackend uses the client-server links to build
// the computation graph for evaluation, and the old RooFit uses the proxies
// (the client-server links are only used to the dirty flag propagation in the
// old RooFit). As the servers and proxies are out of sync in some channels, we
Expand Down Expand Up @@ -213,10 +213,10 @@ int main(int argc, char **argv)
bmdata().ws = bmdata().tfile->Get<RooWorkspace>(workspaceNames[iWorkspace].c_str());
auto mc = static_cast<RooStats::ModelConfig *>(bmdata().ws->obj("ModelConfig"));

// bmdata().pdf = mc->GetPdf();
bmdata().pdf = mc->GetPdf();
// Use this instead to create a new simultaneous pdf that only includes a
// subset of the channels:
bmdata().pdf = createSimPdfSubset(*bmdata().ws, "simPdfSubset", 0, 1);
// bmdata().pdf = createSimPdfSubset(*bmdata().ws, "simPdfSubset", 0, 5);

// Mask broken channels of the full Higgs combination workspace.
if (iWorkspace == 2) {
Expand Down
Loading