Postprocessing linking#31
Draft
oliviermattelaer wants to merge 46 commits into
Draft
Conversation
… claude/vigorous-neumann-313de8
… point for systematics (not fully working)
- write proc_card_mg5.dat at output and embed it as <MG5ProcCard> in the LHE
banner (with <slha>/<MG7RunCard>/<init>) so MadSpin/reweight can read the
model+process from mg7 events
- fix the LHE <init> beam PDGs: use 2212 for hadronic beams (incoming is the
parton, not the beam)
- scope the TOML run_card editor overrides (define_paths/init_run/do_set) to
MG7Selector instead of globally patching AskforEditCard; the global patch
leaked into MadSpin's spawned madevent and broke its run_card handling
('dict' object has no attribute 'blocks')
- map the legacy 'nevents' key to [generation].events on RunCardMG7
- auto-set output_format=lhe when a post-processing tool (shower/detector/
madspin/reweight/analysis) is enabled in the merged question
- pass --lhapdf_config to systematics so it can link the python lhapdf module
- write post-processing tracebacks to a <tool>_crash.log file and print its
path; raise a clear error when the per-event <mgrwt> reweighting info is
missing (mg7 does not write it yet)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- add a Pythia8 driver (_run_pythia8) that showers the mg7 LHE through the MG5aMC_PY8 interface and writes a HepMC file next to the events, mirroring the core of MadEventCmd.do_pythia8 (single sub-run, HepMC output) - veto the MLM/CKKW merging sentinels and set Main:numberOfEvents to the event count (fixed-order LO: no merging), avoiding the -1 out-of-range crash - load mg5amc_py8_interface_path and heptools_install_dir in load_mg5_options - wire shower==Pythia8 into run_selected_tools; failures go through _report_failure (traceback written to Pythia8_shower_crash.log, path printed) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
At output time, ProcessExporterMG7 now writes process-tailored MA5 default cards (madanalysis5_parton/hadron_card_default.dat), mirroring the madevent exporter. At launch time, the mg7 driver runs MA5 on the LHE (parton level) and, when Pythia8 ran, on the HepMC (hadron/reco level). To make MA5 recognise the process legs, add VirtualExporter.expand_merged_particle_legs(), which expands the merged-flavor beam PDG codes (81/82/83 and conjugates) to concrete signed flavour PDGs via the model's merged_particles map. This is also wired into the fortran create_default_madanalysis5_cards path, fixing the same MultiParts failure there (the merged codes never matched a multiparticle definition). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The mg7 (standard) launcher previously re-implemented each post-processing tool standalone (single-core Pythia8, direct MadSpin/MA5 calls). Replace all of that with MG7RunCmd, a thin MadEventCmd adapter pointed at the mg7 output, and drive the real madevent tool commands (reweight, decay_events, shower, delphes, madanalysis5_parton/hadron, rivet) via exec_cmd. The headline win: Pythia8 is now showered in parallel over the cluster/multicore backend, identical to a madevent run (LHE split into per-core jobs, HepMC merged) -- validated with 200 events split into 2 x 100. MadSpin, MA5 parton and MA5 hadron (reco) also run through their standard drivers, with output landing in the normal HTML/<run> layout. MG7RunCmd reconciles the mg7 layout with what MadEventCmd assumes: - configure_directory: no Fortran Source to compile / LHAPDF to link; - set_run_name: load the run card from run_card.toml (RunCardMG7) and take the banner straight from the mg7 LHE; - load_results_db: build a fresh results db without recreate() (the mg7 banner has no <MGGenerationInfo>); the run is registered explicitly; - do_set/do_treatcards: skip the Fortran-compiler / .inc-file machinery; - _prepare_run_dir: expose unweighted_events.lhe.gz for the tools. Supporting changes: - export_cpp (ProcessExporterMG7.finalize): write SubProcesses/proc_characteristics (ninitial/nexternal/initial-PDGs/ISR-FSR) and Cards/me5_configuration.txt so get_characteristics()/set_configuration() work on the mg7 directory. - banner (RunCardMG7): add a run_tag param and legacy-compat keys the tools read (ktdurham/ptlund/xqcut/maxjetflavor/sys_matchscale/dparameter/lhaid/iseed/ python_seed), all taking their "no MLM/CKKW merging" values. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
run_selected_tools issued each tool command with an explicit "run_01" run name, so after decay_events (which repoints self.run_name to the new "<run>_decayed_i" run, as MadEventCmd.do_decay_events does) the shower and analyses still acted on the original, undecayed run. Drop the explicit run name so the commands follow cmd.run_name, exactly like MadEventCmd.do_launch: reweight runs on the generated events, then MadSpin repoints the run, and the shower / MA5 / Rivet that follow act on the decayed events. MG7RunCmd.set_run_name now resolves the banner+LHE from the run's own Events/<run> directory (falling back to the original mg7 LHE), so the decayed run is handled correctly. Verified: with MadSpin+Pythia8, the shower HepMC now lands in Events/run_01_decayed_1/ and showers the decayed events. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The standalone mg7 launcher never configured Python logging, so the reused
madevent tool drivers narrated everything through logger.info / update_status
("Running Pythia8 [arXiv:...]", "Splitting .lhe event file...", the live
Idle/Running/Completed job counters, "Running MadSpin", ...) into loggers with
no handler -- all of it silently dropped.
_setup_tool_logging() attaches a colored INFO console handler to the
'madgraph'/'madevent'/'cmdprint' loggers (reusing coloring_logging.ColorFormatter),
so those existing messages now appear. It is called from run_selected_tools, so
only the post-processing phase is affected (propagate=False keeps it from
touching the generation-phase output).
run_selected_tools also prints a one-line summary of the selected tools and a
clear banner + timing around each step (start / "-> done (Ns)" / failure).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
run_selected_tools invoked madanalysis5_hadron whenever analysis==MadAnalysis5, so with the shower OFF it ran and immediately reported "No hadron level input found ... Skipping". Gate it on the shower being on (shower != OFF), mirroring madevent's own card condition (analysis == 'MadAnalysis5' and shower != 'OFF'). The summary line of selected tools is gated the same way. The card-editor side already hides madanalysis5_hadron_card.dat when the shower is off (inherited switch_cards/active_cards gating), verified in the live question; this only fixes the run side. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The new mg7 post-processing jobs (time-of-flight/Pythia8/Rivet/MadSpin) restored the granular per-tool caches (restore_heptools_lhapdf/_pythia8/ _contur, keys lhapdf-<os>/pythia8-<os>/contur-<os>). Those per-tool caches are evicted by GitHub's cache limits, so the restore was a silent miss: the tool paths got configured but the binaries were absent, the tests self-skipped, and test_manager.py turns a skip into exit 1 -> red jobs (while the madevent jobs stayed green because they restore the combined heptools-<os> cache). Point every mg7 job at restore_heptools (the combined cache the madevent jobs use, which bundles LHAPDF+NNPDF23, Pythia8 and Rivet/contur) and make restore_heptools fail-on-cache-miss so a genuinely missing heptools-<os> cache crashes loudly (naming the key) instead of degrading into opaque skips. Drop the dedicated Delphes job (Delphes is not in the cache; the test_delphes_mg7 method stays and self-skips where Delphes is absent). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The post-processing log lives in a tmp dir CI does not upload, so a failing mg7 generate_events only reported an opaque rc=1. Dump the last 120 lines of the log into the test failure so the real crash is visible in CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Rivet test used p p > e+ e- and the MadSpin test used p p > w+; both hit mg7/madspace generation limits unrelated to the post-processing chaining: - p p > e+ e- crashes the madspace LHECompleter (unordered_map::at) when writing the LHE; - p p > w+ is 2->1 and madspace requires >=2 outgoing particles. Switch both to the 2->2 p p > w+ z (already proven by the tof/Pythia8 tests to generate and write LHE cleanly) so the tests exercise the Rivet/MadSpin command interface chaining rather than these generator gaps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Generation now succeeds for the Rivet/MadSpin tests but the tools produce no output and run_selected_tools swallows tool failures (rc stays 0). Echo the generate_events log tail and any per-tool *_crash.log to stderr so the silent Rivet/MadSpin failure is visible in CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
With the correct heptools cache the tof and Pythia8 mg7 post-processing tests pass, but Rivet and MadSpin hit genuine mg7 gaps (the command interface drives the chain correctly; the underlying tool support is not there yet): - Rivet: the mg7 driver logs "Skipping Rivet for now, passing it to postprocessor" and writes no rivet_result.yoda. - MadSpin: aborts with "Invalid proc_card information in the file (no generate line)" -- the mg7 LHE banner does not yet carry the proc_card in the form MadSpin do_import expects, so no decayed events are produced. Mark both @unittest.expectedFailure (mirroring the existing test_madspin_mixed_flavor_decay_log_summary_mg7) so CI is green while the gaps stay tracked and flip to an unexpected success once mg7 wires up each tool. Also revert the helper diagnostic to only dump the generate_events log on a hard crash (rc != 0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…mplete The MadSpin chaining test failed with "Invalid proc_card information in the file (no generate line)". Root cause: _run_mg7_postproc built the mg7 output with mg.exec_cmd(), which does not record the interface history. The exporter dumps that history into Cards/proc_card_mg5.dat (and thus the LHE banner <MG5ProcCard>), so the model/generate/output lines were missing and MadSpin (which reads the generate line from the banner) aborted. Driving the output through run_cmd -- as a real user does via bin/mg5_aMC -- records the history and writes a complete proc_card, so MadSpin gets its generate line. Also surface any non-systematics per-tool *_crash.log from run_selected_tools (a tool that fails without failing generate_events) and drop the MadSpin @expectedfailure now that the banner is complete. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Development-phase policy: CI should crash to remind us what still needs to be
implemented before release, rather than masking gaps as expected failures.
- test_rivet_from_file_mg7: mg7 Rivet driver not wired up ("Skipping Rivet for
now, passing it to postprocessor") -> now red.
- test_madspin_mixed_flavor_decay_log_summary_mg7: mg7 + MadSpin density
summary not wired up -> now red; give its job restore_heptools so the red
reflects the real gap rather than a missing NNPDF23 PDF.
(The mg7 MadSpin decay chaining, test_w_production_with_ms_decay_mg7, already
passes after the proc_card banner fix.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
So the real reason the mg7 + MadSpin density-summary test fails is visible in CI output instead of only which assertion tripped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The mg7 run_card is TOML (generation.events, default 100000). The launch card
editor did not map the madevent legacy name nevents to it, so a madevent-style
launch script ("set nevents 500") was silently ignored and the run generated
the full 100k events -- test_madspin_mixed_flavor_decay_log_summary_mg7 then
decayed 100k events in ~166s, dangerously close to its 240s timeout.
MG7Selector.do_set now routes the legacy LO run_card names through
RunCardMG7._LO_SCALAR_MAP (nevents->generation.events, use_syst->..., etc.), so
madevent launch scripts edit the mg7 run_card.toml verbatim. This makes the
mixed-flavor MadSpin test generate the intended 500 events (fast, not flaky).
Also: refresh the now-stale KNOWN-FAILING wording (the test passes) and print
the mg7 log tail only on failure.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
do_rivet only prepares Events/<run>/run_rivet.sh and defers execution to the postprocessor (the rivet_card default has run_rivet_later = True, so with --no_default it logs "Skipping Rivet for now, passing it to postprocessor" and appends the run to cmd.postprocessing_dirs). MadEventCmd.do_launch runs that postprocessor at the end of a run; run_selected_tools never did, so mg7 wrote no rivet_result.yoda. Call cmd.postprocessing() after the shower (MG7RunCmd inherits it from MadEventCmd), which executes the deferred run_rivet.sh -> yoda and, when run_contur = True, Contur. Flip test_rivet_from_file_mg7 back to a real pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
_report_failure name had a / (Rivet/Contur) which put the crash log in a nonexistent subdir; renamed to Rivet-Contur. Temporarily dump the mg7_postproc.log tail and Events/**/rivet*.log to diagnose why no yoda. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Root cause of the empty Rivet run: the Pythia8 driver writes <tag>_pythia8_events.hepmc and only *schedules* the .gz compression via the deferred to_store list; the actual gzip to <tag>_pythia8_events.hepmc.gz happens in store_result(). MadEventCmd.do_launch calls store_result() right after the shower/detector/analysis tools, but run_selected_tools never did, so the HepMC stayed uncompressed while the deferred run_rivet.sh reads the .gz path (the pythia8_card default is HEPMCoutput:file = hepmc.gz). Rivet then aborted with "deduce_reader: file ...hepmc.gz does not exist". Call cmd.store_result() after the tool loop (mirroring do_launch) so the HepMC is gzipped before the Rivet/Contur postprocessor runs. Remove the temporary rivet diagnostics. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The merged (switch + card editing) launch question asked ask() without path_msg. path_msg is what Cmd.check_answer_in_input_file uses to enable its "elif path:" branch, so in a scripted run a bare card path was rejected with "This answer is not valid for current question. Keep it for next question and use here default: 0" and silently replaced by the default -- even though the question advertises "enter the path to a valid card or banner" and the interactive flow handles it (AskforEditCard.default -> copy_file -> detect_card_type). Regression from the question merge (b2075d3); the old ask_edit_cards question passes path_msg. Pass path_msg in both merged questions (madevent ask_run_configuration and the mg7 ask_edit_cards). test_generation_from_file_1 now copies run_card_matching.dat over run_card.dat as intended. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rface-e08b34 Claude/ci tests command interface e08b34
…ing) Drives matrix-element reweighting through the mg7 command interface: generate p p > t t~ with the mg7 output, select reweight=ON in the launch question and let run_selected_tools chain "reweight -from_cards" on the events, reweighting to a heavier top. Asserts every event carries the new rwgt_1 weight. The reweight module rebuilds the matrix element from the model/process stored in the LHE banner, so this also exercises the banner proc_card. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rface-e08b34 mg7 CI: add a reweighting acceptance test (mirrors test_mass_reweight…
…tput
For "define q = u d; generate u q > u q" the u d contribution came out twice
too large: export_mg7 decided whether the beam-swapped initial state belongs to
the process with
same_initial_multiparticle = self.incoming[0] == self.incoming[1]
i.e. by comparing the pdg of the *matrix-element* legs. With flavor merging both
initial legs carry the same merged pdg (81), so this was True even though leg 1
is fixed to u -- and the mixed u d flavor then got mirrored, adding a "d u > u d"
initial state that is not part of the process at all.
madevent gets this right (write_mirrorprocs) by using the *process definition*
per-beam multiparticle content. Factor that logic out as
Process.has_same_initial_multiparticle() and use it from both exporters, so they
cannot drift apart.
u q > u q -> (2,) vs (1,2): no flavor mirrored (was: u d mirrored -> x2)
q q > q q -> (1,2) vs (1,2): only the mixed flavor mirrored (unchanged)
Add an explicit mirroring check to test_madevent_merged_flavor_uq (on top of the
cross-section) and a fast output-level mg7 test covering both processes; the
latter fails on the old logic and needs no mg7 runtime.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The initial-state mirroring fix makes test_madevent_merged_flavor_uq_mg7 pass: the merged-flavor path reproduces the 4428 pb reference. It was not segfaulting as the docstring claimed -- it returned a cross-section that was too large, because the mixed u d initial flavor was mirrored even though leg 1 is a fixed u. Refresh the now-stale KNOWN-FAILING/segfault wording on the test and its CI job. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: initial-state mirroring of merged-flavor processes in the mg7 output
For "define q = u d; generate u q > u q" the u d contribution came out twice
too large: export_mg7 decided whether the beam-swapped initial state belongs to
the process with
same_initial_multiparticle = self.incoming[0] == self.incoming[1]
i.e. by comparing the pdg of the *matrix-element* legs. With flavor merging both
initial legs carry the same merged pdg (81), so this was True even though leg 1
is fixed to u -- and the mixed u d flavor then got mirrored, adding a "d u > u d"
initial state that is not part of the process at all.
madevent gets this right (write_mirrorprocs) by using the *process definition*
per-beam multiparticle content. Factor that logic out as
Process.has_same_initial_multiparticle() and use it from both exporters, so they
cannot drift apart.
u q > u q -> (2,) vs (1,2): no flavor mirrored (was: u d mirrored -> x2)
q q > q q -> (1,2) vs (1,2): only the mixed flavor mirrored (unchanged)
Add an explicit mirroring check to test_madevent_merged_flavor_uq (on top of the
cross-section) and a fast output-level mg7 test covering both processes; the
latter fails on the old logic and needs no mg7 runtime.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* mg7: merged-flavor u q > u q now lands on the physical cross-section
The initial-state mirroring fix makes test_madevent_merged_flavor_uq_mg7 pass:
the merged-flavor path reproduces the 4428 pb reference. It was not segfaulting
as the docstring claimed -- it returned a cross-section that was too large,
because the mixed u d initial flavor was mirrored even though leg 1 is a fixed u.
Refresh the now-stale KNOWN-FAILING/segfault wording on the test and its CI job.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
e+ e- > e+ e- came out twice too large in mg7 (81 pb instead of 40.3): get_initial_leg_signature compared |pdg|, so the e+ beam (-11) and the e- beam (+11) both reduced to (11,) and looked like the same multiparticle. The mixed e+ e- flavor was then mirrored -- but the beams are different particles, so the swapped initial state is not part of the process at all. Compare the *signed* flavor content instead (get_initial_flavor already returns signed pdgs; only the signature threw the sign away). madevent is unaffected: its flavor lists are unsigned, so its per-flavor guard (flv[0][0] != flv[0][1]) already suppressed the mirror for e+ e-; it now takes the same decision one step earlier. Verified: e+ e- / u q > u q / q q > q q all keep their madevent mirrorprocs.inc, and test_e_e_collision still reproduces 155.9 pb with run_card_ee.dat. mg7 e+ e- > e+ e- now gives 40.44 +- 0.42 pb (madevent: 40.3). test_e_e_collision_mg7: assert the mirroring explicitly on top of the cross-section, and pin it to the madevent value for the *same* run_card (40.3); the old 155.9 reference belongs to test_e_e_collision run_card_ee.dat and never applied here. Also cover e+ e- in the fast output-level mirroring test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l on) Re-launching an mg7 output turned every tool (pythia8/madspin/reweight/...) on instead of remembering the previous run. The merged launch question materialises every candidate tool card (copies the *_default.dat) so it can offer them for edition, and set_default_<tool> keys the switch default off card presence. madevent prunes the unselected cards afterwards (ask_run_configuration -> keep_cards on the selected cards), but the mg7 launcher had no such cleanup, so the materialised cards persisted and the next launch saw them all present -> every switch defaulted to ON. add prune_unselected_tool_cards() and call it from ask_edit_cards, using the questions own switch->card map. A re-launch now reflects the previous selection (e.g. select nothing -> all OFF; select pythia8 -> shower=Pythia8, rest OFF). Regression test test_relaunch_switch_defaults_mg7 drives the real question twice; it is output-level (no madspace runtime) and fails without the prune. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ude/ci-tests-command-interface-e08b34
…rface-e08b34 Claude/ci tests command interface e08b34
…rface-e08b34 fix CI test for mssm (updated ref value)
Open
* change value for go go
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.
This include the run_card refactoring (that needs to be merged first).
But modifies the question such that we can decide to run Pythia8/MA5/Delphes/MadSpin/...
reweighting is still linked to the old module (need to be replaced by MadTrex).
One still need to check that all linking are working (but claude tells me that i can not write valid lhef file locally from madspace ...)
Linkable tools status