[v640][RF] Backport RooFit bugfix and performance improvement#22030
Merged
guitargeek merged 4 commits intoroot-project:v6-40-00-patchesfrom Apr 24, 2026
Merged
[v640][RF] Backport RooFit bugfix and performance improvement#22030guitargeek merged 4 commits intoroot-project:v6-40-00-patchesfrom
guitargeek merged 4 commits intoroot-project:v6-40-00-patchesfrom
Conversation
Use RooDataHist interfaces that take index input arguments, which is safer because they don't rely on the cached last index in the RooDataHist. Addresses one bullet point in root-project#6557: "Correct interface of RooAbsData and derived classes to use e.g. std::size_t for indexing events. int doesn't make sense." As a followup, we could consider to deprecate the interfaces that use the last cached "current" index. (cherry picked from commit 5754e62)
For models with a single POI and no nuisance parameters, `BayesianCalculator::GetInterval()` used `ComputeIntervalUsingRooFit()`, which built the CDF via `RooAbsPdf::createCdf()` On a computation graph that contains the NLL. The `createCdf()` relies on cloning the integrand subtree and substituting the POI with a prime variable, but the POI dependency inside the NLL compiled for the new vectorizing CPU evaluation backend is not propagated through the clone. The CDF and therefore the calculated interval is then wrong. Users worked around this by calling `SetScanOfPosterior(N)` instead (see root-project#17567). Fortunately, there was already a code path for the n-dimensional parameter case present that doesn't use `createCdf()`, but the ROOT Math integrator classes directly. This commit commit suggests to also do this for the 1D POI-only case to avoid the issue with using the compiled NLL in `createCdf()` and simplifying the code by only providing one code path for interval caluclation with integration. Add a gtest regression test that reproduces the issue scenario and checks the default-path upper limit matches the explicit scan reference. Closes root-project#17567. (cherry picked from commit 1eb9fb6)
When a likelihood is evaluated with the new `"cpu"` backend, the `RooFit::Evaluator` fully manages dependency tracking and re-evaluation of the computation graph. In this case, RooFit’s built-in dirty flag propagation in RooAbsArg becomes redundant and introduces significant overhead for large models. This patch disables regular dirty state propagation for all non-fundamental nodes in the Evaluator's computation graph by setting their OperMode to `RooAbsArg::ADirty`. Fundamental nodes (e.g. RooRealVar, RooCategory) are excluded because they are often shared with other computation graphs outside the Evaluator (usually the original pdf in the RooWorkspace). To set the OperMode of *all* RooAbsArgs to `ADirty` during minimization, while avoiding side effects outside the minimization scope, the dirty flag propagation for the fundamental nodes is only disabled temporarily in the RooMinimizer. This commit drastically speeds up fits with AD in particular (up to 2 x for large models), because with fast gradients, the dirty flag propagation that determines which part of the compute graph needs to be recomputed becomes the bottleneck. It was also redundant with a faster "dirty state" bookkeeping mechanism in the `RooFit::Evaluator` class itself. At this point, there is no performance regression anymore when disabling recursive dirty flag propagation for all evaluated nodes, so the old comment in the code about test 14 in stressRooFit being slow doesn't apply anymore. (cherry picked from commit fa97774)
Several places needed to record a set of operation-mode changes and restore them later as a group, so it's better to have the ChangeOperModeRAII act on groups of RooAbsArg to not have to create one RAII object per arg. (cherry picked from commit d42a27c)
Test Results 22 files 22 suites 3d 12h 4m 8s ⏱️ For more details on these failures, see this check. Results for commit 8837e4e. |
98a75ad
into
root-project:v6-40-00-patches
27 of 30 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport RooFit bugfix and performance improvement to the 6.40 release branch.