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

General numeric type support #97

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Conversation

graeme-a-stewart
Copy link
Member

@graeme-a-stewart graeme-a-stewart commented Nov 26, 2024

Support is added for general numerical types in this PR. EEjet and PseudoJet become parametrised on T <: Real. ClusterSequence stays parametrised on J <: FourMomentum, but is it really important to pass the parametrised jet collection into the constructor otherwise performance greatly suffers! (i.e., ClusterSequence{EEjet{Float64}} not ClusterSequence{EEjet}. To support this the eltype method is defined for both jet types to return the internal type used.

The instrumented-jetreco.jl script gets a new --type option that allows a numeric type to be passed for the reconstruction. Added a quick benchmark.sh script to run all three main use cases.

Current performance tests shows that we are losing a bit in the $pp$ N2Tiled reconstruction, so this needs to be fixed before merging. Performance for Durham $e^+e^-$ and $pp$ N2Plain are the same as the current v0.4.3 release.

Testing on M2pro gives

This branch:

~/.julia/dev/JetReconstruction/examples/ [general-numeric-types*] ./benchmark.sh 
pp 14TeV Tiled
Lowest time per event 189.185 μs
pp 14 TeV Plain
Lowest time per event 678.68667 μs
ee H Durham
Lowest time per event 28.38375 μs

v0.4.3:

~/.julia/dev/JetReconstruction/examples/ [general-numeric-types] ~/tmp/benchmark.sh
pp 14TeV Tiled
Lowest time per event 176.06666 μs
pp 14 TeV Plain
Lowest time per event 677.14125 μs
ee H Durham
Lowest time per event 27.92792 μs

Closes #91


To do:

  • Convert EEjet to T <: Real
  • Convert PseudoJet to T <: Real
  • Convert TiledJet to T <: Real
  • Add option to examples to switch types for the internal representation
    • instrumented_jetreco.jl
    • jetreco.jl
  • Ensure performance is maintained in Float64 case
    • pp Tiled
    • pp Plain
    • ee
  • Add unit tests for Float32 reconstruction

Allowing for different Float values, as well as more exotic types, if needed
Allowing for different Float values, as well as more exotic types,
if needed.
Ensure that types are stable for EEReco, meaning that they are
EEjet{T} for a specific T, not just generic EEjet
Allow instrumented-jetreco to have a type argument that makes the particle
collection have that specific type, allowing for switches to different Floats

N.B, Currently Float32 is slower than Float64
It is very important to pass the fully typed PseudoJet{T} around, not a generic PseudoJet
Returns the parametrised element type
Also support type switching constructor for PseudoJet
@graeme-a-stewart graeme-a-stewart marked this pull request as draft November 26, 2024 10:52
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.

Project coverage is 71.30%. Comparing base (eab62d1) to head (9f96393).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/EEjet.jl 83.33% 1 Missing ⚠️
src/Pseudojet.jl 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #97      +/-   ##
==========================================
+ Coverage   70.18%   71.30%   +1.11%     
==========================================
  Files          17       17              
  Lines        1164     1178      +14     
==========================================
+ Hits          817      840      +23     
+ Misses        347      338       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@graeme-a-stewart
Copy link
Member Author

For completeness, here are the benchmarks on my x86 Ryzen 7 5700G:

pc-sft-fa-0a :: dev/JetReconstruction/examples ‹general-numeric-types› » ./benchmark.sh
pp 14TeV Tiled
Lowest time per event 199.00421999999998 μs
pp 14 TeV Plain
Lowest time per event 506.19272000000007 μs
ee H Durham
Lowest time per event 31.21525 μs
pc-sft-fa-0a :: dev/JetReconstruction/examples ‹main› » ~/tmp/benchmark.sh
pp 14TeV Tiled
Lowest time per event 177.75058 μs
pp 14 TeV Plain
Lowest time per event 502.63006 μs
ee H Durham
Lowest time per event 31.40393 μs

So, again, the significant performance loss is pp tiled (and a small loss for pp plain).

src/Pseudojet.jl Outdated Show resolved Hide resolved
src/EEAlgorithm.jl Outdated Show resolved Hide resolved
At the full constructor level the type parameter really should be known,
the use case for the non-explicit parametrised version is weak, so
it is removed. (This was also causing a docstring warning.)
The particle type is know in the function signature of the underlying reconstruction
We explicitly use Float64 here, because this is deliberately the simple case.
# If we don't have an algorithm we default to PseudoJet
if !isnothing(args[:algorithm])
JetReconstruction.is_ee(args[:algorithm])
jet_type = EEjet{Float64}
Copy link
Collaborator

Choose a reason for hiding this comment

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

just a question: why is it explicitly Float64 here, shouldn't this be smth like eval(args[:type]) for generality?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason is that I wanted jetreco.jl to be the simplest and most explicit example possible. instrumented-jetreco.jl is the one with all the bells and whistles.

It might be useful to add a note though, that any subtype of Real is allowed.

else
jet_type = PseudoJet
jet_type = PseudoJet{Float64}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question :)

Copy link
Member Author

Choose a reason for hiding this comment

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

same answer 🤣

Numerical type can be passed as a parameter to the test struct
This is passed down to read the events in the required precision.
Add some tests for e+e- and pp in Float32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make package work on more general numerical types
3 participants