Repository navigation
Gridpack improvements: fewer files, compression, output directories - #250
Conversation
… channel max weights and integral priors
After splitting the backends code, the subfolder "backend" was added to the process folder. This folder should be copied when the full source gridpack is asked.
|
@oliviermattelaer We should consider dropping that import of the madgraph package altogether, since the goal of gridpacks is to be self-contained. Or do we need it for anything? |
|
It actually does work without it, but has issue if madgraph is linked to the gripack: The try: from madgraph... already exists on main (line 99), so it isn’t new. What’s new is the run_card.get("gridpack", {}) call:
The real question is how do we support madgraph to be importable in general. If we advise to have MG in the PythonPath then we need a full change of the code and decide how to handle mismatch configuration. |
|
I'll drop it then. All run-card settings for gridpacks can be overwritten through command line arguments, so overwriting local code should not be necessary because the only place where the |
…in optimize_only, temp_output_dir auto, pigz compression, drop RunCardMG7 from gridpack, py3.11 f-string
|
@oliviermattelaer I implemented you feedback. So this can be merged once tests pass. |
This PR aims to make CMS happy. It reduces the number of small files in MG7 gridpacks by a lot, and allows flexible output paths for temporary and final files such that gridpacks can be read-only.
Changes
[gridpack] compress(defaultfalse): pack the gridpack intogridpack.tar.gzand remove the uncompressed directory.No
includefolder: the built madspace copied into a gridpack no longer ships itsinclude/directory.temp_output_dir/output_dir([gridpack]run card options, and--temp_output_dir/--output_dirfor the gridpack'sbin/generate_events):output_dirreceives the final files, and noEvents/<run>folder is created when it is set.temp_output_dirreceives the temporary per-channel npy files."") keep the current behaviour.data/globals.tarreplaces thedata/globals/directory of small npy files.TarWriter/TarReader(madspace/driver/tar.hpp) write and read standard POSIX ustar archives, readable bytar, Python'starfileand numpy.save_tensor/load_tensorgained overloads for tar entries. The npy format is unchanged.uniontype punning,reinterpret_cast).Tensor::is_contiguousdoc comment (storage is column-major).data/channels.jsonreplaces the per-channeldata/channels/*.json.ChannelEventGeneratorgainedto_json()andload_json().Source hash check: a madspace source hash mismatch between the gridpack and the installed madspace is now an error.
bin/generate_events --ignore_source_hashruns anyway and still prints the warning.[gridpack] run_mode(regular,minimal,fix_max_weight; defaultminimal; only used whensave_gridpackis set):regular: a normal run with events, then the gridpack is stored.minimal: no events. With MadNIS the gridpack is stored right after the training, with VEGAS once the grid of every channel has converged (newEventGenerator::optimize()).fix_max_weight: no events. Every channel runs untilfreeze_max_weight_afterunweighted events (newEventGenerator::fix_max_weights()). Each channel's max weight is stored in the gridpack and kept fixed, and its integral is stored and combined (inverse-variance weighted) with the on-the-fly estimate to share the events between channels. Caveat: a low-efficiency channel can make this mode slow.Docs:
docs/source/gridpacks.rstdescribes the new layout,compress, the output directories andrun_mode.Compatibility
Gridpacks created before this change (with
data/globals/anddata/channels/) cannot be run by the newbin/generate_events.Testing
madspace/tests/test_tar.py: round trip, and reading/extracting with systemtar,tarfileand numpy.test_*reproducib*_mg7tests pass (withMG7_REPRO_EVENTS=2000), including the MadNIS and VEGAS gridpack ones with the newminimaldefault.e+ e- > mu+ mu-gridpacks in eachrun_mode, with the default settings and with the new options.