Repository navigation
Make denom64 (FPTYPE=v) the default precision, add an mg7 precision check - #497
Conversation
…heck - madmatrix.mk, the mg7 run card (precision = "denom64"), the madevent floating_type and the MadtRex fallbacks now default to v (momenta and propagator denominators in FP64, amplitudes and colour in FP32). MadSpin's density libraries stay pinned to m. - The object directory is build.<BACKEND>_<FPTYPE>: two FPTYPEs of one backend can coexist, and changing [run] precision between two runs of one output no longer fails with "Cannot build for tag". - [run] precision_check (default 0.01): an mg7 run in a precision other than all64 also builds an FPTYPE=d library of each MadMatrix subprocess and, once the events are written, evaluates a sample of them in both precisions (UMAMI through ctypes, one process per FPTYPE). Mean, |M|^2-weighted and max relative deviation are logged and written to Events/<run>/precision_check.json; it warns above precision_check_threshold (1e-3) or on non-finite values. - Tests: unit tests for the defaults, the statistics and the event to library/flavour mapping; acceptance tests for a real run, the side by side builds, a precision change without make clean, and that the check reproduces the |M|^2 madspace computed in the run. Registered in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The C-parity scan in the cpu and simd SigmaKin.cc compared mirror helicity rows with an FP64 tolerance (1e-6 relative, 1e-12 of the largest |M|^2). With FP32 amplitudes (FPTYPE=f and the new default v) rounding noise exceeds it, the verdict latched "not C-symmetric" and the dedup was off: every helicity row evaluated, the mirrored half outside the hel-recycling table. On g g > t t~ g g (simd_128, 1 thread) v ran at 39.7 us/event against 23.4 for d. Under MGONGPU_FPTYPE_FLOAT the test now uses 1e-4 relative and 1e-6 of the largest |M|^2: v 13.0 us/event, f 12.2, |M|^2 identical to v with the helicity choice of the d build (v vs d max 8.7e-6). d and m keep the FP64 tolerance. u u~ > e+ e- is still refused the dedup under v; the gpu backend has no such scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C-parity tolerance fix for FP32 builds (6412ea6)Timing
End-to-end timing (M5 Pro, 18 cores, 100k events, default card)
Measured before the C-parity fix. The check costs the extra CI status at 6412ea684 pass, 1 fail.
🤖 Generated with Claude Code |
_check_stored_matrix_elements warned when the stored matrix elements differ from re-evaluated ones by more than 1e-6, sized for the old color32 default (about 1e-7 apart). With FP32 amplitudes (denom64, the new default, and all32) an MLM run's stored |M|^2 (rescaled to the event's alpha_s) and the re-evaluation differ by a few 1e-6 (1.76e-6 on CI), so test_madtrex_reweights_mlm_events_with_their_stored_matrix_elements saw a false warning. The default tolerance is now 1e-5 for f/v, 1e-6 otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The madspace examples load libmadmatrix_sm_P0_gg_ttxg_scalar_m.so after a plain 'make BACKEND=scalar', which builds FPTYPE=v now: the docs examples CI could not load the library. Same in the gridpack build example, whose FPTYPE has to match the card's precision (denom64 by default). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-stability-d62294 # Conflicts: # madgraph/iolibs/template_files/mg7/madtrex_driver.py # madgraph/iolibs/template_files/mg7/run_card.toml # madgraph/various/banner.py
|
Given you want to compile the Some other points: Claude also says: |
Addresses the review of #497: - [run] precision_check defaults to 0: the check compiles every subprocess a second time (all64); [run] validation (MadtRex) is the whole-sample alternative. - A GPU-only run never ran the check: the build loop reused 'fptype', and its last build is the scalar all64 one of the helicity choice, so the check saw 'd'. New test test_a_gpu_only_run_checks_its_own_precision. - Statistics: cross_section_bias is the signed mean of r = v/d - 1 (the unweighted events already follow |M|^2); the |M|^2-weighted number, which applied |M|^2 twice, is gone. Mean and max of |r| stay. - LHE output: the events are drawn at random from the whole file (reservoir sampling over the raw text, only the kept ones parsed), not the first N. - precision_check.json is strict JSON: non-finite values as strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks Frank, all fair points. Addressed in bb90202:
On the helicity choice in FP64: the bug behind it was the C-parity tolerance (6412ea6). The FP64 tolerance rejected FP32 noise, so On comparing against the auto CPU backend: on a GPU-only run the check uses 🤖 Generated with Claude Code |
madmatrix.mk: keep the FPTYPE=v default in main's shorter comment style. launch_plugin.py: take main's deletion (dead cudacpp code, #498). SigmaKin.cc (cpu, simd): the FP32 C-parity tolerance tests MADMATRIX_FPTYPE_FLOAT, as main renamed the MGONGPU macros; the old name no longer exists and would have silently restored the FP64 tolerance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- summarize: the mean |r| averages the same events as the cross-section bias (finite, non-zero reference); one non-finite event no longer makes it inf, it still shows in non_finite, above_threshold and the max. - compile_precision_check: count the missing libraries by me_path, as the main build loop does, for the PCH decision. - run_card.rst: name [run] validation instead of pointing to an entry that is not documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FP32 C-parity scan used 1e-4 relative and 1e-6 of the largest |M|^2. Measured on the scan points (simd_128), the mirror rows of C-symmetric processes differ by up to 7e-7 of the largest |M|^2 (g g > t t~ g g in f), 1.5x below that cut, so the relative test never acted and one harder point of a run could latch the dedup off. A genuine parity violation is O(1) on both measures (0.7 for u u~ > e+ e-, u u~ > z g g). Both FP32 tolerances are now 1e-5: a pair is flagged only above both, the cut against the largest |M|^2 ~15x above the roundoff. g g > t t~ g g and u u~ > t t~ g g (v, f) keep the dedup, u u~ > e+ e- is refused it (simd and scalar). FP64 builds keep 1e-6 / 1e-12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
v(denom64) is the default precision:madmatrix.mk(FPTYPE = v), the mg7 run card (precision = "denom64"), the madevent+madmatrixfloating_type, the MadtRex reweighting fallbacks and the docs. MadSpin's density libraries (madmatrix/density.py) stay pinned tom.build.<BACKEND>_<FPTYPE>(wasbuild.<BACKEND>). Two FPTYPEs of one backend can now coexist; before, changing[run] precisionbetween two mg7 runs of one output failed with "Cannot build for tag". The.hrflagslookup and thecheck_sa.exerelink marker follow. Existing outputs keep the old makefile and need regenerating.[run] precision_check(default0.01,0disables), newmadgraph/mg7/precision_check.py. A run in a precision other thanall64also builds anFPTYPE=dlibrary of each MadMatrix subprocess (same CPU backend). After the events are written, it evaluates a sample of them (1%, at most 1000; hiddenprecision_check_max_events) with both libraries at the same momenta, flavour, alpha_s and good helicities, through UMAMI/ctypes, each FPTYPE in its own process. The mean, |M|²-weighted and max relative deviations are logged and written toEvents/<run>/precision_check.json, with a warning aboveprecision_check_threshold(1e-3) or on non-finite values. Disabled for all64, gridpack-only runs, cluster jobs and the dummy ME.Validation (local, macOS arm64)
vevaluation reproduces the |M|² madspace computed during the run bit for bit (lhe_npy incl. mirrored flavours, compact_npy):test_precision_check_reproduces_the_run_mg7.p p > e+ e- j: mean 2e-6, max 1e-5.p p > t t~ j: max 2e-6.e+ e- > w+ w-at 100 TeV: 8/200 events above 1e-3 (max 6.7%), warning emitted; |M|²-weighted deviation 3e-7. The automatic FD gauge avoids this.acceptancetest_mg7.yml: 86/98 pass; the rest are local environment issues (NLO widths fall back to LO without fastjet/loop libs; simd_consistency imported another madspace build).acceptancetest.yml: all pass.maincheckout.CI impact (what this draft is for)
FPTYPE=dbuild per mg7 run, about the cost of thevbuild (p p > t t~ j j, 4 jobs: v 10 s, d 8 s locally). Expect the most effect oncheck_xsec_processesandacceptancetest_mg7_bundle_2. If too costly there, those jobs can setprecision_check = 0.von CUDA/HIP has never run in GPU CI: the GPU workflows need to be dispatched on this branch.New tests are registered in
unittest.yml(unittest_interface_uncovered) andacceptancetest_mg7.yml(acceptancetest_mg7_bundle_4).🤖 Generated with Claude Code