Repository navigation
MadSpin: -O2 for productions with >= 4 decaying particles - #238
Merged
Merged
Conversation
MadSpin compiled its standalone trees with an empty GLOBAL_FLAG, i.e. -O0: misc.compile never sets it. set_global_flag() writes GLOBAL_FLAG into the tree's Source/make_opts, which every makefile of the tree includes, and, since `output standalone` has already built Source/DHELAS and Source/MODEL at -O0 and make does not track flags, cleans those so they are rebuilt. -O2 is only used when a production process has at least MS_GLOBAL_FLAG_MIN_DECAYS (4) particles to decay: it costs ~2 s of compilation per run and only pays off when the matrix elements dominate. Measured on the MG7 paper's MadSpin timing setup (10^4 events, nb_core 6, sequential unweighting, mg7 backend): t t~ t t~ x1.05-1.07 and W+W-W+W- x1.25, but WH, t t~, ZZ and t t~ Z 3-7% slower. update_make_opts_full now returns whether it changed the file.
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.
Summary
MadSpin compiles its standalone matrix-element trees through
misc.compile, which never setsGLOBAL_FLAG, so they were always built at-O0(MG5aMC does the same). This PR builds them at-O2, but only when a production process has at least 4 particles that MadSpin decays, because that is the only case where it pays off in a full MadSpin run.MadSpin/decay.pyMS_GLOBAL_FLAG = '-O2',MS_GLOBAL_FLAG_MIN_DECAYS = 4.set_global_flag(tree)writesGLOBAL_FLAGinto the tree'sSource/make_opts, which every makefile of the tree includes (DHELAS, MODEL, the P directories,MadSpin/src/makefile_*).output standalonehas already builtSource/DHELASandSource/MODELat-O0and make does not track flags, so when the flag changes those objects and libraries are removed and rebuilt.decay_all_events.nb_decaying_in_production()counts the decayed final-state particles of the production processes. Decays inside a chain (the W oft > w+ b, w+ > ...) do not count. It readsall_ME(madspin_v1) or theproductionentries ofall_me(onshell/density modes).use_global_flag()is called by both build paths:compile_fortrananddecay_all_events_onshell.compile.madgraph/interface/common_run_interface.py:update_make_opts_fullnow returns whether it changed the file. No existing caller uses the return value.Why the threshold
Full MadSpin runs on the rows of the MG7 paper's
tab_madspin_walltimes.spinmode madspin,unweighting sequential,nb_core 6, mg7 decay backend, fixed seed.-O0[s]-O2[s]-O2adds about 2 s of compilation to every run.g g > t t~ g g,GET_DENSITYgoes from 476 µs per call at-O0to 174 µs at-O2.Validation
tests/test_manager.py -p tests/unit_tests/madspin '.*': Ran 634 tests, OK. 6 are new:TestSetGlobalFlag: the flag is written, stale objects are removed, and nothing is removed once the flag is already set.TestGlobalFlagGate: the decay count from both data layouts, and the flag applied only from 4 decays on.p p > t t~(2 decays):make_optskeeps noGLOBAL_FLAG.p p > t t~ t t~(4 decays): built withGLOBAL_FLAG=-O2.-O2run, the objects MadSpin built (aloha_functions.o,P1_gg_ttx/matrix.o) are byte-identical to a manual-O2compile and differ from-O0.-O2against-O0changes the density matrix only at rounding level, ≤5.4e-15 relative.Notes
madspin_v1case with 4 or more decays end to end; it takes hours. That path goes through the same helper, which the unit tests cover.GET_ALL_INTERwas also measured in this work and dropped. It speeds up the Fortran colour part by 2-10x, but makes no difference on these MadSpin rows because their colour matrices are small.