Skip to content

[RF] RooFFTConvPdf: cache norm. val to avoid bookkeeping during scan#21615

Merged
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:roofftconvpdf
Mar 16, 2026
Merged

[RF] RooFFTConvPdf: cache norm. val to avoid bookkeeping during scan#21615
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:roofftconvpdf

Conversation

@guitargeek
Copy link
Copy Markdown
Contributor

RooFFTConvPdf::scanPdf() repeatedly evaluates the component pdfs with pdf.getVal(normSet) while filling the FFT input buffers. For large scans this incurs unnecessary overhead from RooAbsPdf::getValV()'s normalization-set tracking and cache management, even though the normalization set is fixed for a given FFTCacheElem.

This change caches the normalization integrals for both component pdf clones (normVal1, normVal2) when the FFTCacheElem is constructed. During scanning, the pdfs are then evaluated without passing a normalization set and are normalized manually using the cached integral values.

To exactly reproduce RooAbsPdf::getValV() behaviour (including NaN-packing semantics), the RooAbsPdf::normalizeWithNaNPacking(rawVal, normVal) helper function was moved to an internal helper namespace.

This reduces evaluation overhead in FFT convolutions while preserving bitwise-equivalent normalization behaviour.

Spinoff from #21343 to reduce the size of the "internal" computation graphs a bit that are not visible to the RooFit::Evaluator.

`RooFFTConvPdf::scanPdf()` repeatedly evaluates the component pdfs with
`pdf.getVal(normSet)` while filling the FFT input buffers. For large
scans this incurs unnecessary overhead from `RooAbsPdf::getValV()`'s
normalization-set tracking and cache management, even though the
normalization set is fixed for a given FFTCacheElem.

This change caches the normalization integrals for both component pdf
clones (normVal1, normVal2) when the FFTCacheElem is constructed. During
scanning, the pdfs are then evaluated without passing a normalization
set and are normalized manually using the cached integral values.

To exactly reproduce `RooAbsPdf::getValV()` behaviour (including
NaN-packing semantics), the `RooAbsPdf::normalizeWithNaNPacking(rawVal,
normVal)` helper function was moved to an internal helper namespace.

This reduces evaluation overhead in FFT convolutions while preserving
bitwise-equivalent normalization behaviour.
@guitargeek guitargeek self-assigned this Mar 16, 2026
@guitargeek guitargeek requested a review from bellenot as a code owner March 16, 2026 12:41
@github-actions
Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 4h 45m 56s ⏱️
 3 810 tests  3 809 ✅ 1 💤 0 ❌
75 628 runs  75 619 ✅ 9 💤 0 ❌

Results for commit af10789.

Copy link
Copy Markdown
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks Jonas for this improvement!

@guitargeek guitargeek merged commit 3dcd9c7 into root-project:master Mar 16, 2026
30 of 33 checks passed
@guitargeek guitargeek deleted the roofftconvpdf branch March 16, 2026 16:29
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.

2 participants